Skip to content

Commit

Permalink
Merge pull request #7 from abotalov/build-on-windows
Browse files Browse the repository at this point in the history
Build on windows, update Rubocop
  • Loading branch information
ixti authored Jan 17, 2017
2 parents 491c893 + 1f48738 commit a2e5e06
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 30 deletions.
15 changes: 6 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
AllCops:
DisplayCopNames: true

## Styles ######################################################################

Style/AlignParameters:
Expand Down Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
10 changes: 10 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions http-form_data.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lib/http/form_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/http/form_data/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/http/form_data/multipart/param.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
2 changes: 1 addition & 1 deletion lib/http/form_data/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module HTTP
module FormData
# Gem version.
VERSION = "1.0.1"
VERSION = "1.0.1".freeze
end
end
6 changes: 3 additions & 3 deletions spec/lib/http/form_data/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
5 changes: 4 additions & 1 deletion spec/lib/http/form_data/multipart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a2e5e06

Please sign in to comment.