garnish 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +10 -3
- data/CHANGELOG.rdoc +19 -0
- data/README.rdoc +5 -7
- data/lib/garnish/converter.rb +22 -25
- data/lib/garnish/presenter.rb +3 -6
- data/lib/garnish/presenter/relationships.rb +2 -2
- data/lib/garnish/version.rb +1 -1
- data/spec/README.rdoc +1 -1
- metadata +18 -7
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
0.0.7 (March 11, 2013)
|
2
|
+
|
3
|
+
* Fixed deprecation warnings.
|
4
|
+
* Fixed broken image.
|
5
|
+
* Removed gemnasium dependency.
|
6
|
+
* Added code climate.
|
7
|
+
* Tested on Ruby 2.0.0
|
8
|
+
|
9
|
+
0.0.6.1 (March 4, 2012)
|
10
|
+
|
11
|
+
* Added support for jruby.
|
12
|
+
* Updated readme.
|
13
|
+
* Updated spec readme.
|
14
|
+
* Added dependency status via Gemnasium.
|
15
|
+
|
16
|
+
0.0.6 (March 3, 2012)
|
17
|
+
|
18
|
+
* Added support for Ruby 1.8.7, REE & Rubinius
|
19
|
+
|
1
20
|
0.0.5 (February 29, 2012)
|
2
21
|
|
3
22
|
* Remove cruft from Guardfile so Guard works again. Fix broken tests from last
|
data/README.rdoc
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
http://www.brianpearce.ca/images/garnish.png
|
2
|
+
|
3
|
+
{<img src="https://secure.travis-ci.org/brianp/garnish.png" alt="Build Status" />}[http://travis-ci.org/brianp/garnish] {<img src="https://codeclimate.com/github/brianp/garnish.png" />}[https://codeclimate.com/github/brianp/garnish]
|
2
4
|
|
3
5
|
RDocs[http://rdoc.info/projects/brianp/garnish]
|
4
6
|
|
@@ -15,7 +17,8 @@ Garnish is a Presenter / Decorator pattern for models in Rails. It gives a home
|
|
15
17
|
Garnish Has been tested with
|
16
18
|
|
17
19
|
* Rails 3
|
18
|
-
* Ruby 1.9.2, 1.9.3
|
20
|
+
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, REE, JRuby, Rubinius
|
21
|
+
* ActiveRecord, Mongoid
|
19
22
|
|
20
23
|
== Installation
|
21
24
|
|
@@ -23,11 +26,6 @@ In <b>Rails 3</b>, add this to your Gemfile and run the +bundle+ command.
|
|
23
26
|
|
24
27
|
gem "garnish"
|
25
28
|
|
26
|
-
Alternatively, you can install it as a plugin.
|
27
|
-
|
28
|
-
rails plugin install git://github.com/brianp/garnish.git
|
29
|
-
|
30
|
-
|
31
29
|
== Getting Started
|
32
30
|
|
33
31
|
A lot of magic happens with Garnish in an attempt to make things incredibly simple for you.
|
data/lib/garnish/converter.rb
CHANGED
@@ -2,39 +2,36 @@ module Garnish
|
|
2
2
|
module Converter
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
|
5
|
+
def module_exists?(class_name)
|
6
|
+
klass = Module.const_get(class_name)
|
7
|
+
return klass.is_a?(Module)
|
8
|
+
rescue NameError
|
9
|
+
return false
|
10
|
+
end
|
11
|
+
|
12
|
+
def convert(record, view = nil)
|
13
|
+
view ||= self.template
|
6
14
|
|
7
|
-
|
8
|
-
klass =
|
9
|
-
|
10
|
-
|
11
|
-
return false
|
15
|
+
if record.respond_to?(:each)
|
16
|
+
klass = record.first.class
|
17
|
+
else
|
18
|
+
klass = record.class
|
12
19
|
end
|
13
20
|
|
14
|
-
|
15
|
-
view ||= self.template
|
21
|
+
presenter_name = "#{klass.to_s}Presenter"
|
16
22
|
|
23
|
+
if module_exists?(presenter_name.to_sym)
|
17
24
|
if record.respond_to?(:each)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
presenter_name = "#{klass.to_s}Presenter"
|
24
|
-
|
25
|
-
if module_exists?(presenter_name.to_sym)
|
26
|
-
if record.respond_to?(:each)
|
27
|
-
record.map do |v|
|
28
|
-
v.extend(presenter_name.constantize)
|
29
|
-
v.template = view
|
30
|
-
end
|
31
|
-
else
|
32
|
-
record.extend(presenter_name.constantize)
|
33
|
-
record.template = view
|
25
|
+
record.map do |v|
|
26
|
+
v.extend(presenter_name.constantize)
|
27
|
+
v.template = view
|
34
28
|
end
|
29
|
+
else
|
30
|
+
record.extend(presenter_name.constantize)
|
31
|
+
record.template = view
|
35
32
|
end
|
36
|
-
|
37
33
|
end
|
34
|
+
|
38
35
|
end
|
39
36
|
|
40
37
|
end
|
data/lib/garnish/presenter.rb
CHANGED
@@ -12,13 +12,10 @@ module Garnish
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
protected
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
def method_missing(method, *args, &block)
|
20
|
-
self.template.send(method, *args, &block) unless @template.blank?
|
21
|
-
end
|
17
|
+
def method_missing(method, *args, &block)
|
18
|
+
self.template.send(method, *args, &block) unless @template.blank?
|
22
19
|
end
|
23
20
|
|
24
21
|
end
|
@@ -3,13 +3,13 @@ module Garnish
|
|
3
3
|
module Relationships
|
4
4
|
|
5
5
|
def self.extended(base)
|
6
|
-
base.extend Garnish::Converter
|
6
|
+
base.extend Garnish::Converter
|
7
7
|
base.class_eval do
|
8
8
|
relationships = Garnish::ModelAdapters::AbstractAdapter.adapter_class.defined_relationships(self)
|
9
9
|
|
10
10
|
relationships.map do |key|
|
11
11
|
alias_method "#{key}_orig".to_sym, key.to_sym
|
12
|
-
define_method "#{key}" do
|
12
|
+
define_method "#{key}" do |*rest|
|
13
13
|
records = self.send("#{key}_orig")
|
14
14
|
Garnish::Collection.new(records, template)
|
15
15
|
end
|
data/lib/garnish/version.rb
CHANGED
data/spec/README.rdoc
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: garnish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rspec
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,7 +37,12 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
description: Provides an easy to use and transparent system for implementing the Decorator
|
37
47
|
Pattern
|
38
48
|
email:
|
@@ -90,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
100
|
version: '0'
|
91
101
|
requirements: []
|
92
102
|
rubyforge_project: garnish
|
93
|
-
rubygems_version: 1.8.
|
103
|
+
rubygems_version: 1.8.23
|
94
104
|
signing_key:
|
95
105
|
specification_version: 3
|
96
106
|
summary: Provides the decorator design pattern
|
@@ -103,3 +113,4 @@ test_files:
|
|
103
113
|
- spec/garnish/presenter_spec.rb
|
104
114
|
- spec/garnish/responder_spec.rb
|
105
115
|
- spec/spec_helper.rb
|
116
|
+
has_rdoc:
|