diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-05-06 11:28:47 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-05-06 11:28:47 -0700 |
commit | 5472fa412348b37088c58def15288cf48f489681 (patch) | |
tree | cc1bddb422bc389d1e80990c8a9a447ed2ba19f6 | |
parent | df9b7171922882f420768efdd2ded90940031043 (diff) | |
download | ffi-yajl-5472fa412348b37088c58def15288cf48f489681.tar.gz |
add rubocop + reek
-rw-r--r-- | .reek.yml | 7 | ||||
-rw-r--r-- | .rubocop.yml | 38 | ||||
-rw-r--r-- | Gemfile | 8 | ||||
-rw-r--r-- | Rakefile | 137 |
4 files changed, 167 insertions, 23 deletions
diff --git a/.reek.yml b/.reek.yml new file mode 100644 index 0000000..d51b1c1 --- /dev/null +++ b/.reek.yml @@ -0,0 +1,7 @@ +--- +UncommunicativeModuleName: + enabled: false +UncommunicativeVariableName: + enabled: false +IrresponsibleModule: + enabled: false diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..3d62982 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,38 @@ +AndOr: + Enabled: false +ClassLength: + Enabled: false +CommentAnnotation: + Enabled: false +Documentation: + Enabled: false +DoubleNegation: + Enabled: false +Encoding: + Enabled: false +Eval: + Enabled: false +FormatString: + Enabled: false +HashSyntax: + Enabled: false +LineLength: + Enabled: false +MethodLength: + Enabled: false +PercentLiteralDelimiters: + Enabled: false +RegexpLiteral: + Enabled: false +SignalException: + Enabled: false +SingleSpaceBeforeFirstArg: + Enabled: false +SpaceInsideBrackets: + Enabled: false +SpaceInsideParens: + Enabled: false +StringLiterals: + Enabled: false +TrailingComma: + EnforcedStyleForMultiline: comma @@ -6,3 +6,11 @@ platforms :rbx do gem 'rubysl', '~> 2.0' end +group :development_extras do + gem 'rubocop', '= 0.21.0' + gem 'reek', '= 1.3.7' + gem 'test-kitchen', '~> 1.2' + gem 'kitchen-digitalocean' + gem 'kitchen-ec2' + gem 'kitchen-vagrant' +end @@ -1,35 +1,13 @@ require 'rspec/core/rake_task' require 'rubygems/package_task' require 'rake/extensiontask' +require 'ffi_yajl/version' Dir[File.expand_path("../*gemspec", __FILE__)].reverse.each do |gemspec_path| gemspec = eval(IO.read(gemspec_path)) Gem::PackageTask.new(gemspec).define end -require 'ffi_yajl/version' - -desc "Run all specs against both extensions" -task :spec do - Rake::Task["spec:ffi"].invoke - Rake::Task["spec:ext"].invoke -end - -namespace :spec do - desc "Run all specs against ffi extension" - RSpec::Core::RakeTask.new(:ffi) do |t| - ENV['FORCE_FFI_YAJL'] = "ffi" - t.pattern = FileList['spec/**/*_spec.rb'] - end - if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/ - desc "Run all specs again c extension" - RSpec::Core::RakeTask.new(:ext) do |t| - ENV['FORCE_FFI_YAJL'] = "ext" - t.pattern = FileList['spec/**/*_spec.rb'] - end - end -end - desc "Build it and ship it" task :ship => [:clean, :gem] do sh("git tag #{FFI_Yajl::VERSION}") @@ -69,3 +47,116 @@ Rake::ExtensionTask.new do |ext| ext.ext_dir = 'ext/ffi_yajl/ext/parser' ext.gem_spec = spec end + +# +# test tasks +# + +desc "Run all specs against both extensions" +task :spec do + Rake::Task["spec:ffi"].invoke + Rake::Task["spec:ext"].invoke +end + +namespace :spec do + desc "Run all specs against ffi extension" + RSpec::Core::RakeTask.new(:ffi) do |t| + ENV['FORCE_FFI_YAJL'] = "ffi" + t.pattern = FileList['spec/**/*_spec.rb'] + end + if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/ + desc "Run all specs again c extension" + RSpec::Core::RakeTask.new(:ext) do |t| + ENV['FORCE_FFI_YAJL'] = "ext" + t.pattern = FileList['spec/**/*_spec.rb'] + end + end +end + +if RUBY_VERSION.to_f >= 1.9 + namespace :integration do + begin + require 'kitchen' + rescue LoadError + task :vagrant do + puts "test-kitchen gem is not installed" + end + task :cloud do + puts "test-kitchen gem is not installed" + end + else + desc 'Run Test Kitchen with Vagrant' + task :vagrant do + Kitchen.logger = Kitchen.default_file_logger + Kitchen::Config.new.instances.each do |instance| + instance.test(:always) + end + end + + desc 'Run Test Kitchen with cloud plugins' + task :cloud do + if ENV['TRAVIS_PULL_REQUEST'] != 'true' + ENV['KITCHEN_YAML'] = '.kitchen.cloud.yml' + sh "kitchen test --concurrency 4" + end + end + end + end + namespace :style do + desc 'Run Ruby style checks' + begin + require 'rubocop/rake_task' + rescue LoadError + task :rubocop do + puts "rubocop gem is not installed" + end + else + Rubocop::RakeTask.new(:rubocop) do |t| + t.fail_on_error = false + end + end + + desc 'Run Ruby smell checks' + begin + require 'reek/rake/task' + rescue LoadError + task :reek do + puts "reek gem is not installed" + end + else + Reek::Rake::Task.new(:reek) do |t| + t.fail_on_error = false +# t.config_files = '.reek.yml' + end + end + end +else + namespace :integration do + task :vagrant do + puts "test-kitchen unsupported on ruby 1.8" + end + task :cloud do + puts "test-kitchen unsupported on ruby 1.8" + end + end + namespace :style do + task :rubocop do + puts "rubocop unsupported on ruby 1.8" + end + task :reek do + puts "reek unsupported on ruby 1.8" + end + end +end + + +desc 'Run all style checks' +task :style => ['style:rubocop', 'style:reek'] + +desc 'Run style + spec tests by default on travis' +task :travis => ['style', 'spec'] + +desc 'Run style, spec and test kichen on travis' +task :travis_all => ['style', 'spec', 'integration:cloud'] + +task :default => ['style', 'spec', 'integration:vagrant'] |