ampere 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,6 +3,8 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
+ gem 'activesupport'
7
+ gem 'activemodel'
6
8
  gem 'redis'
7
9
 
8
10
  # Add dependencies to develop your gem here.
@@ -10,7 +12,7 @@ gem 'redis'
10
12
  group :development do
11
13
  gem "shoulda", ">= 0"
12
14
  gem "cucumber", ">= 0"
13
- gem "bundler", "~> 1.0.0"
15
+ gem "bundler", ">= 1.0.0"
14
16
  gem "jeweler", "~> 1.6.4"
15
17
  gem 'simplecov', :require => false, :group => :test
16
18
  gem "rspec"
@@ -1,6 +1,12 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ activemodel (3.2.3)
5
+ activesupport (= 3.2.3)
6
+ builder (~> 3.0.0)
7
+ activesupport (3.2.3)
8
+ i18n (~> 0.6)
9
+ multi_json (~> 1.0)
4
10
  builder (3.0.0)
5
11
  cucumber (1.1.3)
6
12
  builder (>= 2.1.2)
@@ -12,6 +18,7 @@ GEM
12
18
  gherkin (2.6.8)
13
19
  json (>= 1.4.6)
14
20
  git (1.2.5)
21
+ i18n (0.6.0)
15
22
  jeweler (1.6.4)
16
23
  bundler (~> 1.0)
17
24
  git (>= 1.2.5)
@@ -41,7 +48,9 @@ PLATFORMS
41
48
  ruby
42
49
 
43
50
  DEPENDENCIES
44
- bundler (~> 1.0.0)
51
+ activemodel
52
+ activesupport
53
+ bundler (>= 1.0.0)
45
54
  cucumber
46
55
  jeweler (~> 1.6.4)
47
56
  rdoc
data/README.md CHANGED
@@ -93,6 +93,25 @@ individual indices, which will always run faster than queries on unindexed field
93
93
  _**Warning:**_ If you query on an un-indexed field, the returned result set will not be
94
94
  evaluated lazily!
95
95
 
96
+ ### Validations
97
+
98
+ You can now add validations to your Ampere models thanks to the magic of ActiveModel!
99
+
100
+ class Student
101
+ include Ampere::Model
102
+
103
+ field :last_name
104
+ field :first_name
105
+ field :student_id_number
106
+
107
+ index [:last_name, :first_name]
108
+
109
+ validates_presence_of :last_name
110
+ validates_format_of :student_id_number, :with => /\A[0-9]{10}\Z/
111
+ end
112
+
113
+ It's that easy!
114
+
96
115
  ## Contributing to ampere
97
116
 
98
117
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ampere"
8
- s.version = "1.1.0"
8
+ s.version = "1.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Max Thom Stahl"]
12
- s.date = "2012-05-03"
12
+ s.date = "2012-05-12"
13
13
  s.description = "An ActiveRecord/Mongoid-esque object model for the Redis key/value data store."
14
14
  s.email = "max@villainousindustri.es"
