store_agent 1.0.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 541cd57d63698ce014940dccfb89492af36d1ecc
4
- data.tar.gz: c2db5fb40adedf6cfb80fbc26b55e011ccee8527
3
+ metadata.gz: 33dfc49f58f274a2db1bbb0dec2f0e98f2addada
4
+ data.tar.gz: 3e16e6582e9f8292868c557f5b4349b13b596ff5
5
5
  SHA512:
6
- metadata.gz: 6849a47f777b73f0a8b77c36e82176b4227725f5df1f7511ada23330fd706a0cbe6aff07334e5664504d01968444925f2fdc1c9fe34701898a6e91e2daad4972
7
- data.tar.gz: b40d9481c17f04288f7229f121e7dc4e74b7b82657548ffe4f76ff28c2c68ffe9c44b6b4375524825e0656c76130d026752cb99c9f7c598c313e4fcc811738d4
6
+ metadata.gz: 786a325359383c3db29ca0f7ac1e19d254201dbd5d3c9858300a1322251e2a6437d787cf9c920309036baaada29260bb6999dc27143d58218eff442745272fd0
7
+ data.tar.gz: 5803a7cde0d6e12b7af4880b5c7ecf090d9706b854bb5ad4e0d15ab1e94c93103a4aa13e145e85b2a7f320b6cf1dc2f7043ed6146f8dba49bdd33d86df1ba3be
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0-p247
4
+ - 2.1.0
5
+ - 2.1.1
6
+ - 2.1.2
7
+ - 2.1.3
8
+ - 2.1.4
9
+ - 2.1.5
10
+ - 2.2.0
11
+ - 2.2.1
data/README.md CHANGED
@@ -18,6 +18,10 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install store_agent
20
20
 
