dci-rails 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/dci-rails.gemspec +8 -8
  3. data/lib/role.rb +12 -3
  4. data/spec/role_spec.rb +8 -12
  5. metadata +12 -14
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/dci-rails.gemspec CHANGED
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{dci-rails}
8
- s.version = "0.1.3"
7
+ s.name = "dci-rails"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nate Jackson"]
12
- s.date = %q{2011-09-19}
13
- s.description = %q{helpers for rails to implement DCI pattern (http://andrzejonsoftware.blogspot.com/2011/02/dci-and-rails.html)}
14
- s.email = %q{nate.d.jackson@gmail.com}
12
+ s.date = "2012-03-27"
13
+ s.description = "helpers for rails to implement DCI pattern (http://andrzejonsoftware.blogspot.com/2011/02/dci-and-rails.html)"
14
+ s.email = "nate.d.jackson@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.rdoc"
@@ -35,11 +35,11 @@ Gem::Specification.new do |s|
35
35
  "spec/role_spec.rb",
36
36
  "spec/spec_helper.rb"
37
37
  ]
38
- s.homepage = %q{http://github.com/njackson/dci-rails}
38
+ s.homepage = "http://github.com/njackson/dci-rails"
39
39
  s.licenses = ["MIT"]
40
40
  s.require_paths = ["lib"]
41
- s.rubygems_version = %q{1.6.2}
42
- s.summary = %q{DCI helpers for Rails}
41
+ s.rubygems_version = "1.8.10"
42
+ s.summary = "DCI helpers for Rails"
43
43
 
44
44
  if s.respond_to? :specification_version then
45
45
  s.specification_version = 3
data/lib/role.rb CHANGED
@@ -5,13 +5,22 @@ module DCI
5
5
  end
6
6
 
7
7
  module ModuleMethods
8
- def extended_metaclass_eval(&block)
9
- (class << self; self; end).instance_eval do
8
+ def extended_singleton_class_eval(&block)
9
+ singleton_class_for(self).instance_eval do
10
10
  define_method("extended") do |obj|
11
- (class << obj; self; end).instance_eval(&block)
11
+ singleton_class_for(obj).instance_eval(&block)
12
12
  end
13
13
  end
14
14
  end
15
+
16
+ private
17
+ def singleton_class_for(obj)
18
+ if obj.respond_to?(:singleton_class)
19
+ obj.singleton_class
20
+ else
21
+ class << obj; self; end
22
+ end
23
+ end
15
24
  end
16
25
  end
17
26
  end
data/spec/role_spec.rb CHANGED
@@ -1,32 +1,28 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- class DCI::TestModel
4
- class << self
5
- attr_accessor :model_class_method_invoked
6
- def model_class_method
7
- self.model_class_method_invoked = true
8
- end
9
- end
10
- end
3
+ class DCI::TestModel; end
11
4
 
12
5
  module DCI::TestRole
13
6
  include DCI::Role
14
7
 
15
- extended_metaclass_eval do
8
+ extended_singleton_class_eval do
16
9
  self.model_class_method
17
10
  end
18
11
  end
19
12
 
20
13
  describe DCI::Role do
21
14
  let(:instance) { DCI::TestModel.new }
15
+ let(:other_instance) { DCI::TestModel.new }
16
+ let(:instance_singleton_class) { class << instance; self; end }
17
+ let(:other_instance_singleton_class) { class << other_instance; self; end }
22
18
 
23
19
  context "mixed into a model class" do
24
20
  describe "#extended_metaclass_eval" do
25
21
  it "invokes the block on the extended object's metaclass" do
26
- instance.extend(DCI::TestRole)
22
+ instance_singleton_class.should_receive(:model_class_method)
23
+ other_instance_singleton_class.should_not_receive(:model_class_method)
27
24
 
28
- (class << instance; self; end).model_class_method_invoked.should be_true
29
- DCI::TestModel.model_class_method_invoked.should be_false
25
+ instance.extend(DCI::TestRole)
30
26
  end
31
27
  end
32
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dci-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-19 00:00:00.000000000 -05:00
13
- default_executable:
12
+ date: 2012-03-27 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
- requirement: &70170204775520 !ruby/object:Gem::Requirement
16
+ requirement: &70238709718080 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: 2.3.0
23
22
  type: :development
24
23
  prerelease: false
25
- version_requirements: *70170204775520
24
+ version_requirements: *70238709718080
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: bundler
28
- requirement: &70170204774960 !ruby/object:Gem::Requirement
27
+ requirement: &70238709717320 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ~>
@@ -33,10 +32,10 @@ dependencies:
33
32
  version: 1.0.0
34
33
  type: :development
35
34
  prerelease: false
36
- version_requirements: *70170204774960
35
+ version_requirements: *70238709717320
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: jeweler
39
- requirement: &70170204774380 !ruby/object:Gem::Requirement
38
+ requirement: &70238709716400 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
@@ -44,10 +43,10 @@ dependencies:
44
43
  version: 1.6.4
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *70170204774380
46
+ version_requirements: *70238709716400
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: rcov
50
- requirement: &70170204773380 !ruby/object:Gem::Requirement
49
+ requirement: &70238709702880 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ! '>='
@@ -55,7 +54,7 @@ dependencies:
55
54
  version: '0'
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *70170204773380
57
+ version_requirements: *70238709702880
59
58
  description: helpers for rails to implement DCI pattern (http://andrzejonsoftware.blogspot.com/2011/02/dci-and-rails.html)
60
59
  email: nate.d.jackson@gmail.com
61
60
  executables: []
@@ -81,7 +80,6 @@ files:
81
80
  - spec/controller/dsl_spec.rb
82
81
  - spec/role_spec.rb
83
82
  - spec/spec_helper.rb
84
- has_rdoc: true
85
83
  homepage: http://github.com/njackson/dci-rails
86
84
  licenses:
87
85
  - MIT
@@ -97,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
95
  version: '0'
98
96
  segments:
99
97
  - 0
100
- hash: 3087653526277293251
98
+ hash: -4550488307404058322
101
99
  required_rubygems_version: !ruby/object:Gem::Requirement
102
100
  none: false
103
101
  requirements:
@@ -106,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
104
  version: '0'
107
105
  requirements: []
108
106
  rubyforge_project:
109
- rubygems_version: 1.6.2
107
+ rubygems_version: 1.8.10
110
108
  signing_key:
111
109
  specification_version: 3
112
110
  summary: DCI helpers for Rails