social_snippet-supports-mongoid 0.0.1 → 0.0.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,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Nzg1OTYwYmMzNDU5NmI3ZjdlNmU0ZmJhNmRiMGRmOWI2YzJhNGQ0YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODg3NzQ5ZjU3YzdmMmZiMzc0ODdhZDE1ODg2MmU5MGM5ODMxN2FhMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmUwNWIxMDJhZWFlOWUxMjU2ZjNkZGRhY2ViYTk0YTk1YTlkYzI3NjQ4OGE5
|
10
|
+
YWVhZDE1NGViNzE5MDI2ZGEzYWQ0MjE3OGUwOWUxY2Y4MTk2YWE0NGFjODZi
|
11
|
+
MjhjN2VlNjJhYzVlMDI2YWM4NzI5NjM3ZmUyMzk3OTUzMjRiZjk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzFjNDJlYWNiZmFlMGQ3YjkwNTg2NTcyODc1ZGU0N2MyOGEwNDVmNTgxZTg4
|
14
|
+
YzY3MzA1NjIxZjg5NDk1ZGMxZjM2MGYzOGNiOTNmNTZiNTVhMTZlZGIyYWE1
|
15
|
+
YjE5MWQzMmVlNWM5NjU0MTAwMWM3Y2M1ODNlM2YxNmMxMjQ5MWQ=
|
@@ -7,10 +7,12 @@ module SocialSnippet::StorageBackend
|
|
7
7
|
|
8
8
|
attr_reader :paths
|
9
9
|
attr_reader :workdir
|
10
|
+
attr_reader :model
|
10
11
|
|
11
12
|
def initialize
|
12
13
|
@workdir = "/"
|
13
|
-
@
|
14
|
+
@model = Model.find_or_create_by(:id => "social_snippet_storage")
|
15
|
+
@paths = ::SortedSet.new model.paths
|
14
16
|
end
|
15
17
|
|
16
18
|
def cd(path)
|
@@ -23,13 +25,13 @@ module SocialSnippet::StorageBackend
|
|
23
25
|
|
24
26
|
def touch(path)
|
25
27
|
realpath = resolve(path)
|
26
|
-
|
28
|
+
add_path realpath
|
27
29
|
end
|
28
30
|
|
29
31
|
def write(path, content)
|
30
32
|
realpath = resolve(path)
|
31
33
|
raise ::Errno::EISDIR if directory?(path)
|
32
|
-
|
34
|
+
add_path realpath
|
33
35
|
file = File.find_or_create_by(:path => realpath)
|
34
36
|
file.update_attributes(
|
35
37
|
:content => content,
|
@@ -54,8 +56,7 @@ module SocialSnippet::StorageBackend
|
|
54
56
|
def mkdir_p(path)
|
55
57
|
realpath = resolve(path)
|
56
58
|
raise ::Errno::EEXIST if file?(realpath)
|
57
|
-
|
58
|
-
paths.add dirpath(realpath)
|
59
|
+
add_dir realpath
|
59
60
|
end
|
60
61
|
|
61
62
|
def exists?(path)
|
@@ -66,13 +67,13 @@ module SocialSnippet::StorageBackend
|
|
66
67
|
|
67
68
|
def rm(path)
|
68
69
|
realpath = resolve(path)
|
69
|
-
|
70
|
+
delete_path realpath
|
70
71
|
end
|
71
72
|
|
72
73
|
def rm_r(path)
|
73
74
|
realpath = resolve(path)
|
74
|
-
paths.
|
75
|
-
tmp_path.start_with?
|
75
|
+
paths.each do |tmp_path|
|
76
|
+
delete_path tmp_path if tmp_path.start_with?(realpath)
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
@@ -88,9 +89,12 @@ module SocialSnippet::StorageBackend
|
|
88
89
|
end
|
89
90
|
|
90
91
|
def glob(pattern)
|
91
|
-
|
92
|
+
real_pattern = resolve(pattern)
|
93
|
+
pattern_dir = dirpath(::File.dirname real_pattern)
|
92
94
|
paths.select do |path|
|
93
|
-
|
95
|
+
next if directory?(path) && path.end_with?("/")
|
96
|
+
next if pattern_dir === path
|
97
|
+
::File.fnmatch real_pattern, path, ::File::FNM_PATHNAME
|
94
98
|
end
|
95
99
|
end
|
96
100
|
|
@@ -107,6 +111,34 @@ module SocialSnippet::StorageBackend
|
|
107
111
|
|
108
112
|
private
|
109
113
|
|
114
|
+
def add_dir(path)
|
115
|
+
add_path path
|
116
|
+
add_path dirpath(path)
|
117
|
+
end
|
118
|
+
|
119
|
+
def add_parent_dir(path)
|
120
|
+
items = path.split(::File::SEPARATOR)
|
121
|
+
items.pop
|
122
|
+
items.inject(::Array.new) do |tmp, item|
|
123
|
+
tmp.push item
|
124
|
+
add_dir ::File.join(*items)
|
125
|
+
tmp
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def add_path(path)
|
130
|
+
add_parent_dir path
|
131
|
+
unless paths.include?(path)
|
132
|
+
paths.add path
|
133
|
+
model.push :paths => path
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def delete_path(path)
|
138
|
+
paths.delete path
|
139
|
+
model.pull :paths => path
|
140
|
+
end
|
141
|
+
|
110
142
|
def absolute?(path)
|
111
143
|
::Pathname.new(path).absolute?
|
112
144
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_snippet-supports-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroyuki Sano
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.0.2
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: social_snippet
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ! '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ! '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|