15
15
  s.extra_rdoc_files = [
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
40
40
  "spec/models/relationships/has_many_spec.rb",
41
41
  "spec/models/relationships/has_one_spec.rb",
42
42
  "spec/models/updates_spec.rb",
43
+ "spec/models/validations_spec.rb",
43
44
  "spec/module/ampere_spec.rb",
44
45
  "spec/module/collections_ennumerable_spec.rb",
45
46
  "spec/module/collections_spec.rb",
@@ -57,29 +58,35 @@ Gem::Specification.new do |s|
57
58
  s.specification_version = 3
58
59
 
59
60
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
62
+ s.add_runtime_dependency(%q<activemodel>, [">= 0"])
60
63
  s.add_runtime_dependency(%q<redis>, [">= 0"])
61
64
  s.add_development_dependency(%q<shoulda>, [">= 0"])
62
65
  s.add_development_dependency(%q<cucumber>, [">= 0"])
63
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
64
67
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
65
68
  s.add_development_dependency(%q<simplecov>, [">= 0"])
66
69
  s.add_development_dependency(%q<rspec>, [">= 0"])
67
70
  s.add_development_dependency(%q<rdoc>, [">= 0"])
68
71
  else
72
+ s.add_dependency(%q<activesupport>, [">= 0"])
73
+ s.add_dependency(%q<activemodel>, [">= 0"])
69
74
  s.add_dependency(%q<redis>, [">= 0"])
70
75
  s.add_dependency(%q<shoulda>, [">= 0"])
71
76
  s.add_dependency(%q<cucumber>, [">= 0"])
72
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
77
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
73
78
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
74
79
  s.add_dependency(%q<simplecov>, [">= 0"])
75
80
  s.add_dependency(%q<rspec>, [">= 0"])
76
81
  s.add_dependency(%q<rdoc>, [">= 0"])
77
82
  end
78
83
  else
84
+ s.add_dependency(%q<activesupport>, [">= 0"])
85
+ s.add_dependency(%q<activemodel>, [">= 0"])
79
86
  s.add_dependency(%q<redis>, [">= 0"])
80
87
  s.add_dependency(%q<shoulda>, [">= 0"])
81
88
  s.add_dependency(%q<cucumber>, [">= 0"])
82
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
89
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
83
90
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
84
91
  s.add_dependency(%q<simplecov>, [">= 0"])
85
92
  s.add_dependency(%q<rspec>, [">= 0"])
@@ -1,3 +1,5 @@
1
+ # require "active_support"
2
+ require "active_record"
1
3
  require "redis"
2
4
  require "pp"
3
5
 
@@ -5,6 +5,8 @@ module Ampere
5
5
  base.extend(ClassMethods)
6
6
 
7
7
  base.class_eval do
8
+ include(::ActiveModel::Validations)
9
+
8
10
  attr_reader :id
9
11
 
10
12
  attr_accessor :fields
@@ -0,0 +1,41 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ describe 'Validations', :validations => true do
4
+ before :all do
5
+ class Person
6
+ include Ampere::Model
7
+
8
+ field :first_name
9
+ field :last_name
10
+ field :email
11
+
12
+ validates_presence_of :last_name
13
+ validates_format_of :email, :with => /\A\w+@\w+\.com\Z/i
14
+ end
15
+
16
+ end
17
+
18
+ it 'should validate presence of items' do
19
+ alice = Person.new :first_name => 'Alice',
20
+ :last_name => 'Steel',
21
+ :email => 'alice@steel.com'
22
+ bob = Person.new :first_name => 'Bob',
23
+ :email => 'bob@bob.com'
24
+ alice.should be_valid
25
+ alice.errors.should be_empty
26
+ bob.should be_invalid
27
+ bob.errors.should_not be_empty
28
+ end
29
+
30
+ it 'should validate format of items' do
31
+ charlie = Person.new :first_name => 'Charlie',
32
+ :last_name => 'Steel',
33
+ :email => 'c h a r l i e @ charlie .com'
34
+ charlie.should_not be_valid
35
+ end
36
+
37
+ # Since this is accomplished by including a module, what is being tested here
38
+ # is that the module got included correctly and works. For testing of all the
39
+ # other kinds of validations, run the tests for ActiveModel::Validations.
40
+ end
41
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ampere
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,33 @@ 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-12 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: &2166309900 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2166309900
25
+ - !ruby/object:Gem::Dependency
26
+ name: activemodel
27
+ requirement: &2166309360 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2166309360
14
36
  - !ruby/object:Gem::Dependency
15
37
  name: redis
16
- requirement: &2157094220 !ruby/object:Gem::Requirement
38
+ requirement: &2166308860 !ruby/object:Gem::Requirement
17
39
  none: false
18
40
  requirements:
19
41
  - - ! '>='
@@ -21,10 +43,10 @@ dependencies:
21
43
  version: '0'
22
44
  type: :runtime
23
45
  prerelease: false
24
- version_requirements: *2157094220
46
+ version_requirements: *2166308860
25
47
  - !ruby/object:Gem::Dependency
26
48
  name: shoulda
27
- requirement: &2157093700 !ruby/object:Gem::Requirement
49
+ requirement: &2166308340 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ! '>='
@@ -32,10 +54,10 @@ dependencies:
32
54
  version: '0'
33
55
  type: :development
34
56
  prerelease: false
35
- version_requirements: *2157093700
57
+ version_requirements: *2166308340
36
58
  - !ruby/object:Gem::Dependency
37
59
  name: cucumber
38
- requirement: &2157093160 !ruby/object:Gem::Requirement
60
+ requirement: &2166307820 !ruby/object:Gem::Requirement
39
61
  none: false
40
62
  requirements:
41
63
  - - ! '>='
@@ -43,21 +65,21 @@ dependencies:
43
65
  version: '0'
44
66
  type: :development
45
67
  prerelease: false
46
- version_requirements: *2157093160
68
+ version_requirements: *2166307820
47
69
  - !ruby/object:Gem::Dependency
48
70
  name: bundler
49
- requirement: &2157092600 !ruby/object:Gem::Requirement
71
+ requirement: &2166307260 !ruby/object:Gem::Requirement
50
72
  none: false
51
73
  requirements:
52
- - - ~>
74
+ - - ! '>='
53
75
  - !ruby/object:Gem::Version
54
76
  version: 1.0.0
55
77
  type: :development
56
78
  prerelease: false
57
- version_requirements: *2157092600
79
+ version_requirements: *2166307260
58
80
  - !ruby/object:Gem::Dependency
59
81
  name: jeweler
60
- requirement: &2157092100 !ruby/object:Gem::Requirement
82
+ requirement: &2166306720 !ruby/object:Gem::Requirement
61
83
  none: false
62
84
  requirements:
63
85
  - - ~>
@@ -65,10 +87,10 @@ dependencies:
65
87
  version: 1.6.4
66
88
  type: :development
67
89
  prerelease: false
68
- version_requirements: *2157092100
90
+ version_requirements: *2166306720
69
91
  - !ruby/object:Gem::Dependency
70
92
  name: simplecov
71
- requirement: &2157000680 !ruby/object:Gem::Requirement
93
+ requirement: &2166306160 !ruby/object:Gem::Requirement
72
94
  none: false
73
95
  requirements:
74
96
  - - ! '>='
@@ -76,10 +98,10 @@ dependencies:
76
98
  version: '0'
77
99
  type: :development
78
100
  prerelease: false
79
- version_requirements: *2157000680
101
+ version_requirements: *2166306160
80
102
  - !ruby/object:Gem::Dependency
81
103
  name: rspec
82
- requirement: &2157000140 !ruby/object:Gem::Requirement
104
+ requirement: &2166305600 !ruby/object:Gem::Requirement
83
105
  none: false
84
106
  requirements:
85
107
  - - ! '>='
@@ -87,10 +109,10 @@ dependencies:
87
109
  version: '0'
88
110
  type: :development
89
111
  prerelease: false
90
- version_requirements: *2157000140
112
+ version_requirements: *2166305600
91
113
  - !ruby/object:Gem::Dependency
92
114
  name: rdoc
93
- requirement: &2156999620 !ruby/object:Gem::Requirement
115
+ requirement: &2166305100 !ruby/object:Gem::Requirement
94
116
  none: false
95
117
  requirements:
96
118
  - - ! '>='
@@ -98,7 +120,7 @@ dependencies:
98
120
  version: '0'
99
121
  type: :development
100
122
  prerelease: false
101
- version_requirements: *2156999620
123
+ version_requirements: *2166305100
102
124
  description: An ActiveRecord/Mongoid-esque object model for the Redis key/value data
103
125
  store.
104
126
  email: max@villainousindustri.es
@@ -131,6 +153,7 @@ files:
131
153
  - spec/models/relationships/has_many_spec.rb
132
154
  - spec/models/relationships/has_one_spec.rb
133
155
  - spec/models/updates_spec.rb
156
+ - spec/models/validations_spec.rb
134
157
  - spec/module/ampere_spec.rb
135
158
  - spec/module/collections_ennumerable_spec.rb
136
159
  - spec/module/collections_spec.rb
@@ -152,7 +175,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
175
  version: '0'
153
176
  segments:
154
177
  - 0
155
- hash: 3615386568657855204
178
+ hash: -3870431853959501764
156
179
  required_rubygems_version: !ruby/object:Gem::Requirement
157
180
  none: false
158
181
  requirements: