ethon 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -10,9 +10,9 @@ rvm:
10
10
  - jruby-head
11
11
  - jruby-18mode
12
12
  - jruby-19mode
13
- - rbx-18mode
14
- - rbx-19mode
15
13
  matrix:
16
14
  allow_failures:
17
15
  - rvm: ruby-head
18
16
  - rvm: jruby-head
17
+ - rvm: rbx-18mode
18
+ - rvm: rbx-19mode
data/CHANGELOG.md CHANGED
@@ -2,14 +2,24 @@
2
2
 
3
3
  ## Master
4
4
 
5
- [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.6.2...master)
5
+ Not backwards compatible changes:
6
+
7
+ * `mime-types` are no longer a dependency. The gem will be still used if available to determine the mime type of a file which is uploaded. That means you have to have take care of the gem installation yourself.
8
+
9
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.7.0...master)
10
+
11
+ ## 0.7.0
12
+
13
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.6.3...v0.7.0)
14
+
15
+ ## 0.6.3
16
+
17
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.6.2...v0.6.3)
6
18
 
7
19
  ## 0.6.2
8
20
 
9
21
  [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.6.1...v0.6.2)
10
22
 
11
- The changelog entries are coming soon!
12
-
13
23
  ## 0.6.1
14
24
 
15
25
  [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.6.0...v0.6.1)
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ group :development, :test do
8
8
 
9
9
  gem "sinatra", :git => "https://github.com/sinatra/sinatra.git"
10
10
  gem "json"
11
+ gem "mime-types", "~> 1.18"
11
12
 
12
13
  unless ENV["CI"]
13
14
  gem "guard-rspec", "~> 0.7"
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Hans Hasselberg
1
+ Copyright (c) 2012-2014 Hans Hasselberg
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -71,7 +71,7 @@ everything up correctly.
71
71
 
72
72
  (The MIT License)
73
73
 
74
- Copyright © 2012-2013 [Hans Hasselberg](http://www.hans.io)
74
+ Copyright © 2012-2014 [Hans Hasselberg](http://www.hans.io)
75
75
 
76
76
  Permission is hereby granted, free of charge, to any person obtaining a
77
77
  copy of this software and associated documentation files (the "Software"),
data/ethon.gemspec CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.license = 'MIT'
19
19
 
20
20
  s.add_dependency('ffi', ['>= 1.3.0'])
21
- s.add_dependency('mime-types', ['~> 1.18'])
22
21
 
23
22
  s.files = `git ls-files`.split("\n")
24
23
  s.test_files = `git ls-files -- spec/*`.split("\n")
data/lib/ethon.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  require 'logger'
2
2
  require 'ffi'
3
3
  require 'thread'
4
- require 'mime/types'
4
+ begin
5
+ require 'mime/types'
6
+ rescue LoadError
7
+ end
5
8
  require 'tempfile'
6
9
 
7
10
  require 'ethon/libc'
@@ -75,16 +75,23 @@ module Ethon
75
75
  # @return [ Array ] Array of informations.
76
76
  def file_info(file)
77
77
  filename = File.basename(file.path)
78
- types = MIME::Types.type_for(filename)
79
78
  [
80
79
  filename,
81
- types.empty? ? 'application/octet-stream' : types[0].to_s,
80
+ mime_type(filename),
82
81
  File.expand_path(file.path)
83
82
  ]
84
83
  end
85
84
 
86
85
  private
87
86
 
87
+ def mime_type(filename)
88
+ if defined?(MIME) && t = MIME::Types.type_for(filename).first
89
+ t.to_s
90
+ else
91
+ 'application/octet-stream'
92
+ end
93
+ end
94
+
88
95
  def recursively_generate_pairs(h, prefix, pairs)
89
96
  case h
90
97
  when Hash
data/lib/ethon/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Ethon
2
2
 
3
3
  # Ethon version.
4
- VERSION = '0.6.3'
4
+ VERSION = '0.7.0'
5
5
  end
@@ -131,13 +131,37 @@ describe Ethon::Easy::Queryable do
131
131
  end
132
132
 
133
133
  context "when file" do
134
- let(:file) { Tempfile.new("fubar") }
134
+ let(:file) { File.open("spec/spec_helper.rb") }
135
135
  let(:file_info) { params.method(:file_info).call(file) }
136
136
  let(:hash) { {:a => {:b => [file]}} }
137
+ let(:mime_type) { file_info[1] }
137
138
 
138
139
  it "transforms" do
139
140
  expect(pairs).to eq([["a[b][0]", file_info]])
140
141
  end
142
+
143
+ context "when MIME" do
144
+ context "when mime type" do
145
+ it "sets mime type to text" do
146
+ expect(mime_type).to eq("application/x-ruby")
147
+ end
148
+ end
149
+
150
+ context "when no mime type" do
151
+ let(:file) { Tempfile.new("fubar") }
152
+
153
+ it "sets mime type to default application/octet-stream" do
154
+ Object.send(:remove_const, :MIME)
155
+ expect(mime_type).to eq("application/octet-stream")
156
+ end
157
+ end
158
+ end
159
+
160
+ context "when no MIME" do
161
+ it "sets mime type to default application/octet-stream" do
162
+ expect(mime_type).to eq("application/octet-stream")
163
+ end
164
+ end
141
165
  end
142
166
  end
143
167
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-13 00:00:00.000000000 Z
12
+ date: 2014-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.3.0
30
- - !ruby/object:Gem::Dependency
31
- name: mime-types
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '1.18'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '1.18'
46
30
  description: Very lightweight libcurl wrapper.
47
31
  email:
48
32
  - me@hans.io
@@ -165,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
149
  version: '0'
166
150
  segments:
167
151
  - 0
168
- hash: -3291920420856765924
152
+ hash: -1989061620893792868
169
153
  required_rubygems_version: !ruby/object:Gem::Requirement
170
154
  none: false
171
155
  requirements: