resubject 0.0.3 → 0.0.4
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/.yardopts +2 -0
- data/CHANGELOG.md +18 -0
- data/README.md +1 -1
- data/lib/resubject/naming.rb +6 -4
- data/lib/resubject/version.rb +1 -1
- data/spec/resubject/naming_spec.rb +9 -0
- metadata +6 -4
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
data/lib/resubject/naming.rb
CHANGED
@@ -6,9 +6,10 @@ module Resubject
|
|
6
6
|
#
|
7
7
|
# @example
|
8
8
|
#
|
9
|
-
# Naming.presenter_for :post
|
10
|
-
# Naming.presenter_for "post"
|
11
|
-
# Naming.presenter_for Post.new
|
9
|
+
# Naming.presenter_for :post # => PostPresenter
|
10
|
+
# Naming.presenter_for "post" # => PostPresenter
|
11
|
+
# Naming.presenter_for Post.new # => PostPresenter
|
12
|
+
# Naming.presenter_for Ns::Post.new # => Ns::PostPresenter
|
12
13
|
#
|
13
14
|
# @param [Object, String, Symbol] presentable the reference object
|
14
15
|
# @return [Presenter] the related presenter class based on the object
|
@@ -24,7 +25,8 @@ module Resubject
|
|
24
25
|
|
25
26
|
presenter = "#{klass.camelize}Presenter"
|
26
27
|
|
27
|
-
|
28
|
+
# Gets each constant in the namespace
|
29
|
+
presenter.split('::').inject(Object) { |ns, cons| ns.const_get(cons) }
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
data/lib/resubject/version.rb
CHANGED
@@ -23,4 +23,13 @@ describe Resubject::Naming do
|
|
23
23
|
|
24
24
|
expect(presenter).to eq BoxPresenter
|
25
25
|
end
|
26
|
+
|
27
|
+
it 'gets namespaced constants' do
|
28
|
+
stub_const 'Namespaced', Class.new
|
29
|
+
stub_const 'Namespaced::BoxPresenter', Class.new
|
30
|
+
|
31
|
+
presenter = Resubject::Naming.presenter_for "Namespaced::Box"
|
32
|
+
|
33
|
+
expect(presenter).to eq Namespaced::BoxPresenter
|
34
|
+
end
|
26
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resubject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
type: :runtime
|
@@ -87,6 +87,8 @@ files:
|
|
87
87
|
- .gitignore
|
88
88
|
- .rspec
|
89
89
|
- .travis.yml
|
90
|
+
- .yardopts
|
91
|
+
- CHANGELOG.md
|
90
92
|
- Gemfile
|
91
93
|
- IDEAS.md
|
92
94
|
- LICENSE.txt
|
@@ -122,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
124
|
segments:
|
123
125
|
- 0
|
124
126
|
version: '0'
|
125
|
-
hash:
|
127
|
+
hash: -3489835523721177517
|
126
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
129
|
none: false
|
128
130
|
requirements:
|
@@ -131,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
133
|
segments:
|
132
134
|
- 0
|
133
135
|
version: '0'
|
134
|
-
hash:
|
136
|
+
hash: -3489835523721177517
|
135
137
|
requirements: []
|
136
138
|
rubyforge_project:
|
137
139
|
rubygems_version: 1.8.24
|