http-form_data-1.0.1/0000755000004100000410000000000012602556202014452 5ustar www-datawww-datahttp-form_data-1.0.1/Rakefile0000644000004100000410000000044112602556202016116 0ustar www-datawww-data#!/usr/bin/env rake require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new begin require "rubocop/rake_task" RuboCop::RakeTask.new rescue LoadError task :rubocop do $stderr.puts "RuboCop is disabled" end end task :default => [:spec, :rubocop] http-form_data-1.0.1/Gemfile0000644000004100000410000000057012602556202015747 0ustar www-datawww-datasource "https://rubygems.org" gem "rake" group :development do gem "pry" gem "guard" gem "guard-rspec", :require => false end group :test do gem "coveralls" gem "rspec", "~> 3.1" gem "simplecov", ">= 0.9" gem "rubocop", "~> 0.28.0" end group :doc do gem "yard" gem "redcarpet" end # Specify your gem's dependencies in form_data.gemspec gemspec http-form_data-1.0.1/.rspec0000644000004100000410000000003612602556202015566 0ustar www-datawww-data--color --require spec_helper http-form_data-1.0.1/LICENSE.txt0000644000004100000410000000206312602556202016276 0ustar www-datawww-dataCopyright (c) 2015 Aleksey V Zapparov MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http-form_data-1.0.1/spec/0000755000004100000410000000000012602556202015404 5ustar www-datawww-datahttp-form_data-1.0.1/spec/spec_helper.rb0000644000004100000410000000621612602556202020227 0ustar www-datawww-data# coding: utf-8 require "simplecov" require "coveralls" SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter ] SimpleCov.start { add_filter "/spec/" } require "http/form_data" require "support/fixtures_helper" # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.expect_with :rspec do |expectations| # This option will default to `true` in RSpec 4. It makes the `description` # and `failure_message` of custom matchers include text for helper methods # defined using `chain`, e.g.: # be_bigger_than(2).and_smaller_than(4).description # # => "be bigger than 2 and smaller than 4" # ...rather than: # # => "be bigger than 2" expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_with :rspec do |mocks| # Prevents you from mocking or stubbing a method that does not exist on # a real object. This is generally recommended, and will default to # `true` in RSpec 4. mocks.verify_partial_doubles = true end # These two settings work together to allow you to limit a spec run # to individual examples or groups you care about by tagging them with # `:focus` metadata. When nothing is tagged with `:focus`, all examples # get run. config.filter_run :focus config.run_all_when_everything_filtered = true # Limits the available syntax to the non-monkey patched syntax that is # recommended. For more details, see: # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching config.disable_monkey_patching! # This setting enables warnings. It's recommended, but in some cases may # be too noisy due to issues in dependencies. config.warnings = true # Many RSpec users commonly either run the entire suite or an individual # file, and it's useful to allow more verbose output when running an # individual spec file. if config.files_to_run.one? # Use the documentation formatter for detailed output, # unless a formatter has already been configured # (e.g. via a command-line flag). config.default_formatter = "doc" end # Print the 10 slowest examples and example groups at the # end of the spec run, to help surface which specs are running # particularly slow. config.profile_examples = 10 # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 config.order = :random # Seed global randomization in this process using the `--seed` CLI option. # Setting this allows you to use `--seed` to deterministically reproduce # test failures related to randomization by passing the same `--seed` value # as the one that triggered the failure. Kernel.srand config.seed # Include common helpers config.include FixturesHelper end http-form_data-1.0.1/spec/lib/0000755000004100000410000000000012602556202016152 5ustar www-datawww-datahttp-form_data-1.0.1/spec/lib/http/0000755000004100000410000000000012602556202017131 5ustar www-datawww-datahttp-form_data-1.0.1/spec/lib/http/form_data_spec.rb0000644000004100000410000000261412602556202022427 0ustar www-datawww-dataRSpec.describe HTTP::FormData do describe ".create" do subject { HTTP::FormData.create params } context "when form has no files" do let(:params) { { :foo => :bar } } it { is_expected.to be_a HTTP::FormData::Urlencoded } end context "when form has at least one file param" do let(:gemspec) { HTTP::FormData::File.new "gemspec" } let(:params) { { :foo => :bar, :baz => gemspec } } it { is_expected.to be_a HTTP::FormData::Multipart } end context "when form has file in an array param" do let(:gemspec) { HTTP::FormData::File.new "gemspec" } let(:params) { { :foo => :bar, :baz => [gemspec] } } it { is_expected.to be_a HTTP::FormData::Multipart } end end describe ".ensure_hash" do subject(:ensure_hash) { HTTP::FormData.ensure_hash data } context "when Hash given" do let(:data) { { :foo => :bar } } it { is_expected.to eq :foo => :bar } end context "when #to_h given" do let(:data) { double(:to_h => { :foo => :bar }) } it { is_expected.to eq :foo => :bar } end context "when nil given" do let(:data) { nil } it { is_expected.to eq({}) } end context "when neither Hash nor #to_h given" do let(:data) { double } it "fails with HTTP::FormData::Error" do expect { ensure_hash }.to raise_error HTTP::FormData::Error end end end end http-form_data-1.0.1/spec/lib/http/form_data/0000755000004100000410000000000012602556202021065 5ustar www-datawww-datahttp-form_data-1.0.1/spec/lib/http/form_data/urlencoded_spec.rb0000644000004100000410000000154512602556202024555 0ustar www-datawww-data# coding: utf-8 RSpec.describe HTTP::FormData::Urlencoded do let(:data) { { "foo[bar]" => "test" } } subject(:form_data) { HTTP::FormData::Urlencoded.new data } describe "#content_type" do subject { form_data.content_type } it { is_expected.to eq "application/x-www-form-urlencoded" } end describe "#content_length" do subject { form_data.content_length } it { is_expected.to eq form_data.to_s.bytesize } context "with unicode chars" do let(:data) { { "foo[bar]" => "тест" } } it { is_expected.to eq form_data.to_s.bytesize } end end describe "#to_s" do subject { form_data.to_s } it { is_expected.to eq "foo%5Bbar%5D=test" } context "with unicode chars" do let(:data) { { "foo[bar]" => "тест" } } it { is_expected.to eq "foo%5Bbar%5D=%D1%82%D0%B5%D1%81%D1%82" } end end end http-form_data-1.0.1/spec/lib/http/form_data/multipart_spec.rb0000644000004100000410000000244412602556202024451 0ustar www-datawww-dataRSpec.describe HTTP::FormData::Multipart do let(:file) { HTTP::FormData::File.new fixture "the-http-gem.info" } let(:params) { { :foo => :bar, :baz => file } } let(:boundary) { /-{21}[a-f0-9]{42}/ } subject(:form_data) { HTTP::FormData::Multipart.new params } describe "#content_type" do subject { form_data.content_type } it { is_expected.to match(/^multipart\/form-data; boundary=#{boundary}$/) } end describe "#content_length" do subject { form_data.content_length } it { is_expected.to eq form_data.to_s.bytesize } end describe "#to_s" do def disposition(params) params = params.map { |k, v| "#{k}=#{v.inspect}" }.join("; ") "Content-Disposition: form-data; #{params}" end let(:crlf) { "\r\n" } it "properly generates multipart data" do boundary_value = form_data.content_type[/(#{boundary})$/, 1] expect(form_data.to_s).to eq [ "--#{boundary_value}#{crlf}", "#{disposition 'name' => 'foo'}#{crlf}", "#{crlf}bar#{crlf}", "--#{boundary_value}#{crlf}", "#{disposition 'name' => 'baz', 'filename' => file.filename}#{crlf}", "Content-Type: #{file.mime_type}#{crlf}", "#{crlf}#{file}#{crlf}", "--#{boundary_value}--" ].join("") end end end http-form_data-1.0.1/spec/lib/http/form_data/file_spec.rb0000644000004100000410000000517512602556202023353 0ustar www-datawww-data# coding: utf-8 RSpec.describe HTTP::FormData::File do let(:opts) { nil } describe "#size" do subject { described_class.new(file, opts).size } 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").size } end context "when file given as StringIO" do let(:file) { StringIO.new "привет мир!" } it { is_expected.to eq 20 } end context "when file given as File" do let(:file) { fixture("the-http-gem.info").open } after { file.close } it { is_expected.to eq fixture("the-http-gem.info").size } end end describe "#to_s" do subject { described_class.new(file, opts).to_s } 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 } end context "when file given as StringIO" do let(:file) { StringIO.new "привет мир!" } it { is_expected.to eq "привет мир!" } end context "when file given as File" do let(:file) { fixture("the-http-gem.info").open } after { file.close } it { is_expected.to eq fixture("the-http-gem.info").read } end end describe "#filename" do subject { described_class.new(file, opts).filename } context "when file given as a String" do let(:file) { fixture("the-http-gem.info").to_s } it { is_expected.to eq ::File.basename file } context "and filename given with options" do let(:opts) { { :filename => "foobar.txt" } } it { is_expected.to eq "foobar.txt" } end end context "when file given as StringIO" do let(:file) { StringIO.new } it { is_expected.to eq "stream-#{file.object_id}" } context "and filename given with options" do let(:opts) { { :filename => "foobar.txt" } } it { is_expected.to eq "foobar.txt" } end end context "when file given as File" do let(:file) { fixture("the-http-gem.info").open } after { file.close } it { is_expected.to eq "the-http-gem.info" } context "and filename given with options" do let(:opts) { { :filename => "foobar.txt" } } it { is_expected.to eq "foobar.txt" } end end end describe "#mime_type" do subject { described_class.new(StringIO.new, opts).mime_type } it { is_expected.to eq "application/octet-stream" } context "when it was given with options" do let(:opts) { { :mime_type => "application/json" } } it { is_expected.to eq "application/json" } end end end http-form_data-1.0.1/spec/fixtures/0000755000004100000410000000000012602556202017255 5ustar www-datawww-datahttp-form_data-1.0.1/spec/fixtures/expected-multipart-body.tpl0000644000004100000410000000000012602556202024537 0ustar www-datawww-datahttp-form_data-1.0.1/spec/fixtures/the-http-gem.info0000644000004100000410000000011512602556202022432 0ustar www-datawww-dataThe HTTP Gem is an easy-to-use client library for making requests from Ruby. http-form_data-1.0.1/spec/support/0000755000004100000410000000000012602556202017120 5ustar www-datawww-datahttp-form_data-1.0.1/spec/support/fixtures_helper.rb0000644000004100000410000000034612602556202022660 0ustar www-datawww-data# coding: utf-8 require "pathname" module FixturesHelper def fixture(filename) fixtures_root.join filename end def fixtures_root @fixtures_root ||= Pathname.new(__FILE__).join("../../fixtures").realpath end end http-form_data-1.0.1/.travis.yml0000644000004100000410000000046312602556202016566 0ustar www-datawww-databundler_args: --without development doc env: global: - 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 matrix: allow_failures: - rvm: jruby-head - rvm: ruby-head fast_finish: true sudo: false http-form_data-1.0.1/lib/0000755000004100000410000000000012602556202015220 5ustar www-datawww-datahttp-form_data-1.0.1/lib/http/0000755000004100000410000000000012602556202016177 5ustar www-datawww-datahttp-form_data-1.0.1/lib/http/form_data/0000755000004100000410000000000012602556202020133 5ustar www-datawww-datahttp-form_data-1.0.1/lib/http/form_data/multipart.rb0000644000004100000410000000277712602556202022516 0ustar www-datawww-data# stdlib require "securerandom" # internal require "http/form_data/multipart/param" module HTTP module FormData # `multipart/form-data` form data. 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) @content_length = nil end # Returns content to be used for HTTP request body. # # @return [String] def to_s head + @parts.map(&:to_s).join(glue) + tail end # Returns MIME type to be used for HTTP request `Content-Type` header. # # @return [String] def content_type "multipart/form-data; boundary=#{@boundary}" end # Returns form data content size to be used for HTTP request # `Content-Length` header. # # @return [Fixnum] def content_length unless @content_length @content_length = head.bytesize + tail.bytesize @content_length += @parts.map(&:size).reduce(:+) @content_length += (glue.bytesize * (@parts.count - 1)) end @content_length end private # @return [String] def head @head ||= "--#{@boundary}#{CRLF}" end # @return [String] def glue @glue ||= "#{CRLF}--#{@boundary}#{CRLF}" end # @return [String] def tail @tail ||= "#{CRLF}--#{@boundary}--" end end end end http-form_data-1.0.1/lib/http/form_data/multipart/0000755000004100000410000000000012602556202022154 5ustar www-datawww-datahttp-form_data-1.0.1/lib/http/form_data/multipart/param.rb0000644000004100000410000000406512602556202023606 0ustar www-datawww-datamodule HTTP module FormData class Multipart # Utility class to represent multi-part chunks class Param # @param [#to_s] name # @param [FormData::File, #to_s] value def initialize(name, value) @name, @value = name.to_s, 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}" end # Returns body part with headers and data. # # @example With {FormData::File} value # # Content-Disposition: form-data; name="avatar"; filename="avatar.png" # Content-Type: application/octet-stream # # ...data of avatar.png... # # @example With non-{FormData::File} value # # Content-Disposition: form-data; name="username" # # ixti # # @return [String] def to_s "#{@header}#{CRLF * 2}#{@value}" end # Calculates size of a part (headers + body). # # @return [Fixnum] def size size = @header.bytesize + (CRLF.bytesize * 2) if file? size + @value.size else size + @value.to_s.bytesize end end # Flattens given `data` Hash into an array of `Param`'s. # Nested array are unwinded. # Behavior is similar to `URL.encode_www_form`. # # @param [Hash] data # @return [Array] def self.coerce(data) params = [] data.each do |name, values| Array(values).each do |value| params << new(name, value) end end params end private # Tells whenever value is a {FormData::File} or not. # # @return [Boolean] def file? @value.is_a? FormData::File end end end end end http-form_data-1.0.1/lib/http/form_data/urlencoded.rb0000644000004100000410000000144712602556202022612 0ustar www-datawww-datarequire "uri" module HTTP module FormData # `application/x-www-form-urlencoded` form data. class Urlencoded # @param [#to_h, Hash] data form data key-value Hash def initialize(data) @data = FormData.ensure_hash data end # Returns content to be used for HTTP request body. # # @return [String] def to_s ::URI.encode_www_form @data end # Returns MIME type to be used for HTTP request `Content-Type` header. # # @return [String] def content_type "application/x-www-form-urlencoded" end # Returns form data content size to be used for HTTP request # `Content-Length` header. # # @return [Fixnum] def content_length to_s.bytesize end end end end http-form_data-1.0.1/lib/http/form_data/file.rb0000644000004100000410000000375412602556202021410 0ustar www-datawww-datamodule HTTP module FormData # Represents file form param. # # @example Usage with StringIO # # io = StringIO.new "foo bar baz" # FormData::File.new io, :filename => "foobar.txt" # # @example Usage with IO # # File.open "/home/ixti/avatar.png" do |io| # FormData::File.new io # end # # @example Usage with pathname # # FormData::File.new "/home/ixti/avatar.png" class File # Default MIME type DEFAULT_MIME = "application/octet-stream".freeze attr_reader :mime_type, :filename # @see DEFAULT_MIME # @param [String, StringIO, File] file_or_io Filename or IO instance. # @param [#to_h] opts # @option opts [#to_s] :mime_type (DEFAULT_MIME) # @option opts [#to_s] :filename # When `file` is a String, defaults to basename of `file`. # When `file` is a File, defaults to basename of `file`. # When `file` is a StringIO, defaults to `"stream-{object_id}"` def initialize(file_or_io, opts = {}) @file_or_io = file_or_io opts = FormData.ensure_hash opts @mime_type = opts.fetch(:mime_type) { DEFAULT_MIME } @filename = opts.fetch :filename do case file_or_io when String then ::File.basename file_or_io when ::File then ::File.basename file_or_io.path else "stream-#{file_or_io.object_id}" end end end # Returns content size. # # @return [Fixnum] def size with_io(&:size) end # Returns content of a file of IO. # # @return [String] def to_s with_io(&:read) end private # @yield [io] Gives IO instance to the block # @return result of yielded block 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 } end end end end end http-form_data-1.0.1/lib/http/form_data/version.rb0000644000004100000410000000012112602556202022137 0ustar www-datawww-datamodule HTTP module FormData # Gem version. VERSION = "1.0.1" end end http-form_data-1.0.1/lib/http/form_data.rb0000644000004100000410000000424412602556202020464 0ustar www-datawww-datarequire "http/form_data/file" require "http/form_data/multipart" require "http/form_data/urlencoded" require "http/form_data/version" # http.rb namespace. # @see https://github.com/httprb/http.rb module HTTP # Utility-belt to build form data request bodies. # Provides support for `application/x-www-form-urlencoded` and # `multipart/form-data` types. # # @example Usage # # form = FormData.create({ # :username => "ixti", # :avatar_file => FormData::File.new("/home/ixti/avatar.png") # }) # # # Assuming socket is an open socket to some HTTP server # socket << "POST /some-url HTTP/1.1\r\n" # socket << "Host: example.com\r\n" # socket << "Content-Type: #{form.content_type}\r\n" # socket << "Content-Length: #{form.content_length}\r\n" # socket << "\r\n" # socket << form.to_s module FormData # CRLF CRLF = "\r\n".freeze # Generic FormData error. class Error < StandardError; end class << self # FormData factory. Automatically selects best type depending on given # `data` Hash. # # @param [#to_h, Hash] data # @return [Multipart] if any of values is a {FormData::File} # @return [Urlencoded] otherwise def create(data) data = ensure_hash data klass = multipart?(data) ? Multipart : Urlencoded klass.new data end # Coerce `obj` to Hash. # # @note Internal usage helper, to workaround lack of `#to_h` on Ruby < 2.1 # @raise [Error] `obj` can't be coerced. # @return [Hash] def ensure_hash(obj) case 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" end end private # Tells whenever data contains multipart data or not. # # @param [Hash] data # @return [Boolean] def multipart?(data) data.any? do |_, v| next true if v.is_a? FormData::File v.respond_to?(:to_ary) && v.to_ary.any? { |e| e.is_a? FormData::File } end end end end end http-form_data-1.0.1/.rubocop.yml0000644000004100000410000000256512602556202016734 0ustar www-datawww-data## Styles ###################################################################### Style/AlignParameters: EnforcedStyle: with_fixed_indentation Style/BracesAroundHashParameters: Enabled: false # Broken (2014-12-15). Use `yardstick` gem instead. # See: https://github.com/bbatsov/rubocop/issues/947 # TODO: Enable back once cop is fixed. Style/Documentation: Enabled: false Style/EmptyLineBetweenDefs: AllowAdjacentOneLineDefs: true Style/Encoding: EnforcedStyle: when_needed Style/HashSyntax: EnforcedStyle: hash_rockets Style/IndentHash: EnforcedStyle: consistent # New lambda syntax is as ugly to me as new syntax of Hash. Style/Lambda: Enabled: false 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 # Not all trivial readers/writers can be defined with attr_* methods # # class Example < SimpleDelegator # def __getobj__ # @obj # end # # def __setobj__(obj) # @obj = obj # end # end Style/TrivialAccessors: Enabled: false ## Metrics ##################################################################### Metrics/MethodLength: CountComments: false Max: 15 http-form_data-1.0.1/metadata.yml0000644000004100000410000000447512602556202016767 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: http-form_data version: !ruby/object:Gem::Version version: 1.0.1 platform: ruby authors: - Aleksey V Zapparov autorequire: bindir: bin cert_chain: [] date: 2015-03-31 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.7' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.7' description: Utility-belt to build form data request bodies. Provides support for `application/x-www-form-urlencoded` and `multipart/form-data` types. email: - ixti@member.fsf.org executables: [] extensions: [] extra_rdoc_files: [] files: - ".gitignore" - ".rspec" - ".rubocop.yml" - ".travis.yml" - ".yardopts" - CHANGES.md - Gemfile - Guardfile - LICENSE.txt - README.md - Rakefile - http-form_data.gemspec - lib/http/form_data.rb - lib/http/form_data/file.rb - lib/http/form_data/multipart.rb - lib/http/form_data/multipart/param.rb - lib/http/form_data/urlencoded.rb - lib/http/form_data/version.rb - spec/fixtures/expected-multipart-body.tpl - spec/fixtures/the-http-gem.info - spec/lib/http/form_data/file_spec.rb - spec/lib/http/form_data/multipart_spec.rb - spec/lib/http/form_data/urlencoded_spec.rb - spec/lib/http/form_data_spec.rb - spec/spec_helper.rb - spec/support/fixtures_helper.rb homepage: https://github.com/httprb/form_data.rb licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: http-form_data-1.0.1 test_files: - spec/fixtures/expected-multipart-body.tpl - spec/fixtures/the-http-gem.info - spec/lib/http/form_data/file_spec.rb - spec/lib/http/form_data/multipart_spec.rb - spec/lib/http/form_data/urlencoded_spec.rb - spec/lib/http/form_data_spec.rb - spec/spec_helper.rb - spec/support/fixtures_helper.rb has_rdoc: http-form_data-1.0.1/.gitignore0000644000004100000410000000016612602556202016445 0ustar www-datawww-data/.bundle/ /.yardoc /Gemfile.lock /_yardoc/ /coverage/ /doc/ /pkg/ /spec/reports/ /tmp/ *.bundle *.so *.o *.a mkmf.log http-form_data-1.0.1/.yardopts0000644000004100000410000000005612602556202016321 0ustar www-datawww-data--markup-provider=redcarpet --markup=markdown http-form_data-1.0.1/http-form_data.gemspec0000644000004100000410000000202112602556202020723 0ustar www-datawww-data# coding: utf-8 lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "http/form_data/version" Gem::Specification.new do |spec| spec.name = "http-form_data" spec.version = HTTP::FormData::VERSION spec.homepage = "https://github.com/httprb/form_data.rb" spec.authors = ["Aleksey V Zapparov"] 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 > 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.require_paths = ["lib"] spec.add_development_dependency "bundler", "~> 1.7" end http-form_data-1.0.1/CHANGES.md0000644000004100000410000000054712602556202016052 0ustar www-datawww-data## 1.0.1 (2015-03-31) * Fix usage of URI module. ## 1.0.0 (2015-01-04) * Gem renamed to `http-form_data` as `FormData` is not top-level citizen anymore: `FormData -> HTTP::FormData`. ## 0.1.0 (2015-01-02) * Move repo under `httprb` organization on GitHub. * Add `nil` support to `FormData#ensure_hash`. ## 0.0.1 (2014-12-15) * First release ever! http-form_data-1.0.1/README.md0000644000004100000410000000500312602556202015727 0ustar www-datawww-data# FormData [![Gem Version](https://badge.fury.io/rb/http-form_data.png)](http://rubygems.org/gems/http-form_data) [![Build Status](https://secure.travis-ci.org/httprb/form_data.rb.png?branch=master)](http://travis-ci.org/httprb/form_data.rb) [![Code Climate](https://codeclimate.com/github/httprb/form_data.rb.png)](https://codeclimate.com/github/httprb/form_data.rb) [![Coverage Status](https://coveralls.io/repos/httprb/form_data.rb/badge.png?branch=master)](https://coveralls.io/r/httprb/form_data.rb) Utility-belt to build form data request bodies. ## Installation Add this line to your application's Gemfile: ```ruby gem 'http-form_data' ``` And then execute: $ bundle Or install it yourself as: $ gem install http-form_data ## Usage ``` ruby require "http/form_data" form = HTTP::FormData.create({ :username => "ixti", :avatar_file => HTTP::FormData::File.new("/home/ixti/avatar.png") }) # Assuming socket is an open socket to some HTTP server socket << "POST /some-url HTTP/1.1\r\n" socket << "Host: example.com\r\n" socket << "Content-Type: #{form.content_type}\r\n" socket << "Content-Length: #{form.content_length}\r\n" socket << "\r\n" socket << form.to_s ``` ## Supported Ruby Versions 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 If something doesn't work on one of these versions, it's a bug. This library may inadvertently work (or seem to work) on other Ruby versions, however support will only be provided for the versions listed above. If you would like this library to support another Ruby version or implementation, you may volunteer to be a maintainer. Being a maintainer entails making sure all tests run and pass on that implementation. When something breaks on your implementation, you will be responsible for providing patches in a timely fashion. If critical issues for a particular implementation exist at the time of a major release, support for that Ruby version may be dropped. ## Contributing 1. Fork it ( https://github.com/httprb/form_data.rb/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request ## Copyright Copyright (c) 2015 Aleksey V Zapparov. See [LICENSE.txt][license] for further details. [ci]: http://travis-ci.org/httprb/form_data.rb [license]: https://github.com/httprb/form_data.rb/blob/master/LICENSE.txt http-form_data-1.0.1/Guardfile0000644000004100000410000000053312602556202016300 0ustar www-datawww-dataguard :rspec, :cmd => "bundle exec rspec" do require "guard/rspec/dsl" dsl = Guard::RSpec::Dsl.new(self) # RSpec files rspec = dsl.rspec watch(rspec.spec_helper) { rspec.spec_dir } watch(rspec.spec_support) { rspec.spec_dir } watch(rspec.spec_files) # Ruby files ruby = dsl.ruby dsl.watch_spec_files_for(ruby.lib_files) end