diff options
author | Tim Smith <tsmith@chef.io> | 2018-03-06 09:26:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-06 09:26:54 -0800 |
commit | 230b7d0ace8ab1d04cd7fc3e6727d1b879a70902 (patch) | |
tree | 8c3af8e8f87c98e22e2b4e5212382a80340ae437 | |
parent | cbcdfb0f7fac1cb64fa7a0319301cc3d6238eed6 (diff) | |
parent | b21692a88c25de177e29f832073d49e5800e4941 (diff) | |
download | libyajl2-gem-230b7d0ace8ab1d04cd7fc3e6727d1b879a70902.tar.gz |
Merge pull request #17 from chef/tm/chefstyle
Move to using chefstyle
-rw-r--r-- | .rubocop.yml | 38 | ||||
-rw-r--r-- | Gemfile | 20 | ||||
-rw-r--r-- | Rakefile | 64 | ||||
-rw-r--r-- | ext/libyajl2/extconf.rb | 18 | ||||
-rw-r--r-- | libyajl2.gemspec | 10 | ||||
-rw-r--r-- | spec/ffi_spec.rb | 4 | ||||
-rw-r--r-- | spec/path_spec.rb | 4 | ||||
-rw-r--r-- | spec/spec_helper.rb | 4 |
8 files changed, 62 insertions, 100 deletions
diff --git a/.rubocop.yml b/.rubocop.yml deleted file mode 100644 index 3d62982..0000000 --- a/.rubocop.yml +++ /dev/null @@ -1,38 +0,0 @@ -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 @@ -1,18 +1,18 @@ -source 'https://rubygems.org' +source "https://rubygems.org" gemspec 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' + gem "chefstyle" + gem "reek" + gem "test-kitchen", "~> 1.2" + gem "kitchen-digitalocean" + gem "kitchen-ec2" + gem "kitchen-vagrant" end platforms :rbx do - gem 'racc' - gem 'rubysl', '~> 2.0' - gem 'psych' + gem "racc" + gem "rubysl", "~> 2.0" + gem "psych" end @@ -1,15 +1,15 @@ $: << File.expand_path(File.join(File.dirname( __FILE__ ), "lib")) -require 'rubygems' -require 'rake' +require "rubygems" +require "rake" -require 'rubygems/package_task' -require 'rspec/core/rake_task' -require 'rake/extensiontask' +require "rubygems/package_task" +require "rspec/core/rake_task" +require "rake/extensiontask" GEM_NAME = "libyajl2" -gemspec = eval(File.read('libyajl2.gemspec')) +gemspec = eval(File.read("libyajl2.gemspec")) # rubocop:disable Security/Eval Gem::PackageTask.new(gemspec) do |pkg| pkg.need_tar = true @@ -41,9 +41,9 @@ task :clean do sh "git clean -fdx" end -Rake::ExtensionTask.new('libyajl', gemspec) do |ext| - ext.lib_dir = 'lib/libyajl2/vendored-libyajl2/lib' - ext.ext_dir = 'ext/libyajl2' +Rake::ExtensionTask.new("libyajl", gemspec) do |ext| + ext.lib_dir = "lib/libyajl2/vendored-libyajl2/lib" + ext.ext_dir = "ext/libyajl2" end # hack to generate yajl_version.h without using cmake @@ -53,17 +53,17 @@ def generate_yajl_version yajl_major = yajl_minor = yajl_micro = nil File.open("#{vendor_path}/CMakeLists.txt").each do |line| - if m = line.match(/YAJL_MAJOR (\d+)/) + if (m = line.match(/YAJL_MAJOR (\d+)/)) yajl_major = m[1] end - if m = line.match(/YAJL_MINOR (\d+)/) + if (m = line.match(/YAJL_MINOR (\d+)/)) yajl_minor = m[1] end - if m = line.match(/YAJL_MICRO (\d+)/) + if (m = line.match(/YAJL_MICRO (\d+)/)) yajl_micro = m[1] end end - File.open("#{build_path}/api/yajl_version.h", "w+") do |out| # FIXME: relative path + File.open("#{build_path}/api/yajl_version.h", "w+") do |out| # FIXME: relative path File.open("#{vendor_path}/src/api/yajl_version.h.cmake").each do |line| line.gsub!(/\$\{YAJL_MAJOR\}/, yajl_major) line.gsub!(/\$\{YAJL_MINOR\}/, yajl_minor) @@ -136,7 +136,7 @@ RSpec::Core::RakeTask.new(:spec) if RUBY_VERSION.to_f >= 1.9 namespace :integration do begin - require 'kitchen' + require "kitchen" rescue LoadError task :vagrant do puts "test-kitchen gem is not installed" @@ -145,7 +145,7 @@ if RUBY_VERSION.to_f >= 1.9 puts "test-kitchen gem is not installed" end else - desc 'Run Test Kitchen with Vagrant' + desc "Run Test Kitchen with Vagrant" task :vagrant do Kitchen.logger = Kitchen.default_file_logger Kitchen::Config.new.instances.each do |instance| @@ -153,32 +153,33 @@ if RUBY_VERSION.to_f >= 1.9 end end - desc 'Run Test Kitchen with cloud plugins' + desc "Run Test Kitchen with cloud plugins" task :cloud do - if ENV['TRAVIS_PULL_REQUEST'] != 'true' - ENV['KITCHEN_YAML'] = '.kitchen.cloud.yml' + 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' + desc "Run Ruby style checks" begin - require 'rubocop/rake_task' + require "chefstyle" + require "rubocop/rake_task" rescue LoadError task :rubocop do puts "rubocop gem is not installed" end else - Rubocop::RakeTask.new(:rubocop) do |t| + RuboCop::RakeTask.new(:rubocop) do |t| t.fail_on_error = false end end - desc 'Run Ruby smell checks' + desc "Run Ruby smell checks" begin - require 'reek/rake/task' + require "reek/rake/task" rescue LoadError task :reek do puts "reek gem is not installed" @@ -186,7 +187,7 @@ if RUBY_VERSION.to_f >= 1.9 else Reek::Rake::Task.new(:reek) do |t| t.fail_on_error = false - t.config_files = '.reek.yml' + t.config_file = ".reek.yml" end end end @@ -209,14 +210,13 @@ else end end +desc "Run all style checks" +task :style => ["style:rubocop", "style:reek"] -desc 'Run all style checks' -task :style => ['style:rubocop', 'style:reek'] +desc "Run style + spec tests by default on travis" +task :travis => %w{spec style} -desc 'Run style + spec tests by default on travis' -task :travis => ['spec', 'style'] +desc "Run style, spec and test kichen on travis" +task :travis_all => ["spec", "integration:cloud", "style"] -desc 'Run style, spec and test kichen on travis' -task :travis_all => ['spec', 'integration:cloud', 'style'] - -task :default => ['spec', 'integration:vagrant', 'style'] +task :default => ["spec", "integration:vagrant", "style"] diff --git a/ext/libyajl2/extconf.rb b/ext/libyajl2/extconf.rb index c4e9b31..07afbe7 100644 --- a/ext/libyajl2/extconf.rb +++ b/ext/libyajl2/extconf.rb @@ -1,7 +1,7 @@ -require 'rbconfig' -require 'fileutils' -require 'shellwords' +require "rbconfig" +require "fileutils" +require "shellwords" if ENV["USE_SYSTEM_LIBYAJL2"] File.open("Makefile", "w+") do |f| @@ -37,17 +37,17 @@ module Libyajl2Build end def self.deps - require 'mkmf' + require "mkmf" end def self.setup_env - RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC'] + RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"] # set some sane defaults - if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc|clang/ + if RbConfig::MAKEFILE_CONFIG["CC"] =~ /gcc|clang/ # magic flags copied from upstream yajl build system (-std=c99 is necessary for older gcc) $CFLAGS << " -std=c99 -pedantic -Wpointer-arith -Wno-format-y2k -Wstrict-prototypes -Wmissing-declarations -Wnested-externs -Wextra -Wundef -Wwrite-strings -Wold-style-definition -Wredundant-decls -Wno-unused-parameter -Wno-sign-compare -Wmissing-prototypes" - $CFLAGS << " -O2" # match what the upstream uses for optimization + $CFLAGS << " -O2" # match what the upstream uses for optimization # create the implib on windows if windows? @@ -96,8 +96,8 @@ EOF # i could not figure out how to tell mkmf.rb to stop being so helpful, so instead will just patch it here. if windows? makefile = IO.read("Makefile") - makefile.gsub!(/\$\(DEFFILE\)/, '') - File.open("Makefile", 'w+') {|f| f.write(makefile) } + makefile.gsub!(/\$\(DEFFILE\)/, "") + File.open("Makefile", "w+") { |f| f.write(makefile) } end system("pwd") diff --git a/libyajl2.gemspec b/libyajl2.gemspec index 5f8b6f2..05ac626 100644 --- a/libyajl2.gemspec +++ b/libyajl2.gemspec @@ -1,7 +1,7 @@ # coding: utf-8 -lib = File.expand_path('../lib', __FILE__) +lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'libyajl2/version' +require "libyajl2/version" Gem::Specification.new do |spec| spec.name = "libyajl2" @@ -11,7 +11,7 @@ Gem::Specification.new do |spec| spec.summary = %q{Installs a vendored copy of libyajl2 for distributions which lack it} spec.description = spec.summary spec.homepage = "https://github.com/opscode/libyajl2-gem" - spec.licenses = ["Apache 2.0"] + spec.licenses = ["Apache 2.0"] spec.files = Dir.glob("{ext,lib,spec}/**/*") + %w{Gemfile Rakefile CONTRIBUTING.md README.md libyajl2.gemspec bootstrap.sh LICENSE} @@ -25,7 +25,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler" spec.add_development_dependency "rake" # rake-compiler 0.9.2 is required for rbx compiles, and in turn requires rubygems >= 1.8.25 - spec.add_development_dependency "rake-compiler", "~> 0.9" - spec.add_development_dependency "rspec", "~> 2.14" + spec.add_development_dependency "rake-compiler" + spec.add_development_dependency "rspec" spec.add_development_dependency "ffi", "~> 1.9" end diff --git a/spec/ffi_spec.rb b/spec/ffi_spec.rb index f4a3a6e..15c84be 100644 --- a/spec/ffi_spec.rb +++ b/spec/ffi_spec.rb @@ -1,6 +1,6 @@ -require 'spec_helper' +require "spec_helper" -require 'ffi' +require "ffi" module LibyajlTestFFI extend ::FFI::Library diff --git a/spec/path_spec.rb b/spec/path_spec.rb index 673e340..8d0ca47 100644 --- a/spec/path_spec.rb +++ b/spec/path_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe "when testing path helpers" do it "should define Libyajl2::VENDORED_LIBYAJL2_DIR" do @@ -15,7 +15,7 @@ describe "when testing path helpers" do %w{yajl_common.h yajl_gen.h yajl_parse.h yajl_tree.h yajl_version.h}.each do |hdr| it "should copy the #{hdr} header file to the gem path" do - expect(File.exist?(File.join(Libyajl2.include_path, "yajl", hdr))).to be_true + expect(File.exist?(File.join(Libyajl2.include_path, "yajl", hdr))).to be_truthy end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 63a138c..270ab6d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,10 @@ $LOAD_PATH << File.expand_path(File.join(File.dirname( __FILE__ ), "../lib")) -require 'libyajl2' +require "libyajl2" RSpec.configure do |c| - c.order = 'random' + c.order = "random" c.expect_with :rspec do |c2| c2.syntax = :expect |