Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update travis-ci config #8

Merged
merged 4 commits into from
Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.4

## Metrics #####################################################################

Metrics/BlockLength:
Exclude:
- "Guardfile"
- "spec/**/*"

Metrics/MethodLength:
CountComments: false
Max: 15

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

Expand Down Expand Up @@ -53,9 +65,3 @@ Style/EmptyCaseCondition:
# end
Style/TrivialAccessors:
Enabled: false

## Metrics #####################################################################

Metrics/MethodLength:
CountComments: false
Max: 15
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ env:
- JRUBY_OPTS="$JRUBY_OPTS --debug"
language: ruby
rvm:
- 2.0.0
- 2.1
- 2.2
- 2.3.0
- 2.3.1
- 2.3.2
- 2.3.3
- 2.4.0
- ruby-head
- jruby-9.1.6.0
- jruby-head
matrix:
allow_failures:
- rvm: ruby-head
- rvm: jruby-head
fast_finish: true
sudo: false
8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "rake"

group :development do
gem "pry"
gem "guard"
gem "guard-rspec", :require => false
gem "pry"
end

group :test do
gem "coveralls"
gem "rspec", "~> 3.1"
gem "rubocop", "= 0.47.0"
gem "simplecov", ">= 0.9"
gem "rubocop", "= 0.40.0"
end

group :doc do
gem "yard"
gem "redcarpet"
gem "yard"
end

# Specify your gem's dependencies in form_data.gemspec
Expand Down
2 changes: 2 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

guard :rspec, :cmd => "bundle exec rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ socket << form.to_s
This library aims to support and is [tested against][ci] the following Ruby
versions:

* Ruby 2.0.0
* Ruby 2.1.x
* Ruby 2.2.x
* Ruby 2.3.x
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env rake
# frozen_string_literal: true

require "bundler/gem_tasks"

Expand Down
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
version: "#{build}"
build: off
init:
- git config --global core.autocrlf true
install:
- set PATH=C:\Ruby23\bin;%PATH%
- bundle install
Expand Down
3 changes: 2 additions & 1 deletion http-form_data.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "http/form_data/version"
Expand Down
4 changes: 3 additions & 1 deletion lib/http/form_data.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "http/form_data/file"
require "http/form_data/multipart"
require "http/form_data/urlencoded"
Expand Down Expand Up @@ -26,7 +28,7 @@ module HTTP
# socket << form.to_s
module FormData
# CRLF
CRLF = "\r\n".freeze
CRLF = "\r\n"

# Generic FormData error.
class Error < StandardError; end
Expand Down
4 changes: 3 additions & 1 deletion lib/http/form_data/file.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module HTTP
module FormData
# Represents file form param.
Expand All @@ -18,7 +20,7 @@ module FormData
# FormData::File.new "/home/ixti/avatar.png"
class File
# Default MIME type
DEFAULT_MIME = "application/octet-stream".freeze
DEFAULT_MIME = "application/octet-stream"

attr_reader :mime_type, :filename

Expand Down
6 changes: 3 additions & 3 deletions lib/http/form_data/multipart.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# stdlib
# frozen_string_literal: true

require "securerandom"

# internal
require "http/form_data/multipart/param"

module HTTP
Expand All @@ -11,7 +11,7 @@ class Multipart
# @param [#to_h, Hash] data form data key-value Hash
def initialize(data)
@parts = Param.coerce FormData.ensure_hash data
@boundary = ("-" * 21) << SecureRandom.hex(21)
@boundary = (Array.new(21, "-") << SecureRandom.hex(21)).join("")
@content_length = nil
end

Expand Down
14 changes: 8 additions & 6 deletions lib/http/form_data/multipart/param.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# frozen_string_literal: true

module HTTP
module FormData
class Multipart
# Utility class to represent multi-part chunks
class Param
CONTENT_DISPOSITION = ""

# @param [#to_s] name
# @param [FormData::File, #to_s] value
def initialize(name, value)
@name = name.to_s
@value = value

@name = name.to_s
@value = value
@header = "Content-Disposition: form-data; name=#{@name.inspect}"

return unless file?

@header << "; filename=#{value.filename.inspect}"
@header << CRLF
@header << "Content-Type: #{value.mime_type}"
@header = "#{@header}; filename=#{value.filename.inspect}#{CRLF}" \
"Content-Type: #{value.mime_type}"
end

# Returns body part with headers and data.
Expand Down
2 changes: 2 additions & 0 deletions lib/http/form_data/urlencoded.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "uri"

module HTTP
Expand Down
4 changes: 3 additions & 1 deletion lib/http/form_data/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

module HTTP
module FormData
# Gem version.
VERSION = "1.0.1".freeze
VERSION = "1.0.1"
end
end
1 change: 1 addition & 0 deletions spec/lib/http/form_data/file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# coding: utf-8

RSpec.describe HTTP::FormData::File do
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/http/form_data/multipart_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe HTTP::FormData::Multipart do
let(:file) { HTTP::FormData::File.new fixture "the-http-gem.info" }
let(:params) { { :foo => :bar, :baz => file } }
Expand Down
1 change: 1 addition & 0 deletions spec/lib/http/form_data/urlencoded_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# coding: utf-8

RSpec.describe HTTP::FormData::Urlencoded do
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/http/form_data_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe HTTP::FormData do
describe ".create" do
subject { HTTP::FormData.create params }
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding: utf-8
# frozen_string_literal: true

require "simplecov"
require "coveralls"
Expand Down
2 changes: 1 addition & 1 deletion spec/support/fixtures_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding: utf-8
# frozen_string_literal: true

require "pathname"

Expand Down