r3_plugin_toolbox 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.document +0 -0
  2. data/.gitignore +0 -0
  3. data/.rspec +0 -0
  4. data/LICENSE +0 -0
  5. data/README.markdown +11 -6
  6. data/Rakefile +1 -0
  7. data/VERSION +1 -1
  8. data/config/database.yml +0 -0
  9. data/lib/r3_plugin_toolbox.rb +1 -1
  10. data/lib/r3_plugin_toolbox/engine.rb +77 -0
  11. data/lib/r3_plugin_toolbox/extender.rb +72 -0
  12. data/lib/r3_plugin_toolbox/extender/load_handler.rb +39 -0
  13. data/lib/r3_plugin_toolbox/extender/util.rb +64 -0
  14. data/lib/r3_plugin_toolbox/main.rb +5 -0
  15. data/lib/r3_plugin_toolbox/railtie.rb +85 -0
  16. data/lib/r3_plugin_toolbox/rspec/config.rb +14 -0
  17. data/lib/r3_plugin_toolbox/rspec/macro.rb +33 -0
  18. data/lib/r3_plugin_toolbox/rspec/matchers/be_extended_with.rb +66 -0
  19. data/lib/r3_plugin_toolbox/shortcuts.rb +11 -0
  20. data/log/development.log +0 -0
  21. data/r3_plugin_toolbox.gemspec +30 -16
  22. data/spec/fixtures/extension_modules.rb +29 -0
  23. data/spec/r3_plugin_toolbox/engine_spec.rb +17 -0
  24. data/spec/{plugin_toolbox → r3_plugin_toolbox/extender}/extend_view_content_spec.rb +5 -2
  25. data/spec/{plugin_toolbox → r3_plugin_toolbox/extender}/extender_action_spec.rb +4 -4
  26. data/spec/{plugin_toolbox → r3_plugin_toolbox/extender}/extender_i18n_spec.rb +2 -2
  27. data/spec/{plugin_toolbox → r3_plugin_toolbox}/extender_spec.rb +3 -3
  28. data/spec/r3_plugin_toolbox/railtie_spec.rb +16 -0
  29. data/spec/r3_plugin_toolbox/shortcuts_spec.rb +54 -0
  30. data/spec/spec_helper.rb +3 -32
  31. data/wiki/add_rake_tasks.markdown +0 -0
  32. data/wiki/engine.markdown +0 -0
  33. data/wiki/how_to_guide.markdown +0 -0
  34. metadata +49 -21
  35. data/lib/plugin_toolbox/extender.rb +0 -65
  36. data/lib/plugin_toolbox/loader.rb +0 -32
  37. data/lib/plugin_toolbox/rspec/config.rb +0 -12
  38. data/lib/plugin_toolbox/rspec/macro.rb +0 -32
  39. data/lib/plugin_toolbox/rspec/matchers/be_extended_with.rb +0 -64
  40. data/lib/plugin_toolbox/util.rb +0 -62
  41. data/rails3_plugin_toolbox.gemspec +0 -78
File without changes
data/wiki/engine.markdown CHANGED
File without changes
File without changes
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 5
9
- version: 0.3.5
8
+ - 6
9
+ version: 0.3.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -33,9 +33,26 @@ dependencies:
33
33
  type: :development
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: rails
36
+ name: rspec
37
37
  prerelease: false
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 0
46
+ - 0
47
+ - beta
48
+ - 19
49
+ version: 2.0.0.beta.19
50
+ type: :development
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: rails
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
39
56
  none: false
40
57
  requirements:
41
58
  - - ~>
@@ -46,11 +63,11 @@ dependencies:
46
63
  - 0
47
64
  version: 3.0.0
48
65
  type: :runtime
49
- version_requirements: *id002
66
+ version_requirements: *id003
50
67
  - !ruby/object:Gem::Dependency
51
68
  name: require_all
