mem_model 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWUyZGEyNjVkNDU2YTEzODQxYTRiZmZhNDk5YTVkMTNjN2UzZDY1ZQ==
4
+ ZGYzMGYzYzhjNDAyMWZlNmM0NjZhYWNjZGU5YWMzODkxNjAxMDUxZg==
5
5
  data.tar.gz: !binary |-
6
- YTlmNjU4MTBlNzQwNzQ4YzUxMDlmMGU5YmVjODg1MjliNTNiMTk4Mw==
6
+ YzdmNjFlOWJjMzg5NDhhOWQ2NjVmZjYwMDA1NTg1NjE3MDIzN2ViYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWFiZjNiODE0YmM3MzZhNTFhZDBmMjA0NTA0NzkyODVkOGY0ZmM5YWJlODZm
10
- NDcyMWM0MGViY2Y1YWY4ZjdiNDJkNTM5MThkMjRiYjEzYjE4YWJkNDdiNGM0
11
- NDExNjcxMGU2Zjg4NzdjNTViNTE3ZGE1MTczMDU2YzUwOTRmMWI=
9
+ ZjY1Y2EzZmM3MDg2ODc4MTkzZWIxMDQyODkxYzAyNjYxNDdmZTU3MGUyMTAw
10
+ NDBmYjhjMmQ3NjA2YjM2MjEwMDdjYTAzNTcwNWQ3MGE2YmY5ZmRhZmNiMGQ4
11
+ MzJlOTI3ZmMwYWYyYTZiZmQ0ZWNjYTIyNTMwOTM4MGUyZTljY2M=
12
12
  data.tar.gz: !binary |-
13
- ODEyZTFhNzQzNDA5ZTVlNjllMjkxMjI0M2JhOGNmZTgwNjFjYTA2NTZiYjFl
14
- NmNhZTkyNzA5YTVlYjRkMjdlOGMwMmU1YjZiYTZlN2ZiZDg0MDg5ZDQ0MmQ1
15
- OGEzZTg3NTAzNTZiOTAyNzk5MWQ2YmJlYjMzMjA0MDQ4MWIwM2M=
13
+ ZmU1ODE0NDc0ZGY1M2Q0ZjhhNTA0NjNjNDk2NTVkMTZjNjNjNzFjMTY0MGFj
14
+ OThiN2I5Y2FhZTgyZTZjZGE5YThhMjliZjUyZWI3NTlhYmY4NjFiYzRkYjRl
15
+ OWJjMTk0Yzk5YzYyY2M5NmZkMzM3MWJiYmY3NWU1Y2YwMTk3OTc=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 0.9.0 / 2014-01-29
2
+
3
+ * 4 enhancements:
4
+
5
+ * Add created_at, updated_at
6
+ * Add to_hash
7
+ * Always initialize @id
8
+ * persistent now commits
9
+
10
+
1
11
  ### 0.8.0 / 2014-01-03
2
12
 
3
13
  * 1 enhancement:
data/Rakefile CHANGED
@@ -9,7 +9,8 @@ end
9
9
  desc 'Setup your local dev environment'
10
10
  task :setup do
11
11
  spec = Gem::Specification::load('mem_model.gemspec')
12
- sh "gem install hoe-git #{spec.dependencies.map{|d| d.name}.join(' ')}"
12
+ sh "gem install #{spec.dependencies.map{|d| d.name}.join(' ')}"
13
+ sh "rake install_plugins"
13
14
  end
14
15
 
15
16
  desc 'Changelog'
@@ -36,7 +37,7 @@ end
36
37
 
37
38
  if defined? Hoe
38
39
 
39
- [ :debug, :deps, :gemcutter, :newb, :publish, :signing ].each do |plugin|
40
+ [ :debug, :gemcutter, :newb, :publish, :signing ].each do |plugin|
40
41
  Hoe.plugins.delete plugin
41
42
  end
42
43
 
@@ -61,9 +62,9 @@ Hoe.spec 'mem_model' do
61
62
 
62
63
  license 'MIT'
63
64
 
64
- dependency 'minitest', '>= 5.0.0', :development
65
- dependency 'minitest-reporters', '>= 1.0.0', :development
66
- dependency 'coveralls', '>= 1.0.0', :development
65
+ dependency 'minitest', '~> 5.0', :development
66
+ dependency 'minitest-reporters', '~> 1.0', :development
67
+ dependency 'coveralls', '~> 1.0', :development
67
68
  end
68
69
 
69
70
  end # has_hoe
@@ -8,6 +8,9 @@ module MemModel
8
8
  include MemModel::Validations
9
9
  include MemModel::Guid
10
10
  attr_accessor :id
11
+ attr_reader :created_at, :updated_at
12
+ alias :guid :id
13
+ alias :guid= :id=
11
14
  end
12
15
 
13
16
  module ClassMethods
@@ -97,7 +100,7 @@ module MemModel
97
100
  alias_method :to_str, :to_s
98
101
 
99
102
  def delete(record)
100
- store.delete(record)
103
+ persistent{ store.delete(record) }
101
104
  end
