acts_as_git 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/acts_as_git.gemspec +1 -1
- data/lib/acts_as_git.rb +38 -36
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8a66ea83e90c063ae3e92a5c3d82624376ddc2b
|
4
|
+
data.tar.gz: 74eed50746565d7c6c0df0f5ab429b088508080f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6975398a9a676d9703e8d776d27b12a9d2391380e12d2dac5fea27ae9cdd2165795a913c243238e30bfbdd15218291355a181b10b8e067cb7c8869381624eb3b
|
7
|
+
data.tar.gz: 902f2e58656d463a442300ee6fc6f74d4f0615b6207143aea8214006eac595edac4c8b47da63fda33d47fe0e3a5b548930ce6abbf39d73fed271b4c99d63a045
|
data/.gitignore
CHANGED
data/acts_as_git.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.homepage = "https://github.com/rail44/acts_as_git"
|
9
9
|
s.summary = "Make your field act as a git repo"
|
10
10
|
s.description = "Make your field act as a git repo. Save the content to a file, and load the content from a file."
|
11
|
-
s.version = '0.2.
|
11
|
+
s.version = '0.2.4'
|
12
12
|
s.date = Time.now.strftime("%Y-%m-%d")
|
13
13
|
|
14
14
|
s.extra_rdoc_files = Dir["*.rdoc"]
|
data/lib/acts_as_git.rb
CHANGED
@@ -113,31 +113,32 @@ module ActsAsGit
|
|
113
113
|
end
|
114
114
|
|
115
115
|
define_method(:save_with_file) do |*args|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
116
|
+
if save_without_file(*args)
|
117
|
+
params.each do |field, filename_instance_method|
|
118
|
+
field_name = :"@#{field}"
|
119
|
+
repodir = self.class.repodir
|
120
|
+
filename = filename_instance_method.bind(self).call
|
121
|
+
content = instance_variable_get(field_name)
|
122
|
+
if repodir and filename and content
|
123
|
+
oid = @@repo.write(content, :blob)
|
124
|
+
index = @@repo.index
|
125
|
+
path = path(field)
|
126
|
+
action = File.exists?(path)? 'Update': 'Create'
|
127
|
+
FileUtils.mkdir_p(File.dirname(path))
|
128
|
+
index.add(path: filename, oid: oid, mode: 0100644)
|
129
|
+
option = self.class.get_option(index)
|
130
|
+
option[:message] = "#{action} #{filename} for field #{field_name} of #{self.class.name}"
|
131
|
+
Rugged::Commit.create(@@repo, option)
|
132
|
+
@current = @@repo.head.target
|
133
|
+
@@repo.checkout('HEAD', :strategy => :force)
|
134
|
+
@is_changed = false
|
135
|
+
instance_variable_set(field_name, nil)
|
136
|
+
end
|
135
137
|
end
|
136
138
|
end
|
137
|
-
save_without_file(*args)
|
138
139
|
end
|
139
140
|
|
140
|
-
define_method(:save) {|*args| } unless method_defined?(:save)
|
141
|
+
define_method(:save) {|*args| true } unless method_defined?(:save)
|
141
142
|
alias_method :save_without_file, :save
|
142
143
|
alias_method :save, :save_with_file
|
143
144
|
|
@@ -168,24 +169,25 @@ module ActsAsGit
|
|
168
169
|
end
|
169
170
|
|
170
171
|
define_method(:destroy_with_file) do
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
172
|
+
if destroy_without_file
|
173
|
+
params.each do |field, filename_instance_method|
|
174
|
+
field_name = :"@#{field}"
|
175
|
+
filename = filename_instance_method.bind(self).call
|
176
|
+
index = @@repo.index
|
177
|
+
begin
|
178
|
+
index.remove(filename)
|
179
|
+
option = self.class.get_option(index)
|
180
|
+
option[:message] = "Remove #{filename} for field #{field_name} of #{self.class.name}"
|
181
|
+
Rugged::Commit.create(@@repo, option)
|
182
|
+
@current = @@repo.head.target
|
183
|
+
@@repo.checkout('HEAD', :strategy => :force)
|
184
|
+
@is_changed = false
|
185
|
+
rescue Rugged::IndexError => e
|
186
|
+
end
|
184
187
|
end
|
185
188
|
end
|
186
|
-
destroy_without_file
|
187
189
|
end
|
188
|
-
define_method(:destroy) {} unless method_defined?(:destroy)
|
190
|
+
define_method(:destroy) {true} unless method_defined?(:destroy)
|
189
191
|
alias_method :destroy_without_file, :destroy
|
190
192
|
alias_method :destroy, :destroy_with_file
|
191
193
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satoshi Amemiya
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rugged
|