cabinet 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/Gemfile.lock +4 -2
- data/cabinet.gemspec +1 -0
- data/lib/cabinet/cloud.rb +15 -2
- data/lib/cabinet/local.rb +8 -0
- data/lib/cabinet/version.rb +1 -1
- data/spec/cabinet/cloud_spec.rb +10 -0
- data/spec/cabinet/local_spec.rb +10 -0
- data/spec/spec_helper.rb +2 -1
- metadata +19 -4
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cabinet (0.
|
4
|
+
cabinet (0.1.1)
|
5
5
|
fog (~> 0.3.30)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
builder (3.0.0)
|
11
11
|
diff-lcs (1.1.2)
|
12
|
-
excon (0.3.
|
12
|
+
excon (0.3.7)
|
13
13
|
fog (0.3.34)
|
14
14
|
builder
|
15
15
|
excon (>= 0.3.6)
|
@@ -19,6 +19,7 @@ GEM
|
|
19
19
|
net-ssh (>= 2.0.23)
|
20
20
|
nokogiri (>= 1.4.4)
|
21
21
|
ruby-hmac
|
22
|
+
forgery (0.3.6)
|
22
23
|
formatador (0.0.16)
|
23
24
|
json (1.4.6)
|
24
25
|
mime-types (1.16)
|
@@ -40,4 +41,5 @@ PLATFORMS
|
|
40
41
|
DEPENDENCIES
|
41
42
|
cabinet!
|
42
43
|
fog (~> 0.3.30)
|
44
|
+
forgery
|
43
45
|
rspec (~> 2.3.0)
|
data/cabinet.gemspec
CHANGED
data/lib/cabinet/cloud.rb
CHANGED
@@ -27,6 +27,11 @@ module Cabinet
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
def append(name, new_content)
|
31
|
+
content = exists?(name) ? get(name) + new_content : new_content
|
32
|
+
put(name, content) and !!reload(name)
|
33
|
+
end
|
34
|
+
|
30
35
|
def delete(name_or_regexp)
|
31
36
|
@file = nil
|
32
37
|
|
@@ -60,6 +65,10 @@ module Cabinet
|
|
60
65
|
!!file(name)
|
61
66
|
end
|
62
67
|
|
68
|
+
def modified(name)
|
69
|
+
file(name).last_modified + 0
|
70
|
+
end
|
71
|
+
|
63
72
|
def gzip(name, content)
|
64
73
|
name = name.gsub(/(.+?)(\.gz)?$/, '\1.gz')
|
65
74
|
local = "/tmp/#{name}"
|
@@ -78,9 +87,13 @@ module Cabinet
|
|
78
87
|
if @file && @file.key == name
|
79
88
|
@file
|
80
89
|
else
|
81
|
-
|
82
|
-
@file = container.files.get(name)
|
90
|
+
reload(name)
|
83
91
|
end
|
84
92
|
end
|
93
|
+
|
94
|
+
def reload(name)
|
95
|
+
container.files.reload
|
96
|
+
@file = container.files.get(name)
|
97
|
+
end
|
85
98
|
end
|
86
99
|
end
|
data/lib/cabinet/local.rb
CHANGED
@@ -15,6 +15,10 @@ module Cabinet
|
|
15
15
|
File.open(dir + file, 'wb') {|f| f.write(content)} == content.length
|
16
16
|
end
|
17
17
|
|
18
|
+
def append(file, content)
|
19
|
+
File.open(dir + file, 'ab') {|f| f.write(content)} == content.length
|
20
|
+
end
|
21
|
+
|
18
22
|
def delete(file_or_regexp)
|
19
23
|
File.delete *Dir.glob(dir + file_or_regexp)
|
20
24
|
end
|
@@ -23,6 +27,10 @@ module Cabinet
|
|
23
27
|
File.exists?(dir + file)
|
24
28
|
end
|
25
29
|
|
30
|
+
def modified(file)
|
31
|
+
File.mtime(dir + file)
|
32
|
+
end
|
33
|
+
|
26
34
|
def gzip(file, content)
|
27
35
|
File.open(dir + file, 'w') do |f|
|
28
36
|
gz = Zlib::GzipWriter.new(f)
|
data/lib/cabinet/version.rb
CHANGED
data/spec/cabinet/cloud_spec.rb
CHANGED
@@ -22,6 +22,16 @@ describe Cabinet::Cloud do
|
|
22
22
|
@cc.get(@@file_name).should == @@file_content
|
23
23
|
end
|
24
24
|
|
25
|
+
it "should get last modified" do
|
26
|
+
@cc.modified(@@file_name).class.should == Time
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should append file" do
|
30
|
+
extra_content = Forgery(:lorem_ipsum).text(:paragraph)
|
31
|
+
@cc.append(@@file_name, extra_content).should == true
|
32
|
+
@cc.get(@@file_name).should == @@file_content + extra_content
|
33
|
+
end
|
34
|
+
|
25
35
|
it "should list files" do
|
26
36
|
@cc.list.should include(@@file_name)
|
27
37
|
@cc.list(/#{@@file_name}/).should include(@@file_name)
|
data/spec/cabinet/local_spec.rb
CHANGED
@@ -21,6 +21,16 @@ describe Cabinet::Local do
|
|
21
21
|
@cl.get(@@file_name).should == @@file_content
|
22
22
|
end
|
23
23
|
|
24
|
+
it "should see last modified" do
|
25
|
+
@cl.modified(@@file_name).class.should == Time
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should append file" do
|
29
|
+
extra_content = Forgery(:lorem_ipsum).text(:paragraph)
|
30
|
+
@cl.append(@@file_name, extra_content).should == true
|
31
|
+
@cl.get(@@file_name).should == @@file_content + extra_content
|
32
|
+
end
|
33
|
+
|
24
34
|
it "should list files"
|
25
35
|
|
26
36
|
it "should not overwrite file"
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'cabinet')
|
2
|
+
require 'forgery'
|
2
3
|
|
3
4
|
RSpec.configure do |config|
|
4
5
|
config.before(:suite) do
|
5
6
|
@@file_name = 'cabinet.test'
|
6
|
-
@@file_content = (
|
7
|
+
@@file_content = Forgery(:lorem_ipsum).text(:paragraphs, 10)
|
7
8
|
end
|
8
9
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cabinet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sebastian von Conrad
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-13 00:00:00 +10:30
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,20 @@ dependencies:
|
|
50
50
|
version: 2.3.0
|
51
51
|
type: :development
|
52
52
|
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: forgery
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
53
67
|
description: ""
|
54
68
|
email:
|
55
69
|
- sebastian@vonconrad.com
|
@@ -61,6 +75,7 @@ extra_rdoc_files: []
|
|
61
75
|
|
62
76
|
files:
|
63
77
|
- .gitignore
|
78
|
+
- .rspec
|
64
79
|
- Gemfile
|
65
80
|
- Gemfile.lock
|
66
81
|
- LICENSE
|