102
105
 
103
106
  if !MemModel.maglev?
@@ -105,20 +108,18 @@ module MemModel
105
108
  end
106
109
 
107
110
  def persistent(&block)
108
- committed? ?
111
+ result = committed? ?
109
112
  MemModel.persistent(&block) :
110
113
  block.call
114
+ commit
115
+ result
111
116
  end
112
117
  end
113
118
 
114
119
  def initialize(attributes = {})
115
120
  @persisted = false unless maglev?
121
+ @id = self.class.generate_id
116
122
  load_attributes(attributes)
117
- self.id ||= self.generate_id
118
- end
119
-
120
- def generate_id
121
- object_id
122
123
  end
123
124
 
124
125
  def model_name; self.class.model_name; end
@@ -170,15 +171,16 @@ module MemModel
170
171
  end
171
172
 
172
173
  def create
173
- self.id ||= generate_id
174
174
  persistent do
175
+ @created_at = @updated_at = Time.now
176
+ @persisted = true if !class_committed?
175
177
  self.class.store << self
176
- @persisted = true unless class_committed?
177
178
  end
178
179
  self.id
179
180
  end
180
181
 
181
182
  def update
183
+ @updated_at = Time.now
182
184
  commit
183
185
  true
184
186
  end
@@ -197,13 +199,21 @@ module MemModel
197
199
  return self
198
200
  end
199
201
 
202
+ def to_hash
203
+ {
204
+ id: id,
205
+ created_at: created_at,
206
+ updated_at: updated_at
207
+ }
208
+ end
209
+
200
210
  private
201
211
 
202
- def load_attributes(attributes)
203
- return unless attributes
204
- attributes.each do |(name, value)|
205
- self.send("#{name}=".to_sym, value)
212
+ def load_attributes(attributes)
213
+ return unless attributes
214
+ attributes.each do |(name, value)|
215
+ self.send("#{name}=".to_sym, value)
216
+ end
206
217
  end
207
- end
208
218
  end
209
219
  end
@@ -2,10 +2,6 @@ module MemModel
2
2
  module Guid
3
3
  extend MemModel::Concern
4
4
 
5
- def generate_id
6
- self.class.generate_id
7
- end
8
-
9
5
  module ClassMethods
10
6
  def generate_id
11
7
  [guid_prefix, '-', new_uuid].join.upcase
@@ -1,3 +1,3 @@
1
1
  module MemModel
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
data/mem_model.gemspec CHANGED
@@ -1,25 +1,25 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: mem_model 0.8.0.20140103190534 ruby lib
2
+ # stub: mem_model 0.9.0.20140129213522 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "mem_model"
6
- s.version = "0.8.0.20140103190534"
6
+ s.version = "0.9.0.20140129213522"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
+ s.require_paths = ["lib"]
9
10
  s.authors = ["JohnnyT"]
10
- s.date = "2014-01-04"
11
+ s.date = "2014-01-30"
11
12
  s.description = "MemModel persists Ruby objects using MagLev as a data storage engine. It's an ActiveModel implementation so it works stand-alone or in Rails 3 as a drop-in replacement for ActiveRecord or DataMapper. If MemModel is used in non-MagLev platforms, objects will be persisted to in-memory sets."
12
13
  s.email = ["ubergeek3141@gmail.com"]
13
14
  s.extra_rdoc_files = ["CHANGELOG.md", "CONTRIBUTING.md", "LICENSE.md", "Manifest.txt", "README.md"]
14
- s.files = [".coveralls.yml", ".gitignore", ".travis.yml", "CHANGELOG.md", "CONTRIBUTING.md", "Gemfile.ci", "LICENSE.md", "Manifest.txt", "README.md", "Rakefile", "lib/mem_model.rb", "lib/mem_model/base.rb", "lib/mem_model/concern.rb", "lib/mem_model/errors.rb", "lib/mem_model/guid.rb", "lib/mem_model/model_name.rb", "lib/mem_model/rooted_base.rb", "lib/mem_model/validations.rb", "lib/mem_model/version.rb", "mem_model.gemspec", "test/helper.rb", "test/mem_model/test_active_model.rb", "test/mem_model/test_base.rb", "test/mem_model/test_guid.rb", "test/mem_model/test_rooted_base.rb", "test/mem_model/test_validations.rb", "test/mem_model/test_version.rb", "test/support/active_model_lint.rb", ".gemtest"]
15
+ s.files = [".coveralls.yml", ".gemtest", ".gitignore", ".travis.yml", "CHANGELOG.md", "CONTRIBUTING.md", "Gemfile.ci", "LICENSE.md", "Manifest.txt", "README.md", "Rakefile", "lib/mem_model.rb", "lib/mem_model/base.rb", "lib/mem_model/concern.rb", "lib/mem_model/errors.rb", "lib/mem_model/guid.rb", "lib/mem_model/model_name.rb", "lib/mem_model/validations.rb", "lib/mem_model/version.rb", "mem_model.gemspec", "test/helper.rb", "test/mem_model/test_active_model.rb", "test/mem_model/test_base.rb", "test/mem_model/test_guid.rb", "test/mem_model/test_rooted_base.rb", "test/mem_model/test_validations.rb", "test/mem_model/test_version.rb", "test/support/active_model_lint.rb"]
15
16
  s.homepage = "https://github.com/johnnyt/mem_model"
