nightcrawler_swift 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39b53e60af55f2b7f29c0891ca82e3d17e74bb6f
4
- data.tar.gz: 8fe4bcad69946d7680fc258531f78bc0729e6361
3
+ metadata.gz: 3c74bc730b90e84843c501e3664ffbb6c3b13180
4
+ data.tar.gz: 61e84ddcbd1712fb2872fc22814ba0a1cfac1a5b
5
5
  SHA512:
6
- metadata.gz: 33155ed2db0f194cb4012aced580b1f92a1862d4dae8763e527632a26f766a11aec2b7e5574837d2731a956cab5564a5bb9efcc639bc2575a12a3f2330f2f912
7
- data.tar.gz: fd48e8c2d22ec5152fb28ef88b71a67cd6bdb32090480fd9e6188a9ecbf369fca76f36cf05680b994be918a0e151810159721fe2e42e3b069f709a962e5a7056
6
+ metadata.gz: 9958eba6dab0468609f26b417c9bd94aa303c4c5cdeb52adc0333d3b5fd69ffa9188c557a52cabc313fbda355f4d0285a2068d2fcf9accd5b8347d8cf6ab396d
7
+ data.tar.gz: 73d01d3e16053bfb68d701eccd72f72b50e2126b99b7289e8c2baf04f00f73240505a34cc110ee4f715c73a0d3b7fdb4e8ed285d0bde38980f18f080e1256201
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nightcrawler_swift (0.2.1)
4
+ nightcrawler_swift (0.2.2)
5
+ multi_mime (>= 1.0.1)
5
6
  rest-client (>= 1.7.0)
6
7
 
7
8
  GEM
@@ -14,6 +15,7 @@ GEM
14
15
  debugger-linecache (1.2.0)
15
16
  diff-lcs (1.2.5)
16
17
  mime-types (2.3)
18
+ multi_mime (1.0.1)
17
19
  netrc (0.7.7)
18
20
  rake (10.3.2)
19
21
  rest-client (1.7.2)
@@ -1,6 +1,7 @@
1
1
  require "date"
2
2
  require "logger"
3
3
  require "ostruct"
4
+ require "multi_mime"
4
5
  require "rest_client"
5
6
  require "nightcrawler_swift/version"
6
7
  require "nightcrawler_swift/exceptions"
@@ -2,7 +2,8 @@ module NightcrawlerSwift
2
2
  class Upload < Command
3
3
 
4
4
  def execute path, file
5
- response = put "#{connection.upload_url}/#{path}", body: file.read
5
+ content_type = MultiMime.by_file(file).content_type
6
+ response = put "#{connection.upload_url}/#{path}", body: file.read, headers: {content_type: content_type}
6
7
  [200, 201].include?(response.code)
7
8
  end
8
9
 
@@ -1,3 +1,3 @@
1
1
  module NightcrawlerSwift
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "rest-client", ">= 1.7.0"
22
+ spec.add_dependency "multi_mime", ">= 1.0.1"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.6"
24
25
  spec.add_development_dependency "rake"
@@ -0,0 +1 @@
1
+ a { color: red; }
@@ -0,0 +1 @@
1
+ function() {};
@@ -20,13 +20,17 @@ describe NightcrawlerSwift::Sync do
20
20
  dir = File.expand_path(File.join(File.dirname(__FILE__), "../../fixtures/assets"))
21
21
 
22
22
  subject.instance_variable_set(:@upload, upload)
23
+ expect(File).to receive(:open).with(File.join(dir, "css1.css"), "r").and_call_original
23
24
  expect(File).to receive(:open).with(File.join(dir, "ex1.txt"), "r").and_call_original
24
25
  expect(File).to receive(:open).with(File.join(dir, "ex2.txt"), "r").and_call_original
25
26
  expect(File).to receive(:open).with(File.join(dir, "ex3/ex4.txt"), "r").and_call_original
27
+ expect(File).to receive(:open).with(File.join(dir, "js1.js"), "r").and_call_original
26
28
 
29
+ expect(upload).to receive(:execute).with("css1.css", instance_of(File))
27
30
  expect(upload).to receive(:execute).with("ex1.txt", instance_of(File))
28
31
  expect(upload).to receive(:execute).with("ex2.txt", instance_of(File))
29
32
  expect(upload).to receive(:execute).with("ex3/ex4.txt", instance_of(File))
33
+ expect(upload).to receive(:execute).with("js1.js", instance_of(File))
30
34
 
31
35
  subject.execute dir
32
36
  end
@@ -8,7 +8,10 @@ describe NightcrawlerSwift::Upload do
8
8
 
9
9
  describe "#execute" do
10
10
  let(:path) { "file_name" }
11
- let(:file) { double(:file, read: "content") }
11
+ let(:file) do
12
+ dir = File.expand_path(File.join(File.dirname(__FILE__), "../../fixtures/assets"))
13
+ File.open(File.join(dir, "css1.css"))
14
+ end
12
15
 
13
16
  let :connection do
14
17
  double :connection, upload_url: "server-url"
@@ -21,6 +24,7 @@ describe NightcrawlerSwift::Upload do
21
24
  before do
22
25
  allow(NightcrawlerSwift).to receive(:connection).and_return(connection)
23
26
  allow(subject).to receive(:put).and_return(response)
27
+ allow(file).to receive(:read).and_return("content")
24
28
  end
25
29
 
26
30
  let :execute do
@@ -34,7 +38,12 @@ describe NightcrawlerSwift::Upload do
34
38
 
35
39
  it "sends file content as body" do
36
40
  execute
37
- expect(subject).to have_received(:put).with(anything, body: "content")
41
+ expect(subject).to have_received(:put).with(anything, hash_including(body: "content"))
42
+ end
43
+
44
+ it "sends file content_type as header" do
45
+ execute
46
+ expect(subject).to have_received(:put).with(anything, hash_including(headers: { content_type: "text/css"}))
38
47
  end
39
48
 
40
49
  it "sends to upload url with given path" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nightcrawler_swift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tulios
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: 1.7.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: multi_mime
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.1
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 1.0.1
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: bundler
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -112,9 +126,11 @@ files:
112
126
  - lib/nightcrawler_swift/upload.rb
113
127
  - lib/nightcrawler_swift/version.rb
114
128
  - nightcrawler_swift.gemspec
129
+ - spec/fixtures/assets/css1.css
115
130
  - spec/fixtures/assets/ex1.txt
116
131
  - spec/fixtures/assets/ex2.txt
117
132
  - spec/fixtures/assets/ex3/ex4.txt
133
+ - spec/fixtures/assets/js1.js
118
134
  - spec/fixtures/auth_success.json
119
135
  - spec/lib/nightcrawler_swift/command_spec.rb
120
136
  - spec/lib/nightcrawler_swift/connection_spec.rb
@@ -151,9 +167,11 @@ specification_version: 4
151
167
  summary: Like the X-Men nightcrawler this gem teleports your assets to a OpenStack
152
168
  Swift bucket/container
153
169
  test_files:
170
+ - spec/fixtures/assets/css1.css
154
171
  - spec/fixtures/assets/ex1.txt
155
172
  - spec/fixtures/assets/ex2.txt
156
173
  - spec/fixtures/assets/ex3/ex4.txt
174
+ - spec/fixtures/assets/js1.js
157
175
  - spec/fixtures/auth_success.json
158
176
  - spec/lib/nightcrawler_swift/command_spec.rb
159
177
  - spec/lib/nightcrawler_swift/connection_spec.rb