52
69
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
70
+ requirement: &id004 !ruby/object:Gem::Requirement
54
71
  none: false
55
72
  requirements:
56
73
  - - ~>
@@ -61,7 +78,7 @@ dependencies:
61
78
  - 0
62
79
  version: 1.1.0
63
80
  type: :runtime
64
- version_requirements: *id003
81
+ version_requirements: *id004
65
82
  description: Provides a more intuitive DSL for Rails 3 plugin configuration and a specialized RSpec 2 matcher. Makes it much easier to develop Rails 3 plugins!
66
83
  email: kmandrup@gmail.com
67
84
  executables: []
@@ -80,20 +97,27 @@ files:
80
97
  - Rakefile
81
98
  - VERSION
82
99
  - config/database.yml
83
- - lib/plugin_toolbox/extender.rb
84
- - lib/plugin_toolbox/loader.rb
85
- - lib/plugin_toolbox/rspec/config.rb
86
- - lib/plugin_toolbox/rspec/macro.rb
87
- - lib/plugin_toolbox/rspec/matchers/be_extended_with.rb
88
- - lib/plugin_toolbox/util.rb
89
100
  - lib/r3_plugin_toolbox.rb
101
+ - lib/r3_plugin_toolbox/engine.rb
102
+ - lib/r3_plugin_toolbox/extender.rb
103
+ - lib/r3_plugin_toolbox/extender/load_handler.rb
104
+ - lib/r3_plugin_toolbox/extender/util.rb
105
+ - lib/r3_plugin_toolbox/main.rb
106
+ - lib/r3_plugin_toolbox/railtie.rb
107
+ - lib/r3_plugin_toolbox/rspec/config.rb
108
+ - lib/r3_plugin_toolbox/rspec/macro.rb
109
+ - lib/r3_plugin_toolbox/rspec/matchers/be_extended_with.rb
110
+ - lib/r3_plugin_toolbox/shortcuts.rb
90
111
  - log/development.log
91
112
  - r3_plugin_toolbox.gemspec
92
- - rails3_plugin_toolbox.gemspec
93
- - spec/plugin_toolbox/extend_view_content_spec.rb
94
- - spec/plugin_toolbox/extender_action_spec.rb
95
- - spec/plugin_toolbox/extender_i18n_spec.rb
96
- - spec/plugin_toolbox/extender_spec.rb
113
+ - spec/fixtures/extension_modules.rb
114
+ - spec/r3_plugin_toolbox/engine_spec.rb
115
+ - spec/r3_plugin_toolbox/extender/extend_view_content_spec.rb
116
+ - spec/r3_plugin_toolbox/extender/extender_action_spec.rb
117
+ - spec/r3_plugin_toolbox/extender/extender_i18n_spec.rb
118
+ - spec/r3_plugin_toolbox/extender_spec.rb
119
+ - spec/r3_plugin_toolbox/railtie_spec.rb
120
+ - spec/r3_plugin_toolbox/shortcuts_spec.rb
97
121
  - spec/spec_helper.rb
98
122
  - wiki/add_rake_tasks.markdown
99
123
  - wiki/engine.markdown
@@ -131,8 +155,12 @@ signing_key:
131
155
  specification_version: 3
132
156
  summary: Toolbox to facilitate Rails 3 plugin development
133
157
  test_files:
134
- - spec/plugin_toolbox/extend_view_content_spec.rb
135
- - spec/plugin_toolbox/extender_action_spec.rb
136
- - spec/plugin_toolbox/extender_i18n_spec.rb
137
- - spec/plugin_toolbox/extender_spec.rb
158
+ - spec/fixtures/extension_modules.rb
159
+ - spec/r3_plugin_toolbox/engine_spec.rb
160
+ - spec/r3_plugin_toolbox/extender/extend_view_content_spec.rb
161
+ - spec/r3_plugin_toolbox/extender/extender_action_spec.rb
162
+ - spec/r3_plugin_toolbox/extender/extender_i18n_spec.rb
163
+ - spec/r3_plugin_toolbox/extender_spec.rb
164
+ - spec/r3_plugin_toolbox/railtie_spec.rb
165
+ - spec/r3_plugin_toolbox/shortcuts_spec.rb
138
166
  - spec/spec_helper.rb