21
+ ## Build Status
22
+
23
+ [![Build Status](https://travis-ci.org/realglobe-Inc/store_agent.svg?branch=master)](https://travis-ci.org/realglobe-Inc/store_agent)
24
+
21
25
  ## Usage
22
26
 
23
27
  基本的な使用方法は以下。
data/Rakefile CHANGED
@@ -1,2 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
2
3
 
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => [:spec]
@@ -142,9 +142,7 @@ module StoreAgent
142
142
  @default_owner_permission = {
143
143
  "read" => true,
144
144
  "write" => true,
145
- "execute" => true,
146
- "chown" => true,
147
- "chmod" => true
145
+ "execute" => true
148
146
  }
149
147
  @default_guest_permission = {}
150
148
  end
@@ -20,8 +20,6 @@ module StoreAgent
20
20
  class Metadata < Attachment
21
21
  def_delegators :data, *%w([] []=)
22
22
 
23
- # TODO check disk_usage before save
24
-
25
23
  def create
26
24
  super
27
25
  parent.update(disk_usage: disk_usage, directory_file_count: 1, tree_file_count: 1, recursive: true)
@@ -26,12 +26,6 @@ module StoreAgent
26
26
  StoreAgent::Node::PermissionChecker <<
27
27
  StoreAgent::Node::Locker
28
28
 
29
- # def self.inherited(child)
30
- # child.include StoreAgent::Node::Locker
31
- # child.include StoreAgent::Node::PermissionChecker
32
- # child.include StoreAgent::Node::PathValidator
33
- # end
34
-
35
29
  attr_reader :workspace, :path
36
30
  def_delegators :workspace, *%w(current_user)
37
31
 
@@ -35,7 +35,6 @@ module StoreAgent
35
35
  end
36
36
  end
37
37
 
38
- # TODO
39
38
  def read(revision: nil)
40
39
  super do
41
40
  filenames =
@@ -207,11 +206,6 @@ module StoreAgent
207
206
  metadata["tree_file_count"]
208
207
  end
209
208
 
210
- # TODO auth
211
- def update_limit=(limit)
212
- metadata["directory_bytes_limit"] = limit
213
- end
214
-
215
209
  def directory? # :nodoc:
216
210
  true
217
211
  end
@@ -78,9 +78,8 @@ module StoreAgent
78
78
  end
79
79
  end
80
80
 
81
- # TODO recursive_to_root, recursive_to_leaf
82
- # TODO lock_shared recursive_to_root
83
- # 親階層のファイルをロックしていないので、同時にファイル削除などが実行されると問題が発生する可能性がある
81
+ # TODO
82
+ # 親階層のファイルをロックする
84
83
  def set_permission(*)
85
84
  lock!(lock_mode: File::LOCK_EX, recursive: false) do
86
85
  super
@@ -88,6 +87,7 @@ module StoreAgent
88
87
  end
89
88
 
90
89
  # TODO
90
+ # 親階層のファイルをロックする
91
91
  def unset_permission(*)
92
92
  lock!(lock_mode: File::LOCK_EX, recursive: false) do
93
93
  super
@@ -15,5 +15,5 @@
15
15
  #++
16
16
 
17
17
  module StoreAgent
18
- VERSION = "1.0.0"
18
+ VERSION = "1.0.1"
19
19
  end
@@ -27,6 +27,8 @@ module StoreAgent
27
27
  def init
28
28
  super do
29
29
  Git.init
30
+ repository.config["user.name"] || repository.config("user.name", "test_user")
31
+ repository.config["user.email"] || repository.config("user.email", "test@example.com")
30
32
  end
31
33
  end
32
34
 
@@ -39,7 +41,11 @@ module StoreAgent
39
41
 
40
42
  def remove(*paths, **_)
41
43
  super do
42
- repository.remove(paths, recursive: true)
44
+ # TODO fix
45
+ paths_string = paths.map{|path| relative_path(path)}.join(" ")
46
+ repository.chdir do
47
+ `git rm --cached -f -r #{paths_string}`
48
+ end
43
49
  end
44
50
  end
45
51
 
@@ -27,6 +27,8 @@ module StoreAgent
27
27
  def init
28
28
  super do
29
29
  Rugged::Repository.init_at(".")
30
+ repository.config["user.name"] ||= "test_user"
31
+ repository.config["user.email"] ||= "test@example.com"
30
32
  end
31
33
  end
32
34
 
@@ -78,7 +78,7 @@ module StoreAgent
78
78
  # 全ワークスペース名の一覧を配列で返す
79
79
  def self.name_list
80
80
  if !File.exists?(StoreAgent.config.storage_root)
81
- FileUtils.mkdir(StoreAgent.config.storage_root)
81
+ FileUtils.mkdir_p(StoreAgent.config.storage_root)
82
82
  end
83
83
  FileUtils.cd(StoreAgent.config.storage_root) do
84
84
  return Dir.glob("*", File::FNM_DOTMATCH) - StoreAgent.reserved_filenames
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,10 @@ SimpleCov.start do
7
7
  end
8
8
 
9
9
  require "store_agent"
10
+ if !File.exists?(StoreAgent.config.storage_root)
11
+ FileUtils.mkdir_p(StoreAgent.config.storage_root)
12
+ end
13
+ $directory_bytesize = File.size(StoreAgent.config.storage_root)
10
14
 
11
15
  RSpec.configure do |config|
12
16
  config.expect_with :rspec do |expectations|
@@ -24,8 +28,6 @@ RSpec.configure do |config|
24
28
 
25
29
  config.profile_examples = 10
26
30
  config.order = :random
27
- # config.order = "16118"
28
- # config.fail_fast = true
29
31
 
30
32
  Kernel.srand config.seed
31
33
 
@@ -36,7 +38,6 @@ RSpec.configure do |config|
36
38
  "read" => true,
37
39
  "write" => true,
38
40
  "execute" => true,
39
- # "chown" => true,
40
41
  "chmod" => true
41
42
  }
42
43
  end
@@ -66,7 +66,7 @@ RSpec.describe StoreAgent::DataEncoder do
66
66
  dir = workspace.directory("bitesize_test").create
67
67
  file = workspace.file("bitesize_test/hoge.txt").create("12 byte file")
68
68
  expect(file.metadata["bytes"]).to eq 12
69
- expect(workspace.directory("bitesize_test").metadata.disk_usage).to eq 4108
69
+ expect(workspace.directory("bitesize_test").metadata.disk_usage).to eq ($directory_bytesize + 12)
70
70
  end
71
71
  it "パーミッション情報は gzip -c ... | openssl ... でエンコードされた形式で保存される" do
72
72
  file = workspace.file("foo/bar.txt")
@@ -99,30 +99,6 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
99
99
  workspace.directory(".keep").create
100
100
  expect(workspace.directory(".keep").exists?).to be true
101
101
  end
102
- it "引数にブロックを渡してdirectory_bytes_limitを初期化できる" do
103
- pending
104
-
105
- workspace.directory("limit").create do |d|
106
- d..metadata["directory_bytes_limit"] = 12345678
107
- end
108
- expect(workspace.directory("limit").metadata["directory_bytes_limit"]).to eq 12345678
109
- end
110
- it "引数にブロックを渡してオーナーを初期化できる" do
111
- skip "とりあえず保留"
112
-
113
- StoreAgent::Superuser.new.workspace(workspace_name).directory("chown").create do |d|
114
- d.initial_owner = "initial_owner"
115
- end
116
- expect(workspace.directory("chown").metadata["owner"]).to eq "initial_owner"
117
- end
118
- it "引数にブロックを渡して権限を初期化できる" do
119
- pending
120
-
121
- workspace.directory("chmod").create do |d|
122
- d.initial_permission = {"readwrite" => true}
123
- end
124
- expect(workspace.directory("chmod").permission).to eq ({"readwrite" => true})
125
- end
126
102
  end
127
103
 
128
104
  context "ディレクトリ削除のテスト" do
@@ -184,8 +160,8 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
184
160
  workspace.directory("/")
185
161
  end
186
162
 
187
- it "ディスク使用量は 4096 * 4 + 30 バイト" do
188
- expect(root_node.metadata.disk_usage).to eq ((4096 * 4) + 30)
163
+ it "ディスク使用量は #{$directory_bytesize} * 4 + 30 バイト" do
164
+ expect(root_node.metadata.disk_usage).to eq (($directory_bytesize * 4) + 30)
189
165
  end
190
166
  it "直下のファイル数は 1" do
191
167
  expect(root_node.directory_file_count).to eq 1
@@ -199,8 +175,8 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
199
175
  workspace.directory("/delete_test")
200
176
  end
201
177
 
202
- it "ディスク使用量は 4096 * 3 + 30 バイト" do
203
- expect(dir.metadata.disk_usage).to eq ((4096 * 3) + 30)
178
+ it "ディスク使用量は #{$directory_bytesize} * 3 + 30 バイト" do
179
+ expect(dir.metadata.disk_usage).to eq (($directory_bytesize * 3) + 30)
204
180
  end
205
181
  it "直下のファイル数は 2" do
206
182
  expect(dir.directory_file_count).to eq 2
@@ -214,8 +190,8 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
214
190
  workspace.directory("/delete_test/bar")
215
191
  end
216
192
 
217
- it "ディスク使用量は 4096 + 10 バイト" do
218
- expect(dir.metadata.disk_usage).to eq (4096 + 10)
193
+ it "ディスク使用量は #{$directory_bytesize} + 10 バイト" do
194
+ expect(dir.metadata.disk_usage).to eq ($directory_bytesize + 10)
219
195
  end
220
196
  it "直下のファイル数は 1" do
221
197
  expect(dir.directory_file_count).to eq 1
@@ -229,8 +205,8 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
229
205
  workspace.directory("/delete_test/foobar")
230
206
  end
231
207
 
232
- it "ディスク使用量は 4096 + 20 バイト" do
233
- expect(dir.metadata.disk_usage).to eq (4096 + 20)
208
+ it "ディスク使用量は #{$directory_bytesize} + 20 バイト" do
209
+ expect(dir.metadata.disk_usage).to eq ($directory_bytesize + 20)
234
210
  end
235
211
  it "直下のファイル数は 1" do
236
212
  expect(dir.directory_file_count).to eq 1
@@ -337,7 +313,7 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
337
313
  prev_bytesize = workspace.directory("copy").metadata["directory_bytes"]
338
314
  src_dir.copy(dest_directory_path)
339
315
  expect(workspace.directory(dest_directory_path).file("src/foo.txt").read).to eq "copy"
340
- expect(workspace.directory("copy").metadata["directory_bytes"]).to eq prev_bytesize + 4096 + 4
316
+ expect(workspace.directory("copy").metadata["directory_bytes"]).to eq prev_bytesize + $directory_bytesize + 4
341
317
  expect(workspace.directory("copy").tree_file_count).to eq prev_count + 2
342
318
  end
343
319
  it "コピー先のディレクトリ内に同名のファイルが存在する場合、例外が発生する" do
@@ -24,7 +24,7 @@ RSpec.describe StoreAgent::Node::Locker do
24
24
  user.workspace("test_lock")
25
25
  end
26
26
  before do
27
- skip "時間かかるのでスキップ"
27
+ # skip "時間かかるのでスキップ"
28
28
  end
29
29
  before :all do
30
30
  workspace = StoreAgent::User.new("foo").workspace("test_lock")
@@ -42,8 +42,8 @@ RSpec.describe StoreAgent::Node::Metadata do
42
42
  it "JSON形式で保存される" do
43
43
  expect(open(@root_node.metadata.file_path).read).to eq @root_node.metadata.inspect
44
44
  end
45
- it "ルートディレクトリの使用容量は 4096 バイト" do
46
- expect(@root_node.metadata.disk_usage).to eq 4096
45
+ it "ルートディレクトリの使用容量は #{$directory_bytesize} バイト" do
46
+ expect(@root_node.metadata.disk_usage).to eq $directory_bytesize
47
47
  end
48
48
  end
49
49
 
@@ -72,8 +72,8 @@ RSpec.describe StoreAgent::Node::Metadata do
72
72
  end
73
73
 
74
74
  context "ルートディレクトリ" do
75
- it "ディスク使用量は (4096 * 3) バイト" do
76
- expect(@root_node.metadata.disk_usage).to eq (4096 * 3)
75
+ it "ディスク使用量は (#{$directory_bytesize} * 3) バイト" do
76
+ expect(@root_node.metadata.disk_usage).to eq ($directory_bytesize * 3)
77
77
  end
78
78
  it "直下のファイル数は 1" do
79
79
  expect(@root_node.directory_file_count).to eq 1
@@ -83,8 +83,8 @@ RSpec.describe StoreAgent::Node::Metadata do
83
83
  end
84
84
  end
85
85
  context "中間ディレクトリ" do
86
- it "ディスク使用量は (4096 * 2) バイト" do
87
- expect(@dir_1.metadata.disk_usage).to eq (4096 * 2)
86
+ it "ディスク使用量は (#{$directory_bytesize} * 2) バイト" do
87
+ expect(@dir_1.metadata.disk_usage).to eq ($directory_bytesize * 2)
88
88
  end
89
89
  it "直下のファイル数は 1" do
90
90
  expect(@dir_1.directory_file_count).to eq 1
@@ -94,8 +94,8 @@ RSpec.describe StoreAgent::Node::Metadata do
94
94
  end
95
95
  end
96
96
  context "最下層のディレクトリ" do
97
- it "ディスク使用量は 4096 バイト" do
98
- expect(@dir_2.metadata.disk_usage).to eq 4096
97
+ it "ディスク使用量は #{$directory_bytesize} バイト" do
98
+ expect(@dir_2.metadata.disk_usage).to eq $directory_bytesize
99
99
  end
100
100
  it "直下のファイル数は 0" do
101
101
  expect(@dir_2.directory_file_count).to eq 0
@@ -122,8 +122,8 @@ RSpec.describe StoreAgent::Node::Metadata do
122
122
  end
123
123
 
124
124
  context "ルートディレクトリ" do
125
- it "ディスク使用量は (4096 * 2) + 10 バイト" do
126
- expect(@root_node.metadata.disk_usage).to eq ((4096 * 2) + 10)
125
+ it "ディスク使用量は (#{$directory_bytesize} * 2) + 10 バイト" do
126
+ expect(@root_node.metadata.disk_usage).to eq (($directory_bytesize * 2) + 10)
127
127
  end
128
128
  it "直下のファイル数は 1" do
129
129
  expect(@root_node.directory_file_count).to eq 1
@@ -133,8 +133,8 @@ RSpec.describe StoreAgent::Node::Metadata do
133
133
  end
134
134
  end
135
135
  context "ディレクトリ" do
136
- it "ディスク使用量は 4096 + 10 バイト" do
137
- expect(@dir.metadata.disk_usage).to eq (4096 + 10)
136
+ it "ディスク使用量は #{$directory_bytesize} + 10 バイト" do
137
+ expect(@dir.metadata.disk_usage).to eq ($directory_bytesize + 10)
138
138
  end
139
139
  it "直下のファイル数は 1" do
140
140
  expect(@dir.directory_file_count).to eq 1
@@ -175,8 +175,8 @@ RSpec.describe StoreAgent::Node::Metadata do
175
175
  end
176
176
 
177
177
  context "ルートディレクトリ" do
178
- it "ディスク使用量は (4096 * 2) + 7 バイト" do
179
- expect(@root_node.metadata.disk_usage).to eq ((4096 * 2) + 7)
178
+ it "ディスク使用量は (#{$directory_bytesize} * 2) + 7 バイト" do
179
+ expect(@root_node.metadata.disk_usage).to eq (($directory_bytesize * 2) + 7)
180
180
  end
181
181
  it "直下のファイル数は 1" do
182
182
  expect(@root_node.directory_file_count).to eq 1
@@ -186,8 +186,8 @@ RSpec.describe StoreAgent::Node::Metadata do
186
186
  end
187
187
  end
188
188
  context "ディレクトリ" do
189
- it "ディスク使用量は 4096 + 7 バイト" do
190
- expect(@dir.metadata.disk_usage).to eq (4096 + 7)
189
+ it "ディスク使用量は #{$directory_bytesize} + 7 バイト" do
190
+ expect(@dir.metadata.disk_usage).to eq ($directory_bytesize + 7)
191
191
  end
192
192
  it "直下のファイル数は 1" do
193
193
  expect(@dir.directory_file_count).to eq 1
@@ -228,8 +228,8 @@ RSpec.describe StoreAgent::Node::Metadata do
228
228
  end
229
229
 
230
230
  context "ルートディレクトリ" do
231
- it "ディスク使用量は (4096 * 2) + 10 バイト" do
232
- expect(@root_node.metadata.disk_usage).to eq ((4096 * 2) + 10)
231
+ it "ディスク使用量は (#{$directory_bytesize} * 2) + 10 バイト" do
232
+ expect(@root_node.metadata.disk_usage).to eq (($directory_bytesize * 2) + 10)
233
233
  end
234
234
  it "直下のファイル数は 1" do
235
235
  expect(@root_node.directory_file_count).to eq 1
@@ -239,8 +239,8 @@ RSpec.describe StoreAgent::Node::Metadata do
239
239
  end
240
240
  end
241
241
  context "ディレクトリ" do
242
- it "ディスク使用量は 4096 + 10 バイト" do
243
- expect(@dir.metadata.disk_usage).to eq (4096 + 10)
242
+ it "ディスク使用量は #{$directory_bytesize} + 10 バイト" do
243
+ expect(@dir.metadata.disk_usage).to eq ($directory_bytesize + 10)
244
244
  end
245
245
  it "直下のファイル数は 1" do
246
246
  expect(@dir.directory_file_count).to eq 1
@@ -252,7 +252,7 @@ RSpec.describe StoreAgent::Node::Metadata do
252
252
  file = owner.workspace(workspace_name).file("foo/foobarhoge.txt").create("body" => "0987654321")
253
253
  file.body = ""
254
254
  file.delete
255
- expect(@dir.metadata.disk_usage).to eq (4096 + 10)
255
+ expect(@dir.metadata.disk_usage).to eq ($directory_bytesize + 10)
256
256
  end
257
257
  end
258
258
  end
@@ -273,8 +273,8 @@ RSpec.describe StoreAgent::Node::Metadata do
273
273
  end
274
274
 
275
275
  context "ルートディレクトリ" do
276
- it "ディスク使用量は 4096 * 2 バイト" do
277
- expect(@root_node.metadata.disk_usage).to eq (4096 * 2)
276
+ it "ディスク使用量は #{$directory_bytesize} * 2 バイト" do
277
+ expect(@root_node.metadata.disk_usage).to eq ($directory_bytesize * 2)
278
278
  end
279
279
  it "直下のファイル数は 1" do
280
280
  expect(@root_node.directory_file_count).to eq 1
@@ -284,8 +284,8 @@ RSpec.describe StoreAgent::Node::Metadata do
284
284
  end
285
285
  end
286
286
  context "ディレクトリ" do
287
- it "ディスク使用量は 4096 バイト" do
288
- expect(@dir.metadata.disk_usage).to eq 4096
287
+ it "ディスク使用量は #{$directory_bytesize} バイト" do
288
+ expect(@dir.metadata.disk_usage).to eq $directory_bytesize
289
289
  end
290
290
  it "直下のファイル数は 0" do
291
291
  expect(@dir.directory_file_count).to eq 0
@@ -314,8 +314,8 @@ RSpec.describe StoreAgent::Node::Metadata do
314
314
  end
315
315
 
316
316
  context "ルートディレクトリ" do
317
- it "ディスク使用量は 4096 * 2 バイト" do
318
- expect(@root_node.metadata.disk_usage).to eq (4096 * 2)
317
+ it "ディスク使用量は #{$directory_bytesize} * 2 バイト" do
318
+ expect(@root_node.metadata.disk_usage).to eq ($directory_bytesize * 2)
319
319
  end
320
320
  it "直下のファイル数は 1" do
321
321
  expect(@root_node.directory_file_count).to eq 1
@@ -325,8 +325,8 @@ RSpec.describe StoreAgent::Node::Metadata do
325
325
  end
326
326
  end
327
327
  context "ディレクトリ" do
328
- it "ディスク使用量は 4096 バイト" do
329
- expect(@dir.metadata.disk_usage).to eq 4096
328
+ it "ディスク使用量は #{$directory_bytesize} バイト" do
329
+ expect(@dir.metadata.disk_usage).to eq $directory_bytesize
330
330
  end
331
331
  it "直下のファイル数は 0" do
332
332
  expect(@dir.directory_file_count).to eq 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: store_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - realglobe-Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -159,6 +159,7 @@ extra_rdoc_files: []
159
159
  files:
160
160
  - ".gitignore"
161
161
  - ".rspec"
162
+ - ".travis.yml"
162
163
  - Gemfile
163
164
  - Guardfile
164
165
  - LICENSE