mizugumo 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +15 -0
- data/Rakefile +1 -0
- data/lib/generators/mizugumo/install/templates/javascripts/ninjascript.js +27 -5
- data/lib/mizugumo_link_helper.rb +1 -1
- metadata +5 -21
- data/doc/NAME.haml +0 -14
- data/doc/PURPOSE.haml +0 -71
- data/doc/making_generators.txt +0 -167
data/Gemfile.lock
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: http://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
+
archive-tar-minitar (0.5.2)
|
|
5
|
+
columnize (0.3.4)
|
|
4
6
|
diff-lcs (1.1.2)
|
|
5
7
|
git (1.2.5)
|
|
6
8
|
haml (3.0.25)
|
|
@@ -8,6 +10,8 @@ GEM
|
|
|
8
10
|
bundler (~> 1.0.0)
|
|
9
11
|
git (>= 1.2.5)
|
|
10
12
|
rake
|
|
13
|
+
linecache19 (0.5.12)
|
|
14
|
+
ruby_core_source (>= 0.1.4)
|
|
11
15
|
rake (0.8.7)
|
|
12
16
|
rcov (0.9.9)
|
|
13
17
|
rspec (2.4.0)
|
|
@@ -18,6 +22,16 @@ GEM
|
|
|
18
22
|
rspec-expectations (2.4.0)
|
|
19
23
|
diff-lcs (~> 1.1.2)
|
|
20
24
|
rspec-mocks (2.4.0)
|
|
25
|
+
ruby-debug-base19 (0.11.25)
|
|
26
|
+
columnize (>= 0.3.1)
|
|
27
|
+
linecache19 (>= 0.5.11)
|
|
28
|
+
ruby_core_source (>= 0.1.4)
|
|
29
|
+
ruby-debug19 (0.11.6)
|
|
30
|
+
columnize (>= 0.3.1)
|
|
31
|
+
linecache19 (>= 0.5.11)
|
|
32
|
+
ruby-debug-base19 (>= 0.11.19)
|
|
33
|
+
ruby_core_source (0.1.5)
|
|
34
|
+
archive-tar-minitar (>= 0.5.2)
|
|
21
35
|
|
|
22
36
|
PLATFORMS
|
|
23
37
|
ruby
|
|
@@ -28,3 +42,4 @@ DEPENDENCIES
|
|
|
28
42
|
jeweler (~> 1.5.2)
|
|
29
43
|
rcov
|
|
30
44
|
rspec (>= 1.5)
|
|
45
|
+
ruby-debug19
|
data/Rakefile
CHANGED
|
@@ -21,6 +21,7 @@ namespace :update do
|
|
|
21
21
|
#cp File.join(File.dirname(__FILE__), '..', 'NinjaScript', 'javascript', 'jquery.ninja_script.js'),
|
|
22
22
|
#File.join(File.dirname(__FILE__), 'lib', 'generators', 'mizugumo', 'install', 'templates', 'javascripts')
|
|
23
23
|
mkdir_p 'temp'
|
|
24
|
+
sh 'rm -f temp/ninjascript.zip'
|
|
24
25
|
sh 'cd temp; wget --no-check-certificate https://github.com/downloads/LRDesign/NinjaScript/ninjascript.zip'
|
|
25
26
|
sh 'cd temp; unzip ninjascript.zip'
|
|
26
27
|
cwd = File.dirname(__FILE__)
|
|
@@ -2050,6 +2050,7 @@ define('ninja/behaviors',["ninja/exceptions"], function(Exceptions) {
|
|
|
2050
2050
|
},
|
|
2051
2051
|
buildHandler: function(context, eventName, previousHandler) {
|
|
2052
2052
|
var handle
|
|
2053
|
+
var fallThrough = true
|
|
2053
2054
|
var stopDefault = true
|
|
2054
2055
|
var stopPropagate = true
|
|
2055
2056
|
var stopImmediate = false
|
|
@@ -2065,7 +2066,13 @@ define('ninja/behaviors',["ninja/exceptions"], function(Exceptions) {
|
|
|
2065
2066
|
var len = config.length
|
|
2066
2067
|
for(var i = 0; i < len; i++) {
|
|
2067
2068
|
var found = true
|
|
2068
|
-
if (config[i] == "
|
|
2069
|
+
if (config[i] == "dontContinue" ||
|
|
2070
|
+
config[i] == "overridesOthers") {
|
|
2071
|
+
fallThrough = false
|
|
2072
|
+
}
|
|
2073
|
+
if (config[i] == "andDoDefault" ||
|
|
2074
|
+
config[i] == "continues" ||
|
|
2075
|
+
config[i] == "allowDefault") {
|
|
2069
2076
|
stopDefault = false
|
|
2070
2077
|
}
|
|
2071
2078
|
if (config[i] == "allowPropagate" || config[i] == "dontStopPropagation") {
|
|
@@ -2084,13 +2091,21 @@ define('ninja/behaviors',["ninja/exceptions"], function(Exceptions) {
|
|
|
2084
2091
|
}
|
|
2085
2092
|
}
|
|
2086
2093
|
var handler = function(eventRecord) {
|
|
2087
|
-
handle.call(context, eventRecord, this
|
|
2094
|
+
handle.call(context, eventRecord, this)
|
|
2095
|
+
if(!eventRecord.isFallthroughPrevented()) {
|
|
2096
|
+
previousHandler.call(context, eventRecord)
|
|
2097
|
+
}
|
|
2088
2098
|
if(stopDefault){
|
|
2089
2099
|
return false
|
|
2090
2100
|
} else {
|
|
2091
2101
|
return !eventRecord.isDefaultPrevented()
|
|
2092
2102
|
}
|
|
2093
2103
|
}
|
|
2104
|
+
if(!fallThrough) {
|
|
2105
|
+
handler = this.prependAction(handler, function(eventRecord) {
|
|
2106
|
+
eventRecord.preventFallthrough()
|
|
2107
|
+
})
|
|
2108
|
+
}
|
|
2094
2109
|
if(stopDefault) {
|
|
2095
2110
|
handler = this.prependAction(handler, function(eventRecord) {
|
|
2096
2111
|
eventRecord.preventDefault()
|
|
@@ -2111,6 +2126,12 @@ define('ninja/behaviors',["ninja/exceptions"], function(Exceptions) {
|
|
|
2111
2126
|
Ninja.tools.fireMutationEvent()
|
|
2112
2127
|
})
|
|
2113
2128
|
}
|
|
2129
|
+
handler = this.prependAction(handler, function(eventRecord) {
|
|
2130
|
+
eventRecord.isFallthroughPrevented = function(){ return false };
|
|
2131
|
+
eventRecord.preventFallthrough = function(){
|
|
2132
|
+
eventRecord.isFallthroughPrevented =function(){ return true };
|
|
2133
|
+
}
|
|
2134
|
+
})
|
|
2114
2135
|
|
|
2115
2136
|
return handler
|
|
2116
2137
|
},
|
|
@@ -3893,7 +3914,7 @@ define('ninja/behaviors/standard',["ninja", "utils"],
|
|
|
3893
3914
|
{ busyElement: undefined })
|
|
3894
3915
|
|
|
3895
3916
|
return new ninja.does({
|
|
3896
|
-
priority:
|
|
3917
|
+
priority: 10,
|
|
3897
3918
|
helpers: {
|
|
3898
3919
|
findOverlay: function(elem) {
|
|
3899
3920
|
return this.deriveElementsFrom(elem, configs.busyElement)
|
|
@@ -4278,16 +4299,17 @@ define('ninja/behaviors/confirm',["ninja"],
|
|
|
4278
4299
|
function confirmDefault(event,elem) {
|
|
4279
4300
|
if(!confirm(configs.confirmMessage(elem))) {
|
|
4280
4301
|
event.preventDefault()
|
|
4302
|
+
event.preventFallthrough()
|
|
4281
4303
|
}
|
|
4282
4304
|
}
|
|
4283
4305
|
|
|
4284
4306
|
return new ninja.selects({
|
|
4285
4307
|
"form": new ninja.does({
|
|
4286
|
-
priority:
|
|
4308
|
+
priority: 20,
|
|
4287
4309
|
events: { submit: [confirmDefault, "andDoDefault"] }
|
|
4288
4310
|
}),
|
|
4289
4311
|
"a,input": new ninja.does({
|
|
4290
|
-
priority:
|
|
4312
|
+
priority: 20,
|
|
4291
4313
|
events: { click: [confirmDefault, "andDoDefault"] }
|
|
4292
4314
|
})
|
|
4293
4315
|
})
|
data/lib/mizugumo_link_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mizugumo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
prerelease:
|
|
4
|
+
prerelease: false
|
|
6
5
|
segments:
|
|
7
6
|
- 0
|
|
8
7
|
- 2
|
|
9
|
-
-
|
|
10
|
-
version: 0.2.
|
|
8
|
+
- 1
|
|
9
|
+
version: 0.2.1
|
|
11
10
|
platform: ruby
|
|
12
11
|
authors:
|
|
13
12
|
- Evan Dorn
|
|
@@ -15,18 +14,16 @@ autorequire:
|
|
|
15
14
|
bindir: bin
|
|
16
15
|
cert_chain: []
|
|
17
16
|
|
|
18
|
-
date:
|
|
17
|
+
date: 2013-10-02 00:00:00 -07:00
|
|
19
18
|
default_executable:
|
|
20
19
|
dependencies:
|
|
21
20
|
- !ruby/object:Gem::Dependency
|
|
22
21
|
name: rspec
|
|
23
22
|
prerelease: false
|
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
24
|
requirements:
|
|
27
25
|
- - ">="
|
|
28
26
|
- !ruby/object:Gem::Version
|
|
29
|
-
hash: 5
|
|
30
27
|
segments:
|
|
31
28
|
- 1
|
|
32
29
|
- 5
|
|
@@ -37,11 +34,9 @@ dependencies:
|
|
|
37
34
|
name: bundler
|
|
38
35
|
prerelease: false
|
|
39
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
|
40
|
-
none: false
|
|
41
37
|
requirements:
|
|
42
38
|
- - ~>
|
|
43
39
|
- !ruby/object:Gem::Version
|
|
44
|
-
hash: 23
|
|
45
40
|
segments:
|
|
46
41
|
- 1
|
|
47
42
|
- 0
|
|
@@ -53,11 +48,9 @@ dependencies:
|
|
|
53
48
|
name: jeweler
|
|
54
49
|
prerelease: false
|
|
55
50
|
requirement: &id003 !ruby/object:Gem::Requirement
|
|
56
|
-
none: false
|
|
57
51
|
requirements:
|
|
58
52
|
- - ~>
|
|
59
53
|
- !ruby/object:Gem::Version
|
|
60
|
-
hash: 7
|
|
61
54
|
segments:
|
|
62
55
|
- 1
|
|
63
56
|
- 5
|
|
@@ -69,11 +62,9 @@ dependencies:
|
|
|
69
62
|
name: rcov
|
|
70
63
|
prerelease: false
|
|
71
64
|
requirement: &id004 !ruby/object:Gem::Requirement
|
|
72
|
-
none: false
|
|
73
65
|
requirements:
|
|
74
66
|
- - ">="
|
|
75
67
|
- !ruby/object:Gem::Version
|
|
76
|
-
hash: 3
|
|
77
68
|
segments:
|
|
78
69
|
- 0
|
|
79
70
|
version: "0"
|
|
@@ -131,9 +122,6 @@ files:
|
|
|
131
122
|
- lib/generators/rails/mizugumo/view_generator.rb
|
|
132
123
|
- lib/mizugumo.rb
|
|
133
124
|
- lib/mizugumo_link_helper.rb
|
|
134
|
-
- doc/making_generators.txt
|
|
135
|
-
- doc/NAME.haml
|
|
136
|
-
- doc/PURPOSE.haml
|
|
137
125
|
- spec/spec_helper.rb
|
|
138
126
|
has_rdoc: true
|
|
139
127
|
homepage: http://github.com/LRDesign/mizugumo
|
|
@@ -145,27 +133,23 @@ rdoc_options: []
|
|
|
145
133
|
require_paths:
|
|
146
134
|
- lib/
|
|
147
135
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
|
-
none: false
|
|
149
136
|
requirements:
|
|
150
137
|
- - ">="
|
|
151
138
|
- !ruby/object:Gem::Version
|
|
152
|
-
hash: 3
|
|
153
139
|
segments:
|
|
154
140
|
- 0
|
|
155
141
|
version: "0"
|
|
156
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
|
-
none: false
|
|
158
143
|
requirements:
|
|
159
144
|
- - ">="
|
|
160
145
|
- !ruby/object:Gem::Version
|
|
161
|
-
hash: 3
|
|
162
146
|
segments:
|
|
163
147
|
- 0
|
|
164
148
|
version: "0"
|
|
165
149
|
requirements: []
|
|
166
150
|
|
|
167
151
|
rubyforge_project:
|
|
168
|
-
rubygems_version: 1.
|
|
152
|
+
rubygems_version: 1.3.6
|
|
169
153
|
signing_key:
|
|
170
154
|
specification_version: 3
|
|
171
155
|
summary: Seamless UJS for Rails using NinjaScript
|
data/doc/NAME.haml
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
%h1 Mizugumo Ᾱ Name
|
|
2
|
-
|
|
3
|
-
%p
|
|
4
|
-
'mizugumo' is Japanese for 'water-spider'. Mythologically, however, it is the
|
|
5
|
-
name for special wooden shoes that ninja used to walk on water and thereby approach
|
|
6
|
-
targets via unexpected routes.
|
|
7
|
-
|
|
8
|
-
%p
|
|
9
|
-
As much as the Mythbusters were not impressed (real mizugumo likely did not work
|
|
10
|
-
for actual water-walking, and probably only worked as snowshoes to cross marshy
|
|
11
|
-
terrain), we thought it an appropriate name for an unobtrusive JS behavior library.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
data/doc/PURPOSE.haml
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
%h1 Mizugumo Ᾱ Purpose
|
|
2
|
-
|
|
3
|
-
%p
|
|
4
|
-
Mizugumo exists to help Rails developers quickly build apps that are both AJAXy and that degrade
|
|
5
|
-
gracefully when JavaScript is absent. It uses NinjaScript to provide unobtrusive javascript
|
|
6
|
-
behaviors.
|
|
7
|
-
|
|
8
|
-
%h2 Graceful Degradation
|
|
9
|
-
|
|
10
|
-
%h3 Why we care
|
|
11
|
-
|
|
12
|
-
%p
|
|
13
|
-
Rails developers are notorious for making apps that do not degrade well when JS is unavailable,
|
|
14
|
-
especially if the app uses AJAX for some actions. It's hard to blame anyone - generally, adding
|
|
15
|
-
AJAX is a bit of a pain, and adding degradation requires duplicating a lot of development.
|
|
16
|
-
|
|
17
|
-
%p
|
|
18
|
-
Ideally, we should put the effort into graceful degradation because we can't count on JavaScript
|
|
19
|
-
in real-world conditions. Some situations we care about in which JavaScript might not be
|
|
20
|
-
available:
|
|
21
|
-
|
|
22
|
-
%ul
|
|
23
|
-
%li NoScript users and other security-conscious folk
|
|
24
|
-
%li Screen readers for vision-impaired users
|
|
25
|
-
%li Search engines and spiders, which should see as accurate
|
|
26
|
-
%li Automation tools
|
|
27
|
-
|
|
28
|
-
%h3 How to solve the problem
|
|
29
|
-
|
|
30
|
-
%p
|
|
31
|
-
Because the client sees the normal, JS-enabled behavior, and because we are all busy people,
|
|
32
|
-
Rails developers usually won't make their sites degrade gracefully until it becomes no harder
|
|
33
|
-
to build in graceful degradation than not to. Mizugumo aspires to this goal.
|
|
34
|
-
|
|
35
|
-
%p
|
|
36
|
-
Mizugumo replaces some of rails' default behavior that depend on JS with ones that work
|
|
37
|
-
in the absence of JS. Specifically, link_to with a :method option other than GET actually
|
|
38
|
-
outputs a <form>, not an <a href='foo'>. It then provides a default javascript behavior,
|
|
39
|
-
written in NinjaScript, to implicitly convert those forms
|
|
40
|
-
|
|
41
|
-
%p
|
|
42
|
-
Mizugumo also provides a scaffold tool that gives you an out-of-the box AJAX controller
|
|
43
|
-
in which all actions degrade perfectly in the absence of JS. From that scaffold, it becomes
|
|
44
|
-
much easier to build rich behaviors into your sites while maintaining JS-less functionality.
|
|
45
|
-
|
|
46
|
-
%h2 The Philosophy of Ninja-like Unobtrusiveness
|
|
47
|
-
|
|
48
|
-
%p
|
|
49
|
-
The goal of Mizugumo's JS engine, NinjaScript, is to make javascript super easy to use, and
|
|
50
|
-
reliable for the developer &%8212; no surprises.
|
|
51
|
-
|
|
52
|
-
%3 CSS is Great, JS Sucks
|
|
53
|
-
|
|
54
|
-
%p
|
|
55
|
-
We take for granted CSS's super-easy behavior: specify a selector and add a style. That style
|
|
56
|
-
will always apply to anything that matches that selector, even if the DOM is restructured. JavaScript
|
|
57
|
-
is not like this, however: if we use a library (say jQuery) to bind events to a selector, event
|
|
58
|
-
handlers will get bound to the DOM nodes that match that selector *now*, but elements that get added
|
|
59
|
-
later are out of luck. We can fix event handlers with event delegation methods, but that still
|
|
60
|
-
doesn't help us if what we want to do is transform elements. If I write a javascript block to
|
|
61
|
-
add rounded corners to a bunch of elements, or to add tooltip elements to a bunch of <li> nodes,
|
|
62
|
-
it will only make those changes to the elements that match at the time it is run.
|
|
63
|
-
|
|
64
|
-
%p
|
|
65
|
-
NinjaScripts aims to make JS as much like CSS as possible: specify a behavior once - including
|
|
66
|
-
transformations of the elements themselves - and those behaviors will always apply to all elements
|
|
67
|
-
even if the elements are added to the DOM later. So you can say "all divs with class .foo
|
|
68
|
-
get rounded corners" or "all forms matching .mizugomo_graceful_form get replaced with
|
|
69
|
-
links with the text matching the submit button text" and likewise not worry about when
|
|
70
|
-
and how said forms get added to the DOM.
|
|
71
|
-
|
data/doc/making_generators.txt
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
These are notes to myself to hopefully avoid this kind of suffering again.
|
|
2
|
-
|
|
3
|
-
I ran into some troubles (a few hours worth) trying to get the generators
|
|
4
|
-
working.
|
|
5
|
-
|
|
6
|
-
Rails wants to load generators from specific "namespaces", but parts of those
|
|
7
|
-
namespaces are automatically generated. In particular, when a generator is
|
|
8
|
-
invoked, it will generally be looked for with both a "base" and a "context".
|
|
9
|
-
Rails will use *one* of these two when looking, for example, it will look for:
|
|
10
|
-
|
|
11
|
-
<base>/<your generator> and <your generator>/<context>.
|
|
12
|
-
|
|
13
|
-
These are interdependent; particularly, setting up a scaffold_controller
|
|
14
|
-
generator will cause part of it's namespace to be assumed when looking for
|
|
15
|
-
the other items, like template_engine and test_framework.
|
|
16
|
-
|
|
17
|
-
For example, setting scaffold_generator to "mizugumo:scaffold_controller"
|
|
18
|
-
will cause it to assume a base of "mizugumo" and a context of "scaffold"
|
|
19
|
-
when you run "rails generate scaffold", which will make it look for your view
|
|
20
|
-
generator in "mizugumo:erb" and "erb:scaffold", even if you don't explicitly
|
|
21
|
-
set template_engine to anything.
|
|
22
|
-
|
|
23
|
-
The fix for this was to specify the hooks for template_engine etc. with an
|
|
24
|
-
:in => :rails parameter which causes it to look in the rails namespace
|
|
25
|
-
(and thus retrieve the defaults) unless configs in application.rb specifically
|
|
26
|
-
override those generators.
|
|
27
|
-
|
|
28
|
-
Ultimately, Rails will generate eight acceptable namespaces for the
|
|
29
|
-
generator based on the requested name in config in application.rb
|
|
30
|
-
***It must live in one of those paths on the filesystem.*** However, the
|
|
31
|
-
actual ruby module namespace does not need to match (seems to be irrelevant).
|
|
32
|
-
The Rails 'namespace' can be massaged just by setting self.namespace(blah)
|
|
33
|
-
in the class, for example:
|
|
34
|
-
|
|
35
|
-
self.namespace("rails:mizugumo:erb")
|
|
36
|
-
|
|
37
|
-
This lives in generators/rails/mizugumo/erb_generator.rb, which is
|
|
38
|
-
one of the acceptable namespaces/paths for a beast with this config:
|
|
39
|
-
|
|
40
|
-
config.generators do |g|
|
|
41
|
-
g.template_engine 'mizugumo:erb'
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
Without the self.namespace line in the generator file, Thor would think that
|
|
45
|
-
the generator only has namespace "mizugumo:erb", and wouldn't find it.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-----------------------------------
|
|
49
|
-
Debugging this horseshit:
|
|
50
|
-
|
|
51
|
-
add debugger lines to self.find_by_namespace and self.lookup in gems/railties-<version>/lib/rails/generators.rb.
|
|
52
|
-
|
|
53
|
-
Examples follow
|
|
54
|
-
|
|
55
|
-
def self.find_by_namespace(name, base=nil, context=nil) #:nodoc:
|
|
56
|
-
@debug = name =~ /js_assets/
|
|
57
|
-
lookups = []
|
|
58
|
-
lookups << "#{base}:#{name}" if base
|
|
59
|
-
lookups << "#{name}:#{context}" if context
|
|
60
|
-
|
|
61
|
-
unless base || context
|
|
62
|
-
unless name.to_s.include?(?:)
|
|
63
|
-
lookups << "#{name}:#{name}"
|
|
64
|
-
lookups << "rails:#{name}"
|
|
65
|
-
end
|
|
66
|
-
lookups << "#{name}"
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
lookup(lookups)
|
|
70
|
-
|
|
71
|
-
namespaces = Hash[subclasses.map { |klass| [klass.namespace, klass] }]
|
|
72
|
-
|
|
73
|
-
require 'pp' if @debug
|
|
74
|
-
pp :namespaces => namespaces if @debug
|
|
75
|
-
|
|
76
|
-
lookups.each do |namespace|
|
|
77
|
-
klass = namespaces[namespace]
|
|
78
|
-
p :namespace => namespace if @debug
|
|
79
|
-
p :namespaces_namespace => namespaces[namespace] if @debug
|
|
80
|
-
p :klass => klass if @debug
|
|
81
|
-
return klass if klass
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
invoke_fallbacks_for(name, base) || invoke_fallbacks_for(context, name)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
# Receives namespaces in an array and tries to find matching generators
|
|
90
|
-
# in the load path.
|
|
91
|
-
def self.lookup(namespaces) #:nodoc:
|
|
92
|
-
p :namespaces => namespaces if @debug
|
|
93
|
-
load_generators_from_railties!
|
|
94
|
-
paths = namespaces_to_paths(namespaces)
|
|
95
|
-
|
|
96
|
-
p :paths => paths if @debug
|
|
97
|
-
paths.each do |raw_path|
|
|
98
|
-
["rails/generators", "generators"].each do |base|
|
|
99
|
-
path = "#{base}/#{raw_path}_generator"
|
|
100
|
-
|
|
101
|
-
p :path => path if @debug
|
|
102
|
-
|
|
103
|
-
begin
|
|
104
|
-
require path
|
|
105
|
-
p "Successfully Loaded Path" => path if @debug
|
|
106
|
-
require 'pp' if @debug
|
|
107
|
-
pp :calltrace => caller[0..5] if @debug
|
|
108
|
-
return
|
|
109
|
-
rescue LoadError => e
|
|
110
|
-
p "LoadError for #{path}" if @debug
|
|
111
|
-
raise unless e.message =~ /#{Regexp.escape(path)}$/
|
|
112
|
-
rescue NameError => e
|
|
113
|
-
p "NameError for #{path}" if @debug
|
|
114
|
-
raise unless e.message =~ /Rails::Generator([\s(::)]|$)/
|
|
115
|
-
warn "[WARNING] Could not load generator #{path.inspect} because it's a Rails 2.x generator, which is not supported anymore. Error: #{e.message}.\n#{e.backtrace.join("\n")}"
|
|
116
|
-
rescue Exception => e
|
|
117
|
-
p "Other exception for #{path}" if @debug
|
|
118
|
-
warn "[WARNING] Could not load generator #{path.inspect}. Error: #{e.message}.\n#{e.backtrace.join("\n")}"
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
--------------------------------
|
|
126
|
-
|
|
127
|
-
Example of the above running whil looking for the mizugumo:js_assets generator:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
{:namespaces=>["rails:mizugumo:js_assets", "mizugumo:js_assets:scaffold"]}
|
|
131
|
-
{:paths=>["rails/mizugumo/js_assets/js_assets", "rails/mizugumo/js_assets", "mizugumo/js_assets/scaffold/scaffold", "mizugumo/js_assets/scaffold"]}
|
|
132
|
-
{:path=>"rails/generators/rails/mizugumo/js_assets/js_assets_generator"}
|
|
133
|
-
"LoadError for rails/generators/rails/mizugumo/js_assets/js_assets_generator"
|
|
134
|
-
{:path=>"generators/rails/mizugumo/js_assets/js_assets_generator"}
|
|
135
|
-
"LoadError for generators/rails/mizugumo/js_assets/js_assets_generator"
|
|
136
|
-
{:path=>"rails/generators/rails/mizugumo/js_assets_generator"}
|
|
137
|
-
"LoadError for rails/generators/rails/mizugumo/js_assets_generator"
|
|
138
|
-
{:path=>"generators/rails/mizugumo/js_assets_generator"}
|
|
139
|
-
{"Successfully Loaded Path"=>"generators/rails/mizugumo/js_assets_generator"}
|
|
140
|
-
{:calltrace=>
|
|
141
|
-
["/Users/evan/.rvm/gems/ruby-1.9.2-p0@test_mg/gems/railties-3.1.1/lib/rails/generators.rb:302:in `each'",
|
|
142
|
-
"/Users/evan/.rvm/gems/ruby-1.9.2-p0@test_mg/gems/railties-3.1.1/lib/rails/generators.rb:302:in `block in lookup'",
|
|
143
|
-
"/Users/evan/.rvm/gems/ruby-1.9.2-p0@test_mg/gems/railties-3.1.1/lib/rails/generators.rb:301:in `each'",
|
|
144
|
-
"/Users/evan/.rvm/gems/ruby-1.9.2-p0@test_mg/gems/railties-3.1.1/lib/rails/generators.rb:301:in `lookup'",
|
|
145
|
-
"/Users/evan/.rvm/gems/ruby-1.9.2-p0@test_mg/gems/railties-3.1.1/lib/rails/generators.rb:150:in `find_by_namespace'",
|
|
146
|
-
"/Users/evan/.rvm/gems/ruby-1.9.2-p0@test_mg/gems/railties-3.1.1/lib/rails/generators/base.rb:345:in `prepare_for_invocation'"]}
|
|
147
|
-
{:namespaces=>
|
|
148
|
-
{"rails:mizugumo:scaffold_controller"=>Mizugumo::ScaffoldControllerGenerator,
|
|
149
|
-
"mizugumo:view"=>Mizugumo::ViewGenerator,
|
|
150
|
-
"rails:mizugumo:erb"=>Mizugumo::ErbGenerator,
|
|
151
|
-
"mizugumo:install"=>Mizugumo::Generators::InstallGenerator,
|
|
152
|
-
"rails:model"=>Rails::Generators::ModelGenerator,
|
|
153
|
-
"rails:resource"=>Rails::Generators::ResourceGenerator,
|
|
154
|
-
"rails:scaffold"=>Rails::Generators::ScaffoldGenerator,
|
|
155
|
-
"active_record:model"=>ActiveRecord::Generators::ModelGenerator,
|
|
156
|
-
"test_unit:model"=>TestUnit::Generators::ModelGenerator,
|
|
157
|
-
"test_unit:scaffold"=>TestUnit::Generators::ScaffoldGenerator,
|
|
158
|
-
"rails:helper"=>Rails::Generators::HelperGenerator,
|
|
159
|
-
"test_unit:helper"=>TestUnit::Generators::HelperGenerator,
|
|
160
|
-
"rails:mizugumo:js_assets"=>Mizugumo::JsAssetsGenerator}}
|
|
161
|
-
{:namespace=>"rails:mizugumo:js_assets"}
|
|
162
|
-
{:namespaces_namespace=>Mizugumo::JsAssetsGenerator}
|
|
163
|
-
{:klass=>Mizugumo::JsAssetsGenerator}
|
|
164
|
-
invoke mizugumo:js_assets
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|