@@ -1,65 +0,0 @@
1
- require 'plugin_toolbox/util'
2
-
3
- module Rails3
4
- class PluginExtender
5
- include LoadHandler
6
-
7
- def initialize &block
8
- if block
9
- block.arity < 1 ? self.instance_eval(&block) : block.call(self)
10
- end
11
- end
12
-
13
- # load after: [:initialize, :configuration, :eager_load]
14
- def extend_rails(type, &block)
15
- on_load(type, &block)
16
- end
17
-
18
-
19
- # convenience method to extend with multiple modules all within the same base module
20
- def extend_from_module base_name, *module_names, options
21
- raise ArgumentError, "You must specify an options Hash as the last argument for #extend_from_module" if !options.kind_of? Hash
22
- module_names.each do |name|
23
- extend_with get_constant(base_name, name), options
24
- end
25
- end
26
-
27
- def extend_with *module_names, options
28
- raise ArgumentError, "You must specify an options Hash as the last argument for #extend_with" if !options.kind_of? Hash
29
- type = options[:in]
30
- raise ArgumentError, "You must specify an :in option to indicate which Rails 3 component base class to extend with #{module_names}" if !type
31
- module_names.each do |name|
32
- extend! name, type
33
- end
34
- end
35
-
36
- module DSL
37
- include Rails3::PluginExtender::LoadHandler
38
-
39
- def extend_from_module base_name, *module_names
40
- module_names.each do |name|
41
- include get_constant(base_name, name)
42
- end
43
- end
44
-
45
- def extend_with *module_names
46
- module_names.each do |name|
47
- include name
48
- end
49
- end
50
- alias_method :with, :extend_with
51
- end
52
-
53
- protected
54
-
55
- def extend! module_name, type
56
- do_extend! get_module(module_name), get_load_type(type.to_sym)
57
- end
58
-
59
- def do_extend! module_name, type
60
- ActiveSupport.on_load(type) do
61
- include module_name
62
- end
63
- end
64
- end
65
- end
@@ -1,32 +0,0 @@
1
- module Rails3
2
- class PluginExtender
3
- module LoadHandler
4
- include Rails3::PluginExtender::Util
5
-
6
- def before type, &block
7
- type = type.to_sym
8
- raise ArgumentError, "#{type} is not a valid before hook" if !valid_before_hook? type
9
- load_handling :"before_#{type}", &block
10
- end
11
-
12
- def after type, &block
13
- type = type.to_sym
14
- raise ArgumentError, "#{type} is not a valid after hook" if !valid_after_hook? type
15
- load_handling :"after_#{type}", &block
16
- end
17
-
18
- def on_load type, &block
19
- type = get_load_type type
20
- raise ArgumentError, "#{type} is not a valid load hook" if !valid_load_hook? type
21
- load_handling type, &block
22
- end
23
-
24
- def load_handling type, &block
25
- ActiveSupport.on_load type do
26
- extend Rails3::PluginExtender::DSL
27
- instance_eval(&block)
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,12 +0,0 @@
1
- require 'rspec'
2
-
3
- RSpec.configure do |config|
4
- config.include Rails3::PluginExtender::Matchers
5
- config.extend Rails3::PluginExtender::Macro
6
- end
7
-
8
- module RSpec::Core
9
- class ExampleGroup
10
- include Rails3::PluginExtender::Macro
11
- end
12
- end
@@ -1,32 +0,0 @@
1
- module Rails3
2
- class PluginExtender
3
- module Macro
4
- class << self
5
- include Rails3::PluginExtender::Util
6
- end
7
-
8
- MACRO = Rails3::PluginExtender::Macro
9
-
10
- def after_init component, &block
11
- type = MACRO.get_load_type component
12
- Rails3::PluginExtender.new do
13
- extend_rails type do
14
- after :initialize do
15
- yield self
16
- end
17
- end
18
- end
19
- end # def
20
-
21
- def init_app_railties app_name, *railties
22
- app = "#{app_name.to_s.camelize}::Application".constantize
23
- app.initialize!
24
- railties.each do |railtie|
25
- MACRO.get_base_class(railtie).constantize
26
- end
27
- end
28
-
29
- end
30
- end
31
- end
32
-
@@ -1,64 +0,0 @@
1
- module Rails3
2
- class PluginExtender
3
- module Matchers
4
- class BeExtendedWith
5
- include Rails3::PluginExtender::Util
6
-
7
- attr_reader :methods, :module_const, :rails_const, :submodules, :cause, :rails_const_name, :bad_const
8
-
9
- def initialize(module_const, submodules=nil)
10
- @module_const = module_const
11
- raise ArgumentError, "List of submodules must be given as a collection of Symbols or Strings" if submodules && !submodules.respond_to?(:flatten)
12
- @submodules = submodules.flatten if submodules
13
- end
14
-
15
- def matches? type
16
- begin
17
- @rails_const_name = get_base_class(type)
18
- @bad_const = module_const
19
- @rails_const = rails_const_name.constantize
20
-
21
- return match_submodules? if submodules
22
-
23
- methods_included? module_const.instance_methods
24
- rescue
25
- @cause = ", but the extension module wasn't found"
26
- false
27
- end
28
- end
29
-
30
- def base_class_methods
31
- (rails_const == I18n) ? rails_const.methods : rails_const.instance_methods
32
- end
33
-
34
- def match_submodules?
35
- submodules.each do |name|
36
- @bad_const = make_constant(module_const, name)
37
- return false if !methods_included? get_methods(name)
38
- end
39
- true
40
- end
41
-
42
- def methods_included? methods
43
- (base_class_methods & methods) == methods
44
- end
45
-
46
- def get_methods name
47
- get_constant(module_const, name).instance_methods
48
- end
49
-
50
- def failure_message
51
- "Expected the rails class #{rails_const_name} to be extended with the methods in #{bad_const}#{cause}"
52
- end
53
-
54
- def negative_failure_message
55
- "Did not expect the rails class #{rails_const_name} to be extended with the methods in #{bad_const}"
56
- end
57
- end
58
-
59
- def be_extended_with(module_const, *submodules)
60
- BeExtendedWith.new module_const, submodules
61
- end
62
- end
63
- end
64
- end
@@ -1,62 +0,0 @@
1
- module Rails3
2
- class PluginExtender
3
- module Util
4
- INIT = :initialize
5
- ACTIVE_MODULES = {:AR => :active_record, :view => :action_view, :controller => :action_controller, :mailer => :action_mailer}
6
-
7
- def get_base_class type
8
- type = get_load_type(type).to_s
9
- const = act_type?(type) ? rails_const_base(type) : "#{type.to_s.camelize}"
10
- end
11
-
12
- def act_type? type
13
- type =~/action/ || type =~/active/
14
- end
15
-
16
- def get_constant base_name, name
17
- make_constant(base_name, name).constantize
18
- end
19
-
20
- def rails_const_base type
21
- "#{type.to_s.camelize}::Base"
22
- end
23
-
24
- def make_constant base_name, name
25
- "#{base_name.to_s.camelize}::#{name.to_s.camelize}"
26
- end
27
-
28
- def get_load_type type
29
- return ACTIVE_MODULES[type] if ACTIVE_MODULES[type]
30
- return type if ACTIVE_MODULES.values.include? type
31
- return type if type == :i18n
32
- logger.warn "WARNING: The Rails 3 load handler for the component #{type} is not part of the default load process."
33
- end
34
-
35
- def get_module module_name
36
- case module_name
37
- when Constant
38
- module_name
39
- when String
40
- module_name.to_s.constantize
41
- else
42
- raise ArgumentError, "#{module_name} could not be converted into a module constant"
43
- end
44
- end
45
-
46
- protected
47
-
48
- def valid_before_hook? type
49
- [INIT, :configuration, :eager_load].include?(type)
50
- end
51
-
52
- def valid_after_hook? type
53
- INIT == type
54
- end
55
-
56
- def valid_load_hook? type
57
- @valid_load_hooks ||= [ACTIVE_MODULES.keys, ACTIVE_MODULES.values, :i18n].flatten
58
- @valid_load_hooks.include?(type)
59
- end
60
- end
61
- end
62
- end
@@ -1,78 +0,0 @@
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{rails3_plugin_toolbox}
8
- s.version = "0.3.4"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2010-09-13}
13
- s.description = %q{Provides a more intuitive DSL for Rails 3 plugin configuration and a specialized RSpec 2 matcher. Makes it much easier to develop Rails 3 plugins!}
14
- s.email = %q{kmandrup@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- ".rspec",
23
- "LICENSE",
24
- "README.markdown",
25
- "Rakefile",
26
- "VERSION",
27
- "config/database.yml",
28
- "lib/plugin_toolbox/extender.rb",
29
- "lib/plugin_toolbox/loader.rb",
30
- "lib/plugin_toolbox/rspec/config.rb",
31
- "lib/plugin_toolbox/rspec/macro.rb",
32
- "lib/plugin_toolbox/rspec/matchers/be_extended_with.rb",
33
- "lib/plugin_toolbox/util.rb",
34
- "lib/rails3_plugin_toolbox.rb",
35
- "log/development.log",
36
- "rails3_plugin_toolbox.gemspec",
37
- "spec/plugin_toolbox/extend_view_content_spec.rb",
38
- "spec/plugin_toolbox/extender_action_spec.rb",
39
- "spec/plugin_toolbox/extender_i18n_spec.rb",
40
- "spec/plugin_toolbox/extender_spec.rb",
41
- "spec/spec_helper.rb",
42
- "wiki/add_rake_tasks.markdown",
43
- "wiki/engine.markdown",
44
- "wiki/how_to_guide.markdown"
45
- ]
46
- s.homepage = %q{http://github.com/kristianmandrup/rails3_plugin_toolbox}
47
- s.rdoc_options = ["--charset=UTF-8"]
48
- s.require_paths = ["lib"]
49
- s.rubygems_version = %q{1.3.7}
50
- s.summary = %q{Toolbox to facilitate Rails 3 plugin development}
51
- s.test_files = [
52
- "spec/plugin_toolbox/extend_view_content_spec.rb",
53
- "spec/plugin_toolbox/extender_action_spec.rb",
54
- "spec/plugin_toolbox/extender_i18n_spec.rb",
55
- "spec/plugin_toolbox/extender_spec.rb",
56
- "spec/spec_helper.rb"
57
- ]
58
-
59
- if s.respond_to? :specification_version then
60
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
- s.specification_version = 3
62
-
63
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
- s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
65
- s.add_runtime_dependency(%q<rails>, [">= 3.0.0.rc"])
66
- s.add_runtime_dependency(%q<require_all>, [">= 1.1.0"])
67
- else
68
- s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
69
- s.add_dependency(%q<rails>, [">= 3.0.0.rc"])
70
- s.add_dependency(%q<require_all>, [">= 1.1.0"])
71
- end
72
- else
73
- s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
74
- s.add_dependency(%q<rails>, [">= 3.0.0.rc"])
75
- s.add_dependency(%q<require_all>, [">= 1.1.0"])
76
- end
77
- end
78
-