diff --git a/.rubocop.yml b/.rubocop.yml index 6cd11eb..01f9380 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,6 @@ +AllCops: + DisplayCopNames: true + ## Styles ###################################################################### Style/AlignParameters: @@ -31,18 +34,12 @@ Style/Lambda: Style/MultilineOperationIndentation: EnforcedStyle: indented -# A bit useless restriction, that makes impossible aligning code like this: -# -# redis do |conn| -# conn.hset :k1, now -# conn.hincrby :k2, 123 -# end -SingleSpaceBeforeFirstArg: - Enabled: false - Style/StringLiterals: EnforcedStyle: double_quotes +Style/EmptyCaseCondition: + Enabled: false + # Not all trivial readers/writers can be defined with attr_* methods # # class Example < SimpleDelegator diff --git a/.travis.yml b/.travis.yml index beca66c..a6d8d16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,17 +4,12 @@ env: - JRUBY_OPTS="$JRUBY_OPTS --debug" language: ruby rvm: - - 1.9.3 - 2.0.0 - 2.1 - 2.2 - - jruby-19mode - - jruby-head - - rbx-2 - - ruby-head + - 2.3.0 + - 2.4.0 + - jruby-9.1.6.0 matrix: - allow_failures: - - rvm: jruby-head - - rvm: ruby-head fast_finish: true sudo: false diff --git a/Gemfile b/Gemfile index 39bc30f..e9e2b0a 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ group :test do gem "coveralls" gem "rspec", "~> 3.1" gem "simplecov", ">= 0.9" - gem "rubocop", "~> 0.28.0" + gem "rubocop", "= 0.40.0" end group :doc do diff --git a/README.md b/README.md index f795042..ccbc2e7 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,11 @@ socket << form.to_s This library aims to support and is [tested against][ci] the following Ruby versions: -* Ruby 1.9.3 * Ruby 2.0.0 * Ruby 2.1.x * Ruby 2.2.x +* Ruby 2.3.x +* JRuby 9.1.6.0 If something doesn't work on one of these versions, it's a bug. diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..900265c --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,10 @@ +version: "#{build}" +build: off +init: + - git config --global core.autocrlf true +install: + - set PATH=C:\Ruby23\bin;%PATH% + - bundle install +test_script: + - bundle exec rake +skip_tags: true diff --git a/http-form_data.gemspec b/http-form_data.gemspec index dada111..bb24696 100644 --- a/http-form_data.gemspec +++ b/http-form_data.gemspec @@ -11,15 +11,15 @@ Gem::Specification.new do |spec| spec.email = ["ixti@member.fsf.org"] spec.license = "MIT" spec.summary = "http-form_data-#{HTTP::FormData::VERSION}" - spec.description = <<-DESC.gsub(/^\s+> /m, "").gsub("\n", " ").strip + spec.description = <<-DESC.gsub(/^\s+> /m, "").tr("\n", " ").strip > Utility-belt to build form data request bodies. > Provides support for `application/x-www-form-urlencoded` and > `multipart/form-data` types. DESC spec.files = `git ls-files -z`.split("\x0") - spec.executables = spec.files.grep(/^bin\//).map { |f| File.basename(f) } - spec.test_files = spec.files.grep(/^(test|spec|features)\//) + spec.executables = spec.files.grep(%r{^bin\/}).map { |f| File.basename(f) } + spec.test_files = spec.files.grep(%r{^(test|spec|features)\/}) spec.require_paths = ["lib"] spec.add_development_dependency "bundler", "~> 1.7" diff --git a/lib/http/form_data.rb b/lib/http/form_data.rb index c2853b5..9179a30 100644 --- a/lib/http/form_data.rb +++ b/lib/http/form_data.rb @@ -55,7 +55,7 @@ def ensure_hash(obj) when obj.nil? then {} when obj.is_a?(Hash) then obj when obj.respond_to?(:to_h) then obj.to_h - else fail Error, "#{obj.inspect} is neither Hash nor responds to :to_h" + else raise Error, "#{obj.inspect} is neither Hash nor responds to :to_h" end end diff --git a/lib/http/form_data/file.rb b/lib/http/form_data/file.rb index 2e00519..900eddc 100644 --- a/lib/http/form_data/file.rb +++ b/lib/http/form_data/file.rb @@ -67,7 +67,7 @@ def with_io if @file_or_io.is_a?(::File) || @file_or_io.is_a?(StringIO) yield @file_or_io else - ::File.open(@file_or_io) { |io| yield io } + ::File.open(@file_or_io, "rb") { |io| yield io } end end end diff --git a/lib/http/form_data/multipart/param.rb b/lib/http/form_data/multipart/param.rb index e84342a..a8617de 100644 --- a/lib/http/form_data/multipart/param.rb +++ b/lib/http/form_data/multipart/param.rb @@ -6,7 +6,8 @@ class Param # @param [#to_s] name # @param [FormData::File, #to_s] value def initialize(name, value) - @name, @value = name.to_s, value + @name = name.to_s + @value = value @header = "Content-Disposition: form-data; name=#{@name.inspect}" diff --git a/lib/http/form_data/version.rb b/lib/http/form_data/version.rb index 4953957..b2bf8cc 100644 --- a/lib/http/form_data/version.rb +++ b/lib/http/form_data/version.rb @@ -1,6 +1,6 @@ module HTTP module FormData # Gem version. - VERSION = "1.0.1" + VERSION = "1.0.1".freeze end end diff --git a/spec/lib/http/form_data/file_spec.rb b/spec/lib/http/form_data/file_spec.rb index 37dfe1e..8dd5cee 100644 --- a/spec/lib/http/form_data/file_spec.rb +++ b/spec/lib/http/form_data/file_spec.rb @@ -28,7 +28,7 @@ context "when file given as a String" do let(:file) { fixture("the-http-gem.info").to_s } - it { is_expected.to eq fixture("the-http-gem.info").read } + it { is_expected.to eq fixture("the-http-gem.info").read(:mode => "rb") } end context "when file given as StringIO" do @@ -37,9 +37,9 @@ end context "when file given as File" do - let(:file) { fixture("the-http-gem.info").open } + let(:file) { fixture("the-http-gem.info").open("rb") } after { file.close } - it { is_expected.to eq fixture("the-http-gem.info").read } + it { is_expected.to eq fixture("the-http-gem.info").read(:mode => "rb") } end end diff --git a/spec/lib/http/form_data/multipart_spec.rb b/spec/lib/http/form_data/multipart_spec.rb index b715541..de7176a 100644 --- a/spec/lib/http/form_data/multipart_spec.rb +++ b/spec/lib/http/form_data/multipart_spec.rb @@ -6,7 +6,10 @@ describe "#content_type" do subject { form_data.content_type } - it { is_expected.to match(/^multipart\/form-data; boundary=#{boundary}$/) } + + let(:content_type) { %r{^multipart\/form-data; boundary=#{boundary}$} } + + it { is_expected.to match(content_type) } end describe "#content_length" do