16
17
  s.licenses = ["MIT"]
17
18
  s.rdoc_options = ["--main", "README.md"]
18
- s.require_paths = ["lib"]
19
19
  s.rubyforge_project = "mem_model"
20
- s.rubygems_version = "2.1.11"
20
+ s.rubygems_version = "2.2.1"
21
21
  s.summary = "ActiveModel-compliant MagLev persistence"
22
- s.test_files = ["test/mem_model/test_rooted_base.rb", "test/mem_model/test_guid.rb", "test/mem_model/test_base.rb", "test/mem_model/test_active_model.rb", "test/mem_model/test_validations.rb", "test/mem_model/test_version.rb"]
22
+ s.test_files = ["test/mem_model/test_active_model.rb", "test/mem_model/test_rooted_base.rb", "test/mem_model/test_base.rb", "test/mem_model/test_validations.rb", "test/mem_model/test_version.rb", "test/mem_model/test_guid.rb"]
23
23
 
24
24
  if s.respond_to? :specification_version then
25
25
  s.specification_version = 4
@@ -28,17 +28,17 @@ Gem::Specification.new do |s|
28
28
  s.add_development_dependency(%q<minitest>, [">= 5.0.0"])
29
29
  s.add_development_dependency(%q<minitest-reporters>, [">= 1.0.0"])
30
30
  s.add_development_dependency(%q<coveralls>, [">= 1.0.0"])
31
- s.add_development_dependency(%q<hoe>, ["~> 3.7"])
31
+ s.add_development_dependency(%q<hoe>, ["~> 3.8"])
32
32
  else
33
33
  s.add_dependency(%q<minitest>, [">= 5.0.0"])
34
34
  s.add_dependency(%q<minitest-reporters>, [">= 1.0.0"])
35
35
  s.add_dependency(%q<coveralls>, [">= 1.0.0"])
36
- s.add_dependency(%q<hoe>, ["~> 3.7"])
36
+ s.add_dependency(%q<hoe>, ["~> 3.8"])
37
37
  end
38
38
  else
39
39
  s.add_dependency(%q<minitest>, [">= 5.0.0"])
40
40
  s.add_dependency(%q<minitest-reporters>, [">= 1.0.0"])
41
41
  s.add_dependency(%q<coveralls>, [">= 1.0.0"])
42
- s.add_dependency(%q<hoe>, ["~> 3.7"])
42
+ s.add_dependency(%q<hoe>, ["~> 3.8"])
43
43
  end
44
44
  end
data/test/helper.rb CHANGED
@@ -13,5 +13,5 @@ end
13
13
 
14
14
  require File.expand_path('lib/mem_model')
15
15
  Dir[File.expand_path('../support/*.rb', __FILE__)].each { |file| require file }
16
- gem 'minitest', '5.2.0'
16
+ require 'minitest'
17
17
  require 'minitest/autorun'
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mem_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JohnnyT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-04 00:00:00.000000000 Z
11
+ date: 2014-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0
19
+ version: '5.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest-reporters
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: '1.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.0
47
+ version: '1.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.0
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: hoe
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '3.7'
61
+ version: '3.8'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '3.7'
68
+ version: '3.8'
69
69
  description: MemModel persists Ruby objects using MagLev as a data storage engine.
70
70
  It's an ActiveModel implementation so it works stand-alone or in Rails 3 as a drop-in
71
71
  replacement for ActiveRecord or DataMapper. If MemModel is used in non-MagLev platforms,
@@ -82,6 +82,7 @@ extra_rdoc_files:
82
82
  - README.md
83
83
  files:
84
84
  - .coveralls.yml
85
+ - .gemtest
85
86
  - .gitignore
86
87
  - .travis.yml
87
88
  - CHANGELOG.md
@@ -108,7 +109,6 @@ files:
108
109
  - test/mem_model/test_validations.rb
109
110
  - test/mem_model/test_version.rb
110
111
  - test/support/active_model_lint.rb
111
- - .gemtest
112
112
  homepage: https://github.com/johnnyt/mem_model
113
113
  licenses:
114
114
  - MIT
@@ -131,14 +131,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  requirements: []
133
133
  rubyforge_project: mem_model
134
- rubygems_version: 2.1.11
134
+ rubygems_version: 2.2.1
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: ActiveModel-compliant MagLev persistence
138
138
  test_files:
139
+ - test/mem_model/test_active_model.rb
139
140
  - test/mem_model/test_rooted_base.rb
140
- - test/mem_model/test_guid.rb
141
141
  - test/mem_model/test_base.rb
142
- - test/mem_model/test_active_model.rb
143
142
  - test/mem_model/test_validations.rb
144
143
  - test/mem_model/test_version.rb
144
+ - test/mem_model/test_guid.rb