respondie 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Gemfile
2
+ source :gemcutter
3
+ #
4
+ gem "rails", ">= 3.0.0"
5
+
6
+ group :test do
7
+ gem "rspec-rails", ">= 2.0.0.beta.19"
8
+ gem "rcov"
9
+ end
@@ -0,0 +1,91 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.0)
6
+ actionpack (= 3.0.0)
7
+ mail (~> 2.2.5)
8
+ actionpack (3.0.0)
9
+ activemodel (= 3.0.0)
10
+ activesupport (= 3.0.0)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4.1)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.12)
16
+ rack-test (~> 0.5.4)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.0)
19
+ activesupport (= 3.0.0)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.4.1)
22
+ activerecord (3.0.0)
23
+ activemodel (= 3.0.0)
24
+ activesupport (= 3.0.0)
25
+ arel (~> 1.0.0)
26
+ tzinfo (~> 0.3.23)
27
+ activeresource (3.0.0)
28
+ activemodel (= 3.0.0)
29
+ activesupport (= 3.0.0)
30
+ activesupport (3.0.0)
31
+ arel (1.0.1)
32
+ activesupport (~> 3.0.0)
33
+ builder (2.1.2)
34
+ diff-lcs (1.1.2)
35
+ erubis (2.6.6)
36
+ abstract (>= 1.0.0)
37
+ i18n (0.4.1)
38
+ mail (2.2.5)
39
+ activesupport (>= 2.3.6)
40
+ mime-types
41
+ treetop (>= 1.4.5)
42
+ mime-types (1.16)
43
+ nokogiri (1.4.3.1)
44
+ polyglot (0.3.1)
45
+ rack (1.2.1)
46
+ rack-mount (0.6.13)
47
+ rack (>= 1.0.0)
48
+ rack-test (0.5.6)
49
+ rack (>= 1.0)
50
+ rails (3.0.0)
51
+ actionmailer (= 3.0.0)
52
+ actionpack (= 3.0.0)
53
+ activerecord (= 3.0.0)
54
+ activeresource (= 3.0.0)
55
+ activesupport (= 3.0.0)
56
+ bundler (~> 1.0.0)
57
+ railties (= 3.0.0)
58
+ railties (3.0.0)
59
+ actionpack (= 3.0.0)
60
+ activesupport (= 3.0.0)
61
+ rake (>= 0.8.4)
62
+ thor (~> 0.14.0)
63
+ rake (0.8.7)
64
+ rcov (0.9.8)
65
+ rspec (2.0.0.beta.19)
66
+ rspec-core (= 2.0.0.beta.19)
67
+ rspec-expectations (= 2.0.0.beta.19)
68
+ rspec-mocks (= 2.0.0.beta.19)
69
+ rspec-core (2.0.0.beta.19)
70
+ rspec-expectations (2.0.0.beta.19)
71
+ diff-lcs (>= 1.1.2)
72
+ rspec-mocks (2.0.0.beta.19)
73
+ rspec-rails (2.0.0.beta.19)
74
+ rspec (= 2.0.0.beta.19)
75
+ webrat (>= 0.7.2.beta.1)
76
+ thor (0.14.0)
77
+ treetop (1.4.8)
78
+ polyglot (>= 0.3.1)
79
+ tzinfo (0.3.23)
80
+ webrat (0.7.2.beta.1)
81
+ nokogiri (>= 1.2.0)
82
+ rack (>= 1.0)
83
+ rack-test (>= 0.5.3)
84
+
85
+ PLATFORMS
86
+ ruby
87
+
88
+ DEPENDENCIES
89
+ rails (>= 3.0.0)
90
+ rcov
91
+ rspec-rails (>= 2.0.0.beta.19)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 guilherme silveira
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = respondie
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 guilherme silveira. See LICENSE for details.
@@ -0,0 +1,42 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "respondie"
8
+ gem.summary = %Q{A helper to avoid class multiplicity in inheriting responders.}
9
+ gem.description = %Q{A helper to avoid class multiplicity in inheriting responders.}
10
+ gem.email = "guilherme.silveira@caelum.com.br"
11
+ gem.homepage = "http://github.com/caelum/respondie"
12
+ gem.authors = ["guilherme silveira"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.version = "0.9.0"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'rspec'
23
+ require 'rspec/core'
24
+ require 'rspec/core/rake_task'
25
+ RSpec::Core::RakeTask.new(:spec) do |t|
26
+ # t.spec_files = FileList['spec_*.rb']
27
+ t.rspec_opts = ['--colour', '--format progress']
28
+ end
29
+
30
+ task :spec => :check_dependencies
31
+
32
+ task :default => :spec
33
+
34
+ require 'rake/rdoctask'
35
+ Rake::RDocTask.new do |rdoc|
36
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
37
+
38
+ rdoc.rdoc_dir = 'rdoc'
39
+ rdoc.title = "respondie #{version}"
40
+ rdoc.rdoc_files.include('README*')
41
+ rdoc.rdoc_files.include('lib/**/*.rb')
42
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,15 @@
1
+ require 'action_controller'
2
+
3
+ module Respondie
4
+
5
+ def use_trait(&block)
6
+ Respondie::Builder.new("Respondie::Trait::$trait$", self).instance_eval(&block)
7
+ end
8
+
9
+ alias_method :use_traits, :use_trait
10
+
11
+ end
12
+
13
+ ActionController::Base.extend Respondie
14
+
15
+ require 'respondie/builder'
@@ -0,0 +1,22 @@
1
+ class Respondie::Builder
2
+
3
+ def initialize(pattern, controller)
4
+ @pattern = pattern
5
+ custom = Class.new(ActionController::Responder)
6
+ controller.responder = custom
7
+ @responder = controller.responder
8
+ end
9
+
10
+ def method_missing(sym)
11
+ trait sym
12
+ end
13
+
14
+ private
15
+
16
+ def trait(sym)
17
+ type = @pattern.gsub(/\$trait\$/, sym.to_s.camelize)
18
+ @responder.send :include, type.constantize
19
+ self
20
+ end
21
+
22
+ end
@@ -0,0 +1,60 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{respondie}
8
+ s.version = "0.9.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["guilherme silveira"]
12
+ s.date = %q{2010-10-26}
13
+ s.description = %q{A helper to avoid class multiplicity in inheriting responders.}
14
+ s.email = %q{guilherme.silveira@caelum.com.br}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/respondie.rb",
29
+ "lib/respondie/builder.rb",
30
+ "respondie.gemspec",
31
+ "spec/respondie/builder_spec.rb",
32
+ "spec/respondie_spec.rb",
33
+ "spec/spec.opts",
34
+ "spec/spec_helper.rb"
35
+ ]
36
+ s.homepage = %q{http://github.com/caelum/respondie}
37
+ s.rdoc_options = ["--charset=UTF-8"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = %q{1.3.7}
40
+ s.summary = %q{A helper to avoid class multiplicity in inheriting responders.}
41
+ s.test_files = [
42
+ "spec/respondie/builder_spec.rb",
43
+ "spec/respondie_spec.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+
47
+ if s.respond_to? :specification_version then
48
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
+ s.specification_version = 3
50
+
51
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
53
+ else
54
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
58
+ end
59
+ end
60
+
@@ -0,0 +1,24 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ class ProductsController
4
+ attr_accessor :responder
5
+ end
6
+ module Respondie
7
+ module Trait
8
+ module Cute
9
+ def is_cute?
10
+ true
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ describe Respondie::Builder do
17
+
18
+ it "should include a type into a responder" do
19
+ controller = ProductsController.new
20
+ Respondie::Builder.new("Respondie::Trait::$trait$", controller).instance_eval { cute }
21
+ controller.responder.instance_method(:is_cute?).should_not be_nil
22
+ end
23
+
24
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+
6
+ class MyController < ApplicationController
7
+ end
8
+
9
+ describe Respondie do
10
+
11
+ it "should enhance ActionController with its cute method" do
12
+ MyController.should respond_to(:use_trait)
13
+ end
14
+
15
+ it "should enhance ActionController with its cute plural method" do
16
+ MyController.should respond_to(:use_traits)
17
+ end
18
+
19
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'respondie'
4
+ require 'rspec'
5
+ require 'rspec/autorun'
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: respondie
3
+ version: !ruby/object:Gem::Version
4
+ hash: 59
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 0
10
+ version: 0.9.0
11
+ platform: ruby
12
+ authors:
13
+ - guilherme silveira
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-26 00:00:00 -02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: A helper to avoid class multiplicity in inheriting responders.
38
+ email: guilherme.silveira@caelum.com.br
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - LICENSE
45
+ - README.rdoc
46
+ files:
47
+ - .document
48
+ - .gitignore
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE
52
+ - README.rdoc
53
+ - Rakefile
54
+ - VERSION
55
+ - lib/respondie.rb
56
+ - lib/respondie/builder.rb
57
+ - respondie.gemspec
58
+ - spec/respondie/builder_spec.rb
59
+ - spec/respondie_spec.rb
60
+ - spec/spec.opts
61
+ - spec/spec_helper.rb
62
+ has_rdoc: true
63
+ homepage: http://github.com/caelum/respondie
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options:
68
+ - --charset=UTF-8
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ requirements: []
90
+
91
+ rubyforge_project:
92
+ rubygems_version: 1.3.7
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: A helper to avoid class multiplicity in inheriting responders.
96
+ test_files:
97
+ - spec/respondie/builder_spec.rb
98
+ - spec/respondie_spec.rb
99
+ - spec/spec_helper.rb