decent_decoration 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in decent_decorate.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Tomasz Pewiński
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # DecentDecoration
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'decent_decoration'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install decent_decoration
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'decent_decoration/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "decent_decoration"
8
+ gem.version = DecentDecoration::VERSION
9
+ gem.authors = ["Tomasz Pewiński"]
10
+ gem.email = ["pewniak747@gmail.com"]
11
+ gem.description = %q{Use decent_exposure with decorators (e.g. Draper)}
12
+ gem.summary = %q{Use decent_exposure with decorators (e.g. Draper)}
13
+ gem.homepage = "https://github.com/pewniak747/decent_decoration"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_runtime_dependency 'decent_exposure', '> 0'
20
+ gem.add_development_dependency 'rspec', '~> 2.7'
21
+ gem.add_development_dependency 'rspec-rails', '~> 2.7'
22
+ gem.add_development_dependency 'actionpack', '~> 3.1'
23
+ gem.add_development_dependency 'activesupport', '~> 3.1'
24
+ end
@@ -0,0 +1,6 @@
1
+ require "decent_decoration/decorate"
2
+ require "decent_decoration/version"
3
+
4
+ ActiveSupport.on_load(:action_controller) do
5
+ extend DecentDecoration::Decorate
6
+ end
@@ -0,0 +1,13 @@
1
+ module DecentDecoration
2
+ module Decorate
3
+ def decorate(name, options = {}, &block)
4
+ decorator_class = "#{name.to_s.singularize.classify}Decorator".constantize
5
+ decorated_name = name.to_sym
6
+ undecorated_name = "undecorated_#{name}".to_sym
7
+
8
+ options[:model] ||= decorated_name
9
+ expose(undecorated_name, options, &block)
10
+ expose(decorated_name) { decorator_class.new(public_send(undecorated_name)) }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module DecentDecoration
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ require 'fixtures/fake_rails_application'
2
+
3
+ class Conference
4
+ attr_accessor :name, :location
5
+ extend ActiveModel::Naming
6
+ def initialize(attrs={})
7
+ self.attributes = attrs
8
+ end
9
+ def self.find(id)
10
+ new if id
11
+ end
12
+ def attributes=(attributes)
13
+ attributes.each { |k,v| send("#{k}=", v) }
14
+ end
15
+ end
16
+
17
+ class ConferencesController < ActionController::Base
18
+ include Rails.application.routes.url_helpers
19
+
20
+ decorate(:conference)
21
+
22
+ def show
23
+ render :text => "foo"
24
+ end
25
+
26
+ def new
27
+ render :text => "foo"
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ require 'delegate'
2
+
3
+ class ConferenceDecorator < SimpleDelegator
4
+ def decorated_object
5
+ __getobj__
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ require 'active_support/all'
2
+
3
+ require 'decent_exposure'
4
+ require 'decent_decoration'
5
+
6
+ require 'action_controller'
7
+ require 'action_dispatch'
8
+ require 'active_model'
9
+
10
+ module Rails
11
+ class App
12
+ def env_config; {} end
13
+ def routes
14
+ return @routes if defined?(@routes)
15
+ @routes = ActionDispatch::Routing::RouteSet.new
16
+ @routes.draw do
17
+ get '/conferences/new' => "conferences#new"
18
+ get '/conference/(:id)' => "conferences#show"
19
+ end
20
+ @routes
21
+ end
22
+ def call(*args)
23
+ routes.call(*args)
24
+ end
25
+ end
26
+ def self.application
27
+ @app ||= App.new
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ require 'fixtures/decorators'
2
+ require 'fixtures/controllers'
3
+ require 'rspec/rails'
4
+
5
+ describe ConferencesController, type: :controller do
6
+ it "should be a decorator" do
7
+ get '/conference/RuPy'
8
+ controller.conference.should be_instance_of(ConferenceDecorator)
9
+ end
10
+
11
+ it "should have decorated conference" do
12
+ get '/conference/RuPy'
13
+ controller.conference.decorated_object.should be_instance_of(Conference)
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: decent_decoration
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tomasz Pewiński
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: decent_exposure
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>'
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>'
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.7'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.7'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: actionpack
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '3.1'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.1'
78
+ - !ruby/object:Gem::Dependency
79
+ name: activesupport
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '3.1'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '3.1'
94
+ description: Use decent_exposure with decorators (e.g. Draper)
95
+ email:
96
+ - pewniak747@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - LICENSE.txt
104
+ - README.md
105
+ - Rakefile
106
+ - decent_decoration.gemspec
107
+ - lib/decent_decoration.rb
108
+ - lib/decent_decoration/decorate.rb
109
+ - lib/decent_decoration/version.rb
110
+ - spec/fixtures/controllers.rb
111
+ - spec/fixtures/decorators.rb
112
+ - spec/fixtures/fake_rails_application.rb
113
+ - spec/integration/rails_application_spec.rb
114
+ homepage: https://github.com/pewniak747/decent_decoration
115
+ licenses: []
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 1.8.24
135
+ signing_key:
136
+ specification_version: 3
137
+ summary: Use decent_exposure with decorators (e.g. Draper)
138
+ test_files:
139
+ - spec/fixtures/controllers.rb
140
+ - spec/fixtures/decorators.rb
141
+ - spec/fixtures/fake_rails_application.rb
142
+ - spec/integration/rails_application_spec.rb
143
+ has_rdoc: