has_versions 0.4.8 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
data/has_versions.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "has_versions"
4
- s.version = '0.4.8'
4
+ s.version = '0.4.9'
5
5
 
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Grant Rodgers"]
@@ -28,10 +28,4 @@ Gem::Specification.new do |s|
28
28
  s.add_runtime_dependency("simple_uuid", [">= 0"])
29
29
  s.add_development_dependency("rspec", ["~> 2.0"])
30
30
  s.add_development_dependency("yard", ["~> 0.6.0"])
31
- s.add_development_dependency("bundler", ["~> 1.0.0"])
32
- # s.add_development_dependency("cucumber", [">= 0"])
33
- # s.add_development_dependency("simplecov", [">= 0.3.8"])
34
- # s.add_development_dependency("reek", ["~> 1.2.8"])
35
- # s.add_development_dependency("roodi", ["~> 2.1.0"])
36
31
  end
37
-
data/lib/has_versions.rb CHANGED
@@ -13,7 +13,6 @@ module HasVersions
13
13
  autoload :Diff
14
14
  autoload :Merge
15
15
  autoload :Reset
16
- autoload :VersioningKey
17
16
 
18
17
  module Orm
19
18
  extend ActiveSupport::Autoload
@@ -1,7 +1,15 @@
1
1
  module HasVersions
2
2
  module Attributes
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def versioned_fields
7
+ versioning_configuration.attributes
8
+ end
9
+ end
10
+
3
11
  def versioned_attributes
4
- versioning_configuration.attributes.inject({}) do |memo, attribute|
12
+ self.class.versioned_fields.inject({}) do |memo, attribute|
5
13
  memo[attribute] = versioning_encode_value(attribute, self[attribute])
6
14
  memo
7
15
  end
@@ -7,7 +7,7 @@ module HasVersions
7
7
 
8
8
  module Simple
9
9
  def reset!(version)
10
- versioning_configuration.attributes.each do |name|
10
+ self.class.versioned_fields.each do |name|
11
11
  value = versioning_decode_value(name, version.snapshot[name])
12
12
  __send__("#{name}=", value)
13
13
  end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class HasVersions::AttributesTest < MiniTest::Spec
4
+ class VersionedObject
5
+ include HasVersions::Versioned
6
+
7
+ attr_accessor :name
8
+ attr_accessor :time
9
+ attr_accessor :color
10
+
11
+ has_versions(Class.new) do
12
+ attribute :name
13
+ attribute :time
14
+ end
15
+ end
16
+
17
+ def test_versioned_fields
18
+ assert_equal ['name', 'time'], VersionedObject.versioned_fields
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ require 'bundler/setup'
2
+ require 'minitest/autorun'
3
+ Bundler.require
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_versions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.4.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-03 00:00:00.000000000 Z
12
+ date: 2012-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -91,22 +91,6 @@ dependencies:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
93
  version: 0.6.0
94
- - !ruby/object:Gem::Dependency
95
- name: bundler
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ~>
100
- - !ruby/object:Gem::Version
101
- version: 1.0.0
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ~>
108
- - !ruby/object:Gem::Version
109
- version: 1.0.0
110
94
  description: ActiveModel versioning
111
95
  email:
112
96
  - grantr@gmail.com
@@ -148,8 +132,6 @@ files:
148
132
  - lib/has_versions/reset.rb
149
133
  - lib/has_versions/reset/simple.rb
150
134
  - lib/has_versions/versioned.rb
151
- - lib/has_versions/versioning_key.rb
152
- - lib/has_versions/versioning_key/uuid.rb
153
135
  - spec/has_versions/apply_spec.rb
154
136
  - spec/has_versions/configuration_spec.rb
155
137
  - spec/has_versions/diff_spec.rb
@@ -160,10 +142,11 @@ files:
160
142
  - spec/has_versions/reset_spec.rb
161
143
  - spec/has_versions/stage_spec.rb
162
144
  - spec/has_versions/versioned_spec.rb
163
- - spec/has_versions/versioning_key_spec.rb
164
145
  - spec/spec_helper.rb
165
146
  - spec/support/matchers/be_a_uuid.rb
166
147
  - spec/support/version.rb
148
+ - test/has_versions/attributes_test.rb
149
+ - test/test_helper.rb
167
150
  homepage: ''
168
151
  licenses:
169
152
  - MIT
@@ -185,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
168
  version: '0'
186
169
  requirements: []
187
170
  rubyforge_project: has_versions
188
- rubygems_version: 1.8.21
171
+ rubygems_version: 1.8.24
189
172
  signing_key:
190
173
  specification_version: 3
191
174
  summary: ActiveModel versioning
@@ -203,7 +186,8 @@ test_files:
203
186
  - spec/has_versions/reset_spec.rb
204
187
  - spec/has_versions/stage_spec.rb
205
188
  - spec/has_versions/versioned_spec.rb
206
- - spec/has_versions/versioning_key_spec.rb
207
189
  - spec/spec_helper.rb
208
190
  - spec/support/matchers/be_a_uuid.rb
209
191
  - spec/support/version.rb
192
+ - test/has_versions/attributes_test.rb
193
+ - test/test_helper.rb
@@ -1,7 +0,0 @@
1
- module HasVersions
2
- module VersioningKey
3
- extend ActiveSupport::Autoload
4
-
5
- autoload :UUID
6
- end
7
- end
@@ -1,23 +0,0 @@
1
- require 'simple_uuid'
2
-
3
- module HasVersions
4
- module VersioningKey
5
- module UUID
6
- extend ActiveSupport::Concern
7
-
8
- module ClassMethods
9
- def next_versioning_key(object=nil)
10
- SimpleUUID::UUID.new.to_guid
11
- end
12
- end
13
-
14
- def versioning_key
15
- @versioning_key ||= self.class.next_versioning_key(self)
16
- end
17
-
18
- def versioning_key=(key)
19
- @versioning_key = key
20
- end
21
- end
22
- end
23
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'VersioningKey' do
4
- describe 'UUID' do
5
- class VersionedObject
6
- include HasVersions::VersioningKey::UUID
7
- end
8
-
9
- describe 'including class' do
10
- subject { VersionedObject }
11
-
12
- its(:next_versioning_key) { should be_a_uuid }
13
-
14
- it 'should not return the same uuid twice' do
15
- subject.next_versioning_key.should_not equal(subject.next_versioning_key)
16
- end
17
- end
18
-
19
- describe 'instance of including class' do
20
- subject { VersionedObject.new }
21
-
22
- its(:versioning_key) { should be_a_uuid }
23
-
24
- it 'should allow versioning_key to be set' do
25
- key = VersionedObject.next_versioning_key
26
- subject.versioning_key = key
27
- subject.versioning_key.should equal(key)
28
- end
29
- end
30
- end
31
- end