genspec 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +122 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/genspec.gemspec +83 -0
- data/lib/genspec.rb +14 -0
- data/lib/genspec/generation_matchers.rb +27 -0
- data/lib/genspec/generation_matchers/generation_matcher.rb +147 -0
- data/lib/genspec/generation_matchers/result_matcher.rb +42 -0
- data/lib/genspec/generator_example_group.rb +71 -0
- data/pkg/genspec-0.0.0.gem +0 -0
- data/pkg/genspec-0.1.0.gem +0 -0
- data/rdoc/classes/GenSpec.html +124 -0
- data/rdoc/classes/GenSpec/GenerationMatchers.html +197 -0
- data/rdoc/classes/GenSpec/GenerationMatchers/GenerationMatcher.html +363 -0
- data/rdoc/classes/GenSpec/GenerationMatchers/ResultMatcher.html +241 -0
- data/rdoc/classes/GenSpec/GeneratorExampleGroup.html +285 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/README_rdoc.html +261 -0
- data/rdoc/files/lib/genspec/generation_matchers/generation_matcher_rb.html +101 -0
- data/rdoc/files/lib/genspec/generation_matchers/result_matcher_rb.html +101 -0
- data/rdoc/files/lib/genspec/generation_matchers_rb.html +109 -0
- data/rdoc/files/lib/genspec/generator_example_group_rb.html +101 -0
- data/rdoc/files/lib/genspec_rb.html +114 -0
- data/rdoc/fr_class_index.html +31 -0
- data/rdoc/fr_file_index.html +32 -0
- data/rdoc/fr_method_index.html +46 -0
- data/rdoc/index.html +26 -0
- data/rdoc/rdoc-style.css +208 -0
- data/spec/environment_spec.rb +18 -0
- data/spec/generators/test_spec.rb +96 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/generators/test/templates/file +1 -0
- data/spec/support/generators/test/test_generator.rb +29 -0
- metadata +124 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
module GenSpec
|
2
|
+
module GenerationMatchers
|
3
|
+
class ResultMatcher < GenSpec::GenerationMatchers::GenerationMatcher
|
4
|
+
attr_reader :filename
|
5
|
+
|
6
|
+
def initialize(filename, &block)
|
7
|
+
@filename = filename
|
8
|
+
@block = block
|
9
|
+
super(:does_not_matter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def after_replay(target)
|
13
|
+
path = File.join(target.destination_root, filename)
|
14
|
+
if File.exist?(path)
|
15
|
+
matched!
|
16
|
+
validate_block(target, path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure_message
|
21
|
+
"Expected to generate file #{filename}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def negative_failure_message
|
25
|
+
"Expected to not generate file #{filename}"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def validate_block(target, path)
|
30
|
+
if @block
|
31
|
+
if @block.arity == 2
|
32
|
+
@block.call(File.read(path), target)
|
33
|
+
else
|
34
|
+
@block.call(File.read(path))
|
35
|
+
end
|
36
|
+
else
|
37
|
+
true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module GenSpec
|
2
|
+
class GeneratorExampleGroup
|
3
|
+
extend Spec::Example::ExampleGroupMethods
|
4
|
+
include Spec::Example::ExampleMethods
|
5
|
+
include GenSpec::GenerationMatchers
|
6
|
+
delegate :generator_arguments, :generator_options, :generator_args, :to => "self.class"
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def generator_arguments
|
10
|
+
@generator_args.dup? || []
|
11
|
+
end
|
12
|
+
|
13
|
+
def generator_options
|
14
|
+
@generator_options.dup? || {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def with_arguments(*args, &block)
|
18
|
+
if block_given?
|
19
|
+
context "with arguments #{args.inspect}" do
|
20
|
+
with_arguments(*args)
|
21
|
+
instance_eval(&block)
|
22
|
+
end
|
23
|
+
else
|
24
|
+
@generator_args = args.flatten.collect { |c| c.to_s }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def with_options(hash, &block)
|
29
|
+
if block_given?
|
30
|
+
context "with options #{hash.inspect}" do
|
31
|
+
with_options(hash)
|
32
|
+
instance_eval(&block)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
@generator_options = hash
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
alias_method :generator_args, :generator_arguments
|
40
|
+
alias_method :with_args, :with_arguments
|
41
|
+
end
|
42
|
+
|
43
|
+
def subject(&block)
|
44
|
+
block.nil? ?
|
45
|
+
explicit_subject || implicit_subject : @explicit_subject_block = block
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def explicit_subject
|
50
|
+
group = self
|
51
|
+
while group.respond_to?(:explicit_subject_block)
|
52
|
+
return group.explicit_subject_block if group.explicit_subject_block
|
53
|
+
group = group.superclass
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def implicit_subject
|
58
|
+
target = example_group_hierarchy[1].described_class || example_group_hierarchy[1].description_args.first
|
59
|
+
|
60
|
+
if target.kind_of?(Symbol) || target.kind_of?(String)
|
61
|
+
target = self.class.lookup_missing_generator("#{target.to_s.underscore}_generator".camelize)
|
62
|
+
end
|
63
|
+
target.new(generator_args, generator_options)
|
64
|
+
rescue Rails::Generator::GeneratorError, Rails::Generator::UsageError
|
65
|
+
# let them pass, so the user can test the output.
|
66
|
+
# TODO: Make this disable-able via configuration.
|
67
|
+
|
68
|
+
$! # return this because it is the content we'll check against.
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,124 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: GenSpec</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">GenSpec</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/genspec/generation_matchers/generation_matcher_rb.html">
|
59
|
+
lib/genspec/generation_matchers/generation_matcher.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../files/lib/genspec/generation_matchers/result_matcher_rb.html">
|
63
|
+
lib/genspec/generation_matchers/result_matcher.rb
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../files/lib/genspec/generation_matchers_rb.html">
|
67
|
+
lib/genspec/generation_matchers.rb
|
68
|
+
</a>
|
69
|
+
<br />
|
70
|
+
<a href="../files/lib/genspec/generator_example_group_rb.html">
|
71
|
+
lib/genspec/generator_example_group.rb
|
72
|
+
</a>
|
73
|
+
<br />
|
74
|
+
</td>
|
75
|
+
</tr>
|
76
|
+
|
77
|
+
</table>
|
78
|
+
</div>
|
79
|
+
<!-- banner header -->
|
80
|
+
|
81
|
+
<div id="bodyContent">
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<div id="contextContent">
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
|
92
|
+
</div>
|
93
|
+
|
94
|
+
|
95
|
+
<!-- if includes -->
|
96
|
+
|
97
|
+
<div id="section">
|
98
|
+
|
99
|
+
<div id="class-list">
|
100
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
101
|
+
|
102
|
+
Module <a href="GenSpec/GenerationMatchers.html" class="link">GenSpec::GenerationMatchers</a><br />
|
103
|
+
Class <a href="GenSpec/GeneratorExampleGroup.html" class="link">GenSpec::GeneratorExampleGroup</a><br />
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<!-- if method_list -->
|
114
|
+
|
115
|
+
|
116
|
+
</div>
|
117
|
+
|
118
|
+
|
119
|
+
<div id="validator-badges">
|
120
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
121
|
+
</div>
|
122
|
+
|
123
|
+
</body>
|
124
|
+
</html>
|
@@ -0,0 +1,197 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: GenSpec::GenerationMatchers</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">GenSpec::GenerationMatchers</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/genspec/generation_matchers/generation_matcher_rb.html">
|
59
|
+
lib/genspec/generation_matchers/generation_matcher.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../../files/lib/genspec/generation_matchers/result_matcher_rb.html">
|
63
|
+
lib/genspec/generation_matchers/result_matcher.rb
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../../files/lib/genspec/generation_matchers_rb.html">
|
67
|
+
lib/genspec/generation_matchers.rb
|
68
|
+
</a>
|
69
|
+
<br />
|
70
|
+
</td>
|
71
|
+
</tr>
|
72
|
+
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
<div id="method-list">
|
88
|
+
<h3 class="section-bar">Methods</h3>
|
89
|
+
|
90
|
+
<div class="name-list">
|
91
|
+
<a href="#M000001">generate</a>
|
92
|
+
<a href="#M000002">output</a>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
|
99
|
+
<!-- if includes -->
|
100
|
+
|
101
|
+
<div id="section">
|
102
|
+
|
103
|
+
<div id="class-list">
|
104
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
105
|
+
|
106
|
+
Class <a href="GenerationMatchers/GenerationMatcher.html" class="link">GenSpec::GenerationMatchers::GenerationMatcher</a><br />
|
107
|
+
Class <a href="GenerationMatchers/ResultMatcher.html" class="link">GenSpec::GenerationMatchers::ResultMatcher</a><br />
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
<!-- if method_list -->
|
118
|
+
<div id="methods">
|
119
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
120
|
+
|
121
|
+
<div id="method-M000001" class="method-detail">
|
122
|
+
<a name="M000001"></a>
|
123
|
+
|
124
|
+
<div class="method-heading">
|
125
|
+
<a href="#M000001" class="method-signature">
|
126
|
+
<span class="method-name">generate</span><span class="method-args">(kind, *args, &block)</span>
|
127
|
+
</a>
|
128
|
+
</div>
|
129
|
+
|
130
|
+
<div class="method-description">
|
131
|
+
<p>
|
132
|
+
Valid types: :dependency, :class_collisions, :file, :template,
|
133
|
+
:complex_template, :directory, :readme, :migration_template,
|
134
|
+
:route_resources
|
135
|
+
</p>
|
136
|
+
<p><a class="source-toggle" href="#"
|
137
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
138
|
+
<div class="method-source-code" id="M000001-source">
|
139
|
+
<pre>
|
140
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers.rb, line 8</span>
|
141
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate</span>(<span class="ruby-identifier">kind</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
142
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">kind</span>.<span class="ruby-identifier">to_s</span>
|
143
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-operator">*</span><span class="ruby-constant">GenSpec</span><span class="ruby-operator">::</span><span class="ruby-constant">GenerationMatchers</span><span class="ruby-operator">::</span><span class="ruby-constant">GenerationMatcher</span>.<span class="ruby-identifier">generation_methods</span>
|
144
|
+
<span class="ruby-constant">GenSpec</span><span class="ruby-operator">::</span><span class="ruby-constant">GenerationMatchers</span><span class="ruby-operator">::</span><span class="ruby-constant">GenerationMatcher</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">kind</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
145
|
+
<span class="ruby-keyword kw">else</span>
|
146
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">kind</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">String</span>)
|
147
|
+
<span class="ruby-constant">GenSpec</span><span class="ruby-operator">::</span><span class="ruby-constant">GenerationMatchers</span><span class="ruby-operator">::</span><span class="ruby-constant">ResultMatcher</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">kind</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
148
|
+
<span class="ruby-keyword kw">else</span>
|
149
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">"No generator matcher for #{kind.inspect}"</span>
|
150
|
+
<span class="ruby-keyword kw">end</span>
|
151
|
+
<span class="ruby-keyword kw">end</span>
|
152
|
+
<span class="ruby-keyword kw">end</span>
|
153
|
+
</pre>
|
154
|
+
</div>
|
155
|
+
</div>
|
156
|
+
</div>
|
157
|
+
|
158
|
+
<div id="method-M000002" class="method-detail">
|
159
|
+
<a name="M000002"></a>
|
160
|
+
|
161
|
+
<div class="method-heading">
|
162
|
+
<a href="#M000002" class="method-signature">
|
163
|
+
<span class="method-name">output</span><span class="method-args">(text_or_regexp)</span>
|
164
|
+
</a>
|
165
|
+
</div>
|
166
|
+
|
167
|
+
<div class="method-description">
|
168
|
+
<p>
|
169
|
+
This tests the content sent to the command line, instead of the generated
|
170
|
+
product. Useful for testing help messages, etc.
|
171
|
+
</p>
|
172
|
+
<p><a class="source-toggle" href="#"
|
173
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
174
|
+
<div class="method-source-code" id="M000002-source">
|
175
|
+
<pre>
|
176
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers.rb, line 23</span>
|
177
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">output</span>(<span class="ruby-identifier">text_or_regexp</span>)
|
178
|
+
<span class="ruby-constant">GenSpec</span><span class="ruby-operator">::</span><span class="ruby-constant">GenerationMatchers</span><span class="ruby-operator">::</span><span class="ruby-constant">GenerationMatcher</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">:output</span>, <span class="ruby-identifier">text_or_regexp</span>)
|
179
|
+
<span class="ruby-keyword kw">end</span>
|
180
|
+
</pre>
|
181
|
+
</div>
|
182
|
+
</div>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
|
186
|
+
</div>
|
187
|
+
|
188
|
+
|
189
|
+
</div>
|
190
|
+
|
191
|
+
|
192
|
+
<div id="validator-badges">
|
193
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
</body>
|
197
|
+
</html>
|
@@ -0,0 +1,363 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: GenSpec::GenerationMatchers::GenerationMatcher</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">GenSpec::GenerationMatchers::GenerationMatcher</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/genspec/generation_matchers/generation_matcher_rb.html">
|
59
|
+
lib/genspec/generation_matchers/generation_matcher.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000013">after_replay</a>
|
90
|
+
<a href="#M000010">failure_message</a>
|
91
|
+
<a href="#M000008">generation_methods</a>
|
92
|
+
<a href="#M000014">matched!</a>
|
93
|
+
<a href="#M000015">matched?</a>
|
94
|
+
<a href="#M000009">matches?</a>
|
95
|
+
<a href="#M000011">negative_failure_message</a>
|
96
|
+
<a href="#M000007">new</a>
|
97
|
+
<a href="#M000012">replay</a>
|
98
|
+
</div>
|
99
|
+
</div>
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
<!-- if includes -->
|
105
|
+
|
106
|
+
<div id="section">
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
<!-- if method_list -->
|
116
|
+
<div id="methods">
|
117
|
+
<h3 class="section-bar">Public Class methods</h3>
|
118
|
+
|
119
|
+
<div id="method-M000008" class="method-detail">
|
120
|
+
<a name="M000008"></a>
|
121
|
+
|
122
|
+
<div class="method-heading">
|
123
|
+
<a href="#M000008" class="method-signature">
|
124
|
+
<span class="method-name">generation_methods</span><span class="method-args">()</span>
|
125
|
+
</a>
|
126
|
+
</div>
|
127
|
+
|
128
|
+
<div class="method-description">
|
129
|
+
<p><a class="source-toggle" href="#"
|
130
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
131
|
+
<div class="method-source-code" id="M000008-source">
|
132
|
+
<pre>
|
133
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers/generation_matcher.rb, line 13</span>
|
134
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">generation_methods</span>
|
135
|
+
<span class="ruby-ivar">@generation_methods</span> <span class="ruby-operator">||=</span> <span class="ruby-node">%w(dependency class_collisions file template complex_template directory readme
|
136
|
+
migration_template route_resources)</span>
|
137
|
+
<span class="ruby-keyword kw">end</span>
|
138
|
+
</pre>
|
139
|
+
</div>
|
140
|
+
</div>
|
141
|
+
</div>
|
142
|
+
|
143
|
+
<div id="method-M000007" class="method-detail">
|
144
|
+
<a name="M000007"></a>
|
145
|
+
|
146
|
+
<div class="method-heading">
|
147
|
+
<a href="#M000007" class="method-signature">
|
148
|
+
<span class="method-name">new</span><span class="method-args">(kind = nil, *args)</span>
|
149
|
+
</a>
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<div class="method-description">
|
153
|
+
<p><a class="source-toggle" href="#"
|
154
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
155
|
+
<div class="method-source-code" id="M000007-source">
|
156
|
+
<pre>
|
157
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers/generation_matcher.rb, line 6</span>
|
158
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">kind</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
159
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"Call with kind"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">kind</span>
|
160
|
+
<span class="ruby-ivar">@kind</span> = <span class="ruby-identifier">kind</span>.<span class="ruby-identifier">to_s</span>
|
161
|
+
<span class="ruby-ivar">@args</span> = <span class="ruby-identifier">args</span>
|
162
|
+
<span class="ruby-ivar">@but_found</span> = <span class="ruby-keyword kw">nil</span>
|
163
|
+
<span class="ruby-keyword kw">end</span>
|
164
|
+
</pre>
|
165
|
+
</div>
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
170
|
+
|
171
|
+
<div id="method-M000010" class="method-detail">
|
172
|
+
<a name="M000010"></a>
|
173
|
+
|
174
|
+
<div class="method-heading">
|
175
|
+
<a href="#M000010" class="method-signature">
|
176
|
+
<span class="method-name">failure_message</span><span class="method-args">()</span>
|
177
|
+
</a>
|
178
|
+
</div>
|
179
|
+
|
180
|
+
<div class="method-description">
|
181
|
+
<p><a class="source-toggle" href="#"
|
182
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
183
|
+
<div class="method-source-code" id="M000010-source">
|
184
|
+
<pre>
|
185
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers/generation_matcher.rb, line 35</span>
|
186
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">failure_message</span>
|
187
|
+
<span class="ruby-node">"Expected to generate #{@kind}#{with_file}#{but_found}"</span>
|
188
|
+
<span class="ruby-keyword kw">end</span>
|
189
|
+
</pre>
|
190
|
+
</div>
|
191
|
+
</div>
|
192
|
+
</div>
|
193
|
+
|
194
|
+
<div id="method-M000009" class="method-detail">
|
195
|
+
<a name="M000009"></a>
|
196
|
+
|
197
|
+
<div class="method-heading">
|
198
|
+
<a href="#M000009" class="method-signature">
|
199
|
+
<span class="method-name">matches?</span><span class="method-args">(target)</span>
|
200
|
+
</a>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
<div class="method-description">
|
204
|
+
<p><a class="source-toggle" href="#"
|
205
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
206
|
+
<div class="method-source-code" id="M000009-source">
|
207
|
+
<pre>
|
208
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers/generation_matcher.rb, line 18</span>
|
209
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">matches?</span>(<span class="ruby-identifier">target</span>)
|
210
|
+
<span class="ruby-comment cmt"># if it's a string then it's an error message or some such from the generator.</span>
|
211
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">target</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Rails</span><span class="ruby-operator">::</span><span class="ruby-constant">Generator</span><span class="ruby-operator">::</span><span class="ruby-constant">GeneratorError</span>)
|
212
|
+
<span class="ruby-comment cmt"># if we're not checking output then why hold on to it? Raise it like the error it is!</span>
|
213
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">target</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@kind</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'output'</span>
|
214
|
+
<span class="ruby-ivar">@log</span> = <span class="ruby-identifier">target</span>.<span class="ruby-identifier">message</span>
|
215
|
+
<span class="ruby-keyword kw">else</span>
|
216
|
+
<span class="ruby-identifier">temporary_root</span>(<span class="ruby-identifier">target</span>) <span class="ruby-keyword kw">do</span>
|
217
|
+
<span class="ruby-identifier">swap_loggers</span>(<span class="ruby-identifier">target</span>) <span class="ruby-keyword kw">do</span>
|
218
|
+
<span class="ruby-identifier">replay</span>(<span class="ruby-identifier">target</span>)
|
219
|
+
<span class="ruby-keyword kw">end</span>
|
220
|
+
<span class="ruby-keyword kw">end</span>
|
221
|
+
<span class="ruby-keyword kw">end</span>
|
222
|
+
<span class="ruby-identifier">match_content</span>
|
223
|
+
<span class="ruby-identifier">matched?</span>
|
224
|
+
<span class="ruby-keyword kw">end</span>
|
225
|
+
</pre>
|
226
|
+
</div>
|
227
|
+
</div>
|
228
|
+
</div>
|
229
|
+
|
230
|
+
<div id="method-M000011" class="method-detail">
|
231
|
+
<a name="M000011"></a>
|
232
|
+
|
233
|
+
<div class="method-heading">
|
234
|
+
<a href="#M000011" class="method-signature">
|
235
|
+
<span class="method-name">negative_failure_message</span><span class="method-args">()</span>
|
236
|
+
</a>
|
237
|
+
</div>
|
238
|
+
|
239
|
+
<div class="method-description">
|
240
|
+
<p><a class="source-toggle" href="#"
|
241
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
242
|
+
<div class="method-source-code" id="M000011-source">
|
243
|
+
<pre>
|
244
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers/generation_matcher.rb, line 39</span>
|
245
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">negative_failure_message</span>
|
246
|
+
<span class="ruby-node">"Expected not to generate #{@kind}#{with_file}"</span>
|
247
|
+
<span class="ruby-keyword kw">end</span>
|
248
|
+
</pre>
|
249
|
+
</div>
|
250
|
+
</div>
|
251
|
+
</div>
|
252
|
+
|
253
|
+
<h3 class="section-bar">Protected Instance methods</h3>
|
254
|
+
|
255
|
+
<div id="method-M000013" class="method-detail">
|
256
|
+
<a name="M000013"></a>
|
257
|
+
|
258
|
+
<div class="method-heading">
|
259
|
+
<a href="#M000013" class="method-signature">
|
260
|
+
<span class="method-name">after_replay</span><span class="method-args">(target)</span>
|
261
|
+
</a>
|
262
|
+
</div>
|
263
|
+
|
264
|
+
<div class="method-description">
|
265
|
+
<p>
|
266
|
+
hook
|
267
|
+
</p>
|
268
|
+
<p><a class="source-toggle" href="#"
|
269
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
270
|
+
<div class="method-source-code" id="M000013-source">
|
271
|
+
<pre>
|
272
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers/generation_matcher.rb, line 52</span>
|
273
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after_replay</span>(<span class="ruby-identifier">target</span>)
|
274
|
+
<span class="ruby-keyword kw">end</span>
|
275
|
+
</pre>
|
276
|
+
</div>
|
277
|
+
</div>
|
278
|
+
</div>
|
279
|
+
|
280
|
+
<div id="method-M000014" class="method-detail">
|
281
|
+
<a name="M000014"></a>
|
282
|
+
|
283
|
+
<div class="method-heading">
|
284
|
+
<a href="#M000014" class="method-signature">
|
285
|
+
<span class="method-name">matched!</span><span class="method-args">()</span>
|
286
|
+
</a>
|
287
|
+
</div>
|
288
|
+
|
289
|
+
<div class="method-description">
|
290
|
+
<p><a class="source-toggle" href="#"
|
291
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
292
|
+
<div class="method-source-code" id="M000014-source">
|
293
|
+
<pre>
|
294
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers/generation_matcher.rb, line 55</span>
|
295
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">matched!</span>
|
296
|
+
<span class="ruby-ivar">@matched</span> = <span class="ruby-keyword kw">true</span>
|
297
|
+
<span class="ruby-keyword kw">end</span>
|
298
|
+
</pre>
|
299
|
+
</div>
|
300
|
+
</div>
|
301
|
+
</div>
|
302
|
+
|
303
|
+
<div id="method-M000015" class="method-detail">
|
304
|
+
<a name="M000015"></a>
|
305
|
+
|
306
|
+
<div class="method-heading">
|
307
|
+
<a href="#M000015" class="method-signature">
|
308
|
+
<span class="method-name">matched?</span><span class="method-args">()</span>
|
309
|
+
</a>
|
310
|
+
</div>
|
311
|
+
|
312
|
+
<div class="method-description">
|
313
|
+
<p><a class="source-toggle" href="#"
|
314
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
315
|
+
<div class="method-source-code" id="M000015-source">
|
316
|
+
<pre>
|
317
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers/generation_matcher.rb, line 59</span>
|
318
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">matched?</span>
|
319
|
+
<span class="ruby-operator">!</span><span class="ruby-operator">!</span><span class="ruby-ivar">@matched</span>
|
320
|
+
<span class="ruby-keyword kw">end</span>
|
321
|
+
</pre>
|
322
|
+
</div>
|
323
|
+
</div>
|
324
|
+
</div>
|
325
|
+
|
326
|
+
<div id="method-M000012" class="method-detail">
|
327
|
+
<a name="M000012"></a>
|
328
|
+
|
329
|
+
<div class="method-heading">
|
330
|
+
<a href="#M000012" class="method-signature">
|
331
|
+
<span class="method-name">replay</span><span class="method-args">(target)</span>
|
332
|
+
</a>
|
333
|
+
</div>
|
334
|
+
|
335
|
+
<div class="method-description">
|
336
|
+
<p><a class="source-toggle" href="#"
|
337
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
338
|
+
<div class="method-source-code" id="M000012-source">
|
339
|
+
<pre>
|
340
|
+
<span class="ruby-comment cmt"># File lib/genspec/generation_matchers/generation_matcher.rb, line 45</span>
|
341
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">replay</span>(<span class="ruby-identifier">target</span>)
|
342
|
+
<span class="ruby-ivar">@create</span> = <span class="ruby-constant">Rails</span><span class="ruby-operator">::</span><span class="ruby-constant">Generator</span><span class="ruby-operator">::</span><span class="ruby-constant">Commands</span><span class="ruby-operator">::</span><span class="ruby-constant">Create</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">target</span>)
|
343
|
+
<span class="ruby-identifier">target</span>.<span class="ruby-identifier">manifest</span>.<span class="ruby-identifier">replay</span>(<span class="ruby-keyword kw">self</span>)
|
344
|
+
<span class="ruby-identifier">after_replay</span>(<span class="ruby-identifier">target</span>)
|
345
|
+
<span class="ruby-keyword kw">end</span>
|
346
|
+
</pre>
|
347
|
+
</div>
|
348
|
+
</div>
|
349
|
+
</div>
|
350
|
+
|
351
|
+
|
352
|
+
</div>
|
353
|
+
|
354
|
+
|
355
|
+
</div>
|
356
|
+
|
357
|
+
|
358
|
+
<div id="validator-badges">
|
359
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
360
|
+
</div>
|
361
|
+
|
362
|
+
</body>
|
363
|
+
</html>
|