resubject 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ -
2
+ CHANGELOG.md IDEAS.md LICENSE.txt
data/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # 0.0.4
2
+
3
+ - bugfixes
4
+ - Find the presenter in the current object's namespace
5
+
6
+ # 0.0.3
7
+
8
+ - Improve docs
9
+
10
+ # 0.0.2
11
+
12
+ - Big refactoring
13
+ - Add `currency` helper
14
+ - Add `presents` helper
15
+
16
+ # 0.0.1
17
+
18
+ - Initial commit
data/README.md CHANGED
@@ -10,7 +10,7 @@ Uber simple presenters using Ruby's SimpleDelegator.
10
10
  Add this line to your application's Gemfile:
11
11
 
12
12
  ```ruby
13
- gem 'resubject', '~> 0.0.3'
13
+ gem 'resubject', '~> 0.0.4'
14
14
  ```
15
15
 
16
16
  And then execute:
@@ -6,9 +6,10 @@ module Resubject
6
6
  #
7
7
  # @example
8
8
  #
9
- # Naming.presenter_for :post # => PostPresenter
10
- # Naming.presenter_for "post" # => PostPresenter
11
- # Naming.presenter_for Post.new # => PostPresenter
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
- Object.const_get presenter
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
@@ -1,3 +1,3 @@
1
1
  module Resubject
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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.3
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-06 00:00:00.000000000 Z
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: 3846405687038123926
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: 3846405687038123926
136
+ hash: -3489835523721177517
135
137
  requirements: []
136
138
  rubyforge_project:
137
139
  rubygems_version: 1.8.24