dm-active_model 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -3,3 +3,5 @@
3
3
  coverage
4
4
  rdoc
5
5
  pkg
6
+ .bundle
7
+
data/Gemfile ADDED
@@ -0,0 +1,27 @@
1
+ # This will setup a complete development environment
2
+ #
3
+ # git clone git://github.com/snusnu/dm-active_model
4
+ # cd dm-active_model
5
+ # gem install bundler (if you haven't done so before)
6
+ # bundle install
7
+ # rake spec
8
+ #
9
+
10
+ source 'http://gemcutter.org'
11
+
12
+ git 'git://github.com/rails/rails.git'
13
+ gem 'activesupport', '~> 3.0.0.beta1', :require => 'active_support'
14
+ gem 'activemodel', '~> 3.0.0.beta1', :require => 'active_model'
15
+
16
+ git 'git://github.com/snusnu/dm-core.git', 'branch' => 'active_support'
17
+ gem 'dm-core', '~> 0.10'
18
+
19
+ group(:test) do
20
+ gem 'rspec', '~> 1.3'
21
+ gem 'do_sqlite3', '~> 0.10.1'
22
+ end
23
+
24
+ group(:development) do
25
+ gem 'rake'
26
+ gem 'jeweler', '~> 1.4'
27
+ end
data/Rakefile CHANGED
@@ -1,4 +1,15 @@
1
- require 'rubygems'
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
9
+ end
10
+
11
+ Bundler.require(:default, :development, :test)
12
+
2
13
  require 'rake'
3
14
 
4
15
  require File.expand_path('../lib/dm-active_model/version', __FILE__)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dm-active_model}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Gamsjaeger (snusnu)"]
12
- s.date = %q{2010-01-20}
12
+ s.date = %q{2010-02-23}
13
13
  s.description = %q{A datamapper plugin for active_model compliance and thus rails 3 compatibility.}
14
14
  s.email = %q{gamsnjaga [a] gmail [d] com}
15
15
  s.extra_rdoc_files = [
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  ".document",
22
22
  ".gitignore",
23
23
  "CHANGELOG",
24
+ "Gemfile",
24
25
  "LICENSE",
25
26
  "README.rdoc",
26
27
  "Rakefile",
@@ -43,7 +44,7 @@ Gem::Specification.new do |s|
43
44
  s.homepage = %q{http://github.com/snusnu/dm-active_model}
44
45
  s.rdoc_options = ["--charset=UTF-8"]
45
46
  s.require_paths = ["lib"]
46
- s.rubygems_version = %q{1.3.5}
47
+ s.rubygems_version = %q{1.3.6}
47
48
  s.summary = %q{active_model compliance for datamapper}
48
49
  s.test_files = [
49
50
  "spec/amo_compliance_spec.rb",
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module ActiveModel
3
3
 
4
- VERSION = '0.3.0'.freeze
4
+ VERSION = '0.4.0'.freeze
5
5
 
6
6
  end
7
7
  end
@@ -15,16 +15,27 @@ module DataMapper
15
15
 
16
16
  module InstanceMethods
17
17
 
18
- def self.included(host)
19
- host.class_eval do
20
- alias :new_record? :new?
21
- end
22
- end
23
-
24
18
  def to_model
25
19
  self
26
20
  end
27
21
 
22
+ def persisted?
23
+ saved?
24
+ end
25
+
26
+ def to_key
27
+ key
28
+ end
29
+
30
+ def to_param
31
+ return nil if key.nil?
32
+ if key.length > 1
33
+ raise "You need to implement #to_param yourself to support this key: #{self.class.key.inspect}"
34
+ else
35
+ self.key.first.to_s
36
+ end
37
+ end
38
+
28
39
  # Define the minimum requirements if the resource
29
40
  # has no concept of validation baked in, which
30
41
  # happens if dm-validations is not required.
@@ -11,16 +11,20 @@ share_examples_for 'an active_model compliant object' do
11
11
 
12
12
  include ActiveModel::Lint::Tests
13
13
 
14
- it 'must implement the #valid? interface' do
15
- test_valid?
14
+ it 'must implement the #to_key interface' do
15
+ test_to_key
16
+ end
17
+
18
+ it 'must implement the #to_param interface' do
19
+ test_to_param
16
20
  end
17
21
 
18
- it 'must implement the #new_record? interface' do
19
- test_new_record?
22
+ it 'must implement the #valid? interface' do
23
+ test_valid?
20
24
  end
21
25
 
22
- it 'must implement the #destroyed? interface' do
23
- test_destroyed?
26
+ it 'must implement the #persisted? interface' do
27
+ test_persisted?
24
28
  end
25
29
 
26
30
  it 'must implement the #model_naming interface' do
@@ -17,7 +17,7 @@ describe 'An active_model compliant DataMapper::Resource' do
17
17
  end
18
18
 
19
19
  before :each do
20
- @model = ComplianceTest::ProfileInfo.create.to_model
20
+ @model = ComplianceTest::ProfileInfo.new.to_model
21
21
  end
22
22
 
23
23
  it_should_behave_like 'an active_model compliant object'
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,13 @@
1
- require 'rubygems'
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
9
+ end
10
+ Bundler.require(:default, :test)
2
11
 
3
12
  # Use local dm-core if running from a typical dev checkout.
4
13
  lib = File.expand_path('../../../dm-core/lib', __FILE__)
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-active_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Martin Gamsjaeger (snusnu)
@@ -9,39 +14,49 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-20 00:00:00 +01:00
17
+ date: 2010-02-23 00:00:00 +01:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: dm-core
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ~>
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 10
23
30
  version: "0.10"
24
- version:
31
+ type: :runtime
32
+ version_requirements: *id001
25
33
  - !ruby/object:Gem::Dependency
26
34
  name: rspec
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
30
37
  requirements:
31
38
  - - ">="
32
39
  - !ruby/object:Gem::Version
40
+ segments:
41
+ - 1
42
+ - 2
43
+ - 9
33
44
  version: 1.2.9
34
- version:
45
+ type: :development
46
+ version_requirements: *id002
35
47
  - !ruby/object:Gem::Dependency
36
48
  name: yard
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
40
51
  requirements:
41
52
  - - ~>
42
53
  - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ - 5
43
57
  version: "0.5"
44
- version:
58
+ type: :development
59
+ version_requirements: *id003
45
60
  description: A datamapper plugin for active_model compliance and thus rails 3 compatibility.
46
61
  email: gamsnjaga [a] gmail [d] com
47
62
  executables: []
@@ -56,6 +71,7 @@ files:
56
71
  - .document
57
72
  - .gitignore
58
73
  - CHANGELOG
74
+ - Gemfile
59
75
  - LICENSE
60
76
  - README.rdoc
61
77
  - Rakefile
@@ -87,18 +103,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
103
  requirements:
88
104
  - - ">="
89
105
  - !ruby/object:Gem::Version
106
+ segments:
107
+ - 0
90
108
  version: "0"
91
- version:
92
109
  required_rubygems_version: !ruby/object:Gem::Requirement
93
110
  requirements:
94
111
  - - ">="
95
112
  - !ruby/object:Gem::Version
113
+ segments:
114
+ - 0
96
115
  version: "0"
97
- version:
98
116
  requirements: []
99
117
 
100
118
  rubyforge_project:
101
- rubygems_version: 1.3.5
119
+ rubygems_version: 1.3.6
102
120
  signing_key:
103
121
  specification_version: 3
104
122
  summary: active_model compliance for datamapper