nightcrawler_swift 0.2.0 → 0.2.1
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/nightcrawler_swift.rb +1 -0
- data/lib/nightcrawler_swift/version.rb +1 -1
- data/spec/lib/nightcrawler_swift_spec.rb +71 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39b53e60af55f2b7f29c0891ca82e3d17e74bb6f
|
4
|
+
data.tar.gz: 8fe4bcad69946d7680fc258531f78bc0729e6361
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33155ed2db0f194cb4012aced580b1f92a1862d4dae8763e527632a26f766a11aec2b7e5574837d2731a956cab5564a5bb9efcc639bc2575a12a3f2330f2f912
|
7
|
+
data.tar.gz: fd48e8c2d22ec5152fb28ef88b71a67cd6bdb32090480fd9e6188a9ecbf369fca76f36cf05680b994be918a0e151810159721fe2e42e3b069f709a962e5a7056
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://codeclimate.com/github/tulios/nightcrawler_swift)
|
2
|
+
|
1
3
|
# Nightcrawler Swift
|
2
4
|
|
3
5
|
Like the X-Men nightcrawler this gem teleports your assets to a OpenStack Swift bucket/container. It was designed to sync your assets with OpenStack Swift and allow some operations with your buckets/containers.
|
@@ -34,7 +36,7 @@ config.nightcrawler_swift.auth_url = "https://auth.url.com:123/v2.0/tokens"
|
|
34
36
|
By default it will use ```Rails.logger``` as logger, to change that use a different logger in configurations, like:
|
35
37
|
|
36
38
|
```ruby
|
37
|
-
config.nightcrawler_swift.logger = Logger.new(
|
39
|
+
config.nightcrawler_swift.logger = Logger.new(STDOUT)
|
38
40
|
```
|
39
41
|
|
40
42
|
#### 2) Profit!
|
data/lib/nightcrawler_swift.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe NightcrawlerSwift do
|
4
|
+
|
5
|
+
subject do
|
6
|
+
NightcrawlerSwift
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "::logger" do
|
10
|
+
before do
|
11
|
+
subject.logger = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns an instance of Logger when not configured" do
|
15
|
+
expect(Logger).to receive(:new).with(STDOUT)
|
16
|
+
subject.logger
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns the configured logger" do
|
20
|
+
logger = Logger.new(StringIO.new)
|
21
|
+
subject.logger = logger
|
22
|
+
expect(subject.logger).to eql(logger)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "::configure" do
|
27
|
+
it "creates a new connection with the given opts" do
|
28
|
+
opts = {bucket: "rogue"}
|
29
|
+
expect(NightcrawlerSwift::Connection).to receive(:new).with(opts).and_call_original
|
30
|
+
subject.configure opts
|
31
|
+
expect(subject.connection).to_not be_nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "::connection" do
|
36
|
+
it "returns the configured connection" do
|
37
|
+
connection = NightcrawlerSwift::Connection.new
|
38
|
+
expect(NightcrawlerSwift::Connection).to receive(:new).with(anything).and_return(connection)
|
39
|
+
NightcrawlerSwift.configure
|
40
|
+
expect(NightcrawlerSwift.connection).to eql(connection)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "::sync" do
|
45
|
+
let :dir_path do
|
46
|
+
"path"
|
47
|
+
end
|
48
|
+
|
49
|
+
let :sync_instance do
|
50
|
+
double("Sync", execute: true)
|
51
|
+
end
|
52
|
+
|
53
|
+
before do
|
54
|
+
NightcrawlerSwift.configure
|
55
|
+
end
|
56
|
+
|
57
|
+
it "connects" do
|
58
|
+
allow(NightcrawlerSwift::Sync).to receive(:new).and_return(sync_instance)
|
59
|
+
expect(NightcrawlerSwift.connection).to receive(:connect!)
|
60
|
+
NightcrawlerSwift.sync dir_path
|
61
|
+
end
|
62
|
+
|
63
|
+
it "uses Sync command with the given dir_path" do
|
64
|
+
expect(NightcrawlerSwift.connection).to receive(:connect!)
|
65
|
+
expect(NightcrawlerSwift::Sync).to receive(:new).and_return(sync_instance)
|
66
|
+
expect(sync_instance).to receive(:execute).with(dir_path)
|
67
|
+
NightcrawlerSwift.sync dir_path
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|