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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 548a408bfc4e57cd36753dfc8f6d5430c17d0153
4
- data.tar.gz: 6d8237671f4f92ef5b30c24b1d4645ee42085124
3
+ metadata.gz: b8a66ea83e90c063ae3e92a5c3d82624376ddc2b
4
+ data.tar.gz: 74eed50746565d7c6c0df0f5ab429b088508080f
5
5
  SHA512:
6
- metadata.gz: 52fdcc5ab24e32e2a722de1cfc7a52607f04c3bb03918a63f1d978e366ce14bf884c5821b571dcfd2655144ad0453b30b18ee7f3819e9fc3f2bfdcf027d330c4
7
- data.tar.gz: 3f9bc33d2e1be6575e4e63e5880b4b9b3035d80d87b0345456cb3b722e4dd4325cb1883425ab38605672c9f0a486394985e4ea3acc8698d39135113878ce7184
6
+ metadata.gz: 6975398a9a676d9703e8d776d27b12a9d2391380e12d2dac5fea27ae9cdd2165795a913c243238e30bfbdd15218291355a181b10b8e067cb7c8869381624eb3b
7
+ data.tar.gz: 902f2e58656d463a442300ee6fc6f74d4f0615b6207143aea8214006eac595edac4c8b47da63fda33d47fe0e3a5b548930ce6abbf39d73fed271b4c99d63a045
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ doc/
7
7
  .DS_Store
8
8
  tags
9
9
  pkg/*
10
+ vendor/*
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.3'
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
- params.each do |field, filename_instance_method|
117
- field_name = :"@#{field}"
118
- repodir = self.class.repodir
119
- filename = filename_instance_method.bind(self).call
120
- content = instance_variable_get(field_name)
121
- if repodir and filename and content
122
- oid = @@repo.write(content, :blob)
123
- index = @@repo.index
124
- path = path(field)
125
- action = File.exists?(path)? 'Update': 'Create'
126
- FileUtils.mkdir_p(File.dirname(path))
127
- index.add(path: filename, oid: oid, mode: 0100644)
128
- option = self.class.get_option(index)
129
- option[:message] = "#{action} #{filename} for field #{field_name} of #{self.class.name}"
130
- Rugged::Commit.create(@@repo, option)
131
- @current = @@repo.head.target
132
- @@repo.checkout('HEAD', :strategy => :force)
133
- @is_changed = false
134
- instance_variable_set(field_name, nil)
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
- params.each do |field, filename_instance_method|
172
- field_name = :"@#{field}"
173
- filename = filename_instance_method.bind(self).call
174
- index = @@repo.index
175
- begin
176
- index.remove(filename)
177
- option = self.class.get_option(index)
178
- option[:message] = "Remove #{filename} for field #{field_name} of #{self.class.name}"
179
- Rugged::Commit.create(@@repo, option)
180
- @current = @@repo.head.target
181
- @@repo.checkout('HEAD', :strategy => :force)
182
- @is_changed = false
183
- rescue Rugged::IndexError => e
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.3
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-01 00:00:00.000000000 Z
12
+ date: 2014-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rugged