cog 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/BuiltIn.cogfile CHANGED
@@ -8,8 +8,20 @@ language :c do |l|
8
8
  l.comment '//'
9
9
  l.multiline_comment '/*', '*/'
10
10
  l.extension :c, :h
11
+ l.seed_extension :c, :header => :h
11
12
  l.include_guard_begin {|name| "#ifndef #{name.underscore.upcase}\n#define #{name.underscore.upcase}"}
12
13
  l.include_guard_end {|name| "#endif"}
14
+ l.reserved %w(auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while _Packed)
15
+
16
+ l.map_boolean('bool') { |x| (!!x).inspect }
17
+ l.map_integer('int') { |x| x.to_i.inspect if x.to_i.signed?(16) }
18
+ l.map_long('long') { |x| x.to_i.inspect + "l" if x.to_i.signed?(32) }
19
+ l.map_float('float') { |x| x.to_f.inspect + "f" }
20
+ l.map_double('double') { |x| x.to_f.inspect }
21
+ l.map_char('char') { |x| x.to_s.length == 1 && "'#{x}'" }
22
+ l.map_string('char *') { |x| x.to_s.inspect }
23
+ l.map_null('void *') { |x| x.nil? && 'NULL' }
24
+ l.map_void('void')
13
25
  end
14
26
 
15
27
  language 'c++' do |l|
@@ -17,17 +29,41 @@ language 'c++' do |l|
17
29
  l.comment_style :c
18
30
  l.include_guard_style :c
19
31
  l.extension :h, :hh, :hpp, :hxx, 'h++', :cc, :cpp, :cxx, 'c++'
32
+ l.seed_extension :cpp, :header => :h
20
33
  l.use_named_scope {|name| "using namespace #{name};"}
21
34
  l.named_scope_begin {|name| "namespace #{name} {"}
22
35
  l.named_scope_end {|name| "} // namespace #{name}"}
36
+ l.reserved %w(INT_MAX INT_MIN MAX_RAND NULL and and_eq asm auto bitand bitor bool break case catch char cin class compl const const_cast continue cout default delete do double dynamic_cast else endl enum explicit extern false float for friend goto if include inline int iomanip iostream long main mutable namespace new not not_eq npos operator or or_eq private protected public register reinterpret_cast return short signed sizeof static static_cast std string struct switch template this throw true try typedef typeid typename union unsigned using virtual void volatile wchar_t while xor xor_eq")
37
+
38
+ l.map_boolean('bool') { |x| (!!x).inspect }
39
+ l.map_integer('int') { |x| x.to_i.inspect if x.to_i.signed?(16) }
40
+ l.map_long('long') { |x| x.to_i.inspect + "l" if x.to_i.signed?(32) }
41
+ l.map_float('float') { |x| x.to_f.inspect + "f" }
42
+ l.map_double('double') { |x| x.to_f.inspect }
43
+ l.map_char('char') { |x| x.to_s.length == 1 && "'#{x}'" }
44
+ l.map_string('std::string') { |x| x.to_s.inspect }
45
+ l.map_null('void *') { |x| x.nil? && 'NULL' }
46
+ l.map_void('void')
23
47
  end
24
48
 
25
49
  language 'c#' do |l|
26
50
  l.name 'C#'
27
51
  l.comment_style :c
28
52
  l.extension :cs
53
+ l.seed_extension :cs
29
54
  l.named_scope_begin {|name| "namespace #{name} {"}
30
55
  l.named_scope_end {|name| "} // namespace #{name}"}
56
+ l.reserved %w(abstract as base bool break byte case catch char checked class const continue decimal default delegate do double else enum event explicit extern false finally fixed float for foreach goto if implicit in int interface internal is lock long namespace new null object operator out override params private protected public readonly ref return sbyte sealed short sizeof stackalloc static string struct switch this throw true try typeof uint ulong unchecked unsafe ushort using virtual void volatile while)
57
+
58
+ l.map_boolean('bool') { |x| (!!x).inspect }
59
+ l.map_integer('int') { |x| x.to_i.inspect if x.to_i.signed?(32) }
60
+ l.map_long('long') { |x| x.to_i.inspect + "L" }
61
+ l.map_float('float') { |x| x.to_f.inspect + "F" }
62
+ l.map_double('double') { |x| x.to_f.inspect }
63
+ l.map_char('char') { |x| x.to_s.length == 1 && "'#{x}'" }
64
+ l.map_string('string') { |x| x.to_s.inspect }
65
+ l.map_null('Object') { |x| x.nil? && 'null' }
66
+ l.map_void('void')
31
67
  end
32
68
 
33
69
  language :css do |l|
@@ -48,22 +84,57 @@ language :java do |l|
48
84
  l.name 'Java'
49
85
  l.comment_style :c
50
86
  l.extension :java
87
+ l.seed_extension :java
51
88
  l.named_scope_begin {|name| "package #{name};"}
52
89
  l.named_scope_end {|name| "// end of package #{name}"}
90
+ l.reserved %w(abstract assert boolean break byte case catch char class const continue default do double else enum extends false final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws transient true try void volatile while)
91
+
92
+ l.map_boolean('boolean') { |x| (!!x).inspect }
93
+ l.map_integer('int') { |x| x.to_i.inspect if x.to_i.signed?(32) }
94
+ l.map_long('long') { |x| x.to_i.inspect + "L" }
95
+ l.map_float('float') { |x| x.to_f.inspect + "f" }
96
+ l.map_double('double') { |x| x.to_f.inspect + "d" }
97
+ l.map_char('char') { |x| x.to_s.length == 1 && "'#{x}'" }
98
+ l.map_string('String') { |x| x.to_s.inspect }
99
+ l.map_null('Object') { |x| x.nil? && 'null' }
100
+ l.map_void('void')
53
101
  end
54
102
 
55
103
  language :javascript do |l|
56
104
  l.name 'JavaScript'
57
105
  l.comment_style :c
58
106
  l.extension :js
107
+ l.seed_extension :js
59
108
  l.named_scope_begin {|name| "var #{name} = { // named scope"}
60
109
  l.named_scope_end {|name| "}; // end of named scope #{name}"}
110
+ l.reserved %w(Array Date Infinity JavaArray JavaClass JavaObject JavaPackage Math NaN Number Object String abstract alert all anchor anchors area assign blur boolean break button byte case catch char checkbox class clearInterval clearTimeout clientInformation close closed confirm const constructor continue crypto debugger decodeURI decodeURIComponent default defaultStatus delete do document double element elements else embed embeds encodeURI encodeURIComponent enum escape eval event export extends false fileUpload final finally float focus for form forms frame frameRate frames function function getClass goto hasOwnProperty hidden history if image images implements import in innerHeight innerWidth instanceof int interface isFinite isNaN isPrototypeOf java layer layers length let link location long mimeTypes name native navigate navigator new null offscreenBuffering onbeforeunload onblur onclick oncontextmenu ondragdrop ondragdrop onerror onfocus onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseout onmouseover onmouseup onreset onsubmit onunload open opener option outerHeight outerWidth package packages pageXOffset pageYOffset parent parseFloat parseInt password pkcs11 plugin private prompt propertyIsEnum protected prototype public radio reset return screenX screenY scroll secure select self setInterval setTimeout short static status submit super switch synchronized taint text textarea this throw throws toString top transient true try typeof undefined unescape untaint valueOf var void volatile while window with)
111
+
112
+ l.map_boolean('Boolean') { |x| (!!x).inspect }
113
+ l.map_integer('Number') { |x| x.to_i.inspect }
114
+ l.map_long('Number') { |x| x.to_i.inspect }
115
+ l.map_float('Number') { |x| x.to_f.inspect }
116
+ l.map_double('Number') { |x| x.to_f.inspect }
117
+ l.map_char('String') { |x| x.to_s.inspect }
118
+ l.map_string('String') { |x| x.to_s.inspect }
119
+ l.map_null('Object') { |x| x.nil? && 'null' }
61
120
  end
62
121
 
63
122
  language :objc do |l|
64
123
  l.name 'Objective-C'
65
124
  l.comment_style :c
66
125
  l.extension :h, :m, :mm
126
+ l.seed_extension :m, :header => :h
127
+ l.reserved %w(@catch @class @dynamic @end @finally @implementation @interface @private @property @protected @protocol @public @selector @synthesize @throw @try BOOL Class IMP NO NULL Protocol SEL YES _Bool _Complex _Imaginery atomic auto break bycopy byref case char const continue default do double else enum extern float for goto id if in inline inout int long nil nonatomic oneway out register restrict retain return self short signed sizeof static struct super switch typedef union unsigned void volatile while)
128
+
129
+ l.map_boolean('BOOL') { |x| x ? 'YES' : 'NO' }
130
+ l.map_integer('int') { |x| x.to_i.inspect if x.to_i.signed?(16) }
131
+ l.map_long('long') { |x| x.to_i.inspect + "l" if x.to_i.signed?(32) }
132
+ l.map_float('float') { |x| x.to_f.inspect + "f" }
133
+ l.map_double('double') { |x| x.to_f.inspect }
134
+ l.map_char('char') { |x| x.to_s.length == 1 && "'#{x}'" }
135
+ l.map_string('NSString *') { |x| "@" + x.to_s.inspect }
136
+ l.map_null('id') { |x| x.nil? && 'nil' }
137
+ l.map_void('void')
67
138
  end
68
139
 
69
140
  language :python do |l|
@@ -71,6 +142,17 @@ language :python do |l|
71
142
  l.comment '#'
72
143
  l.multiline_comment "'''", "'''"
73
144
  l.extension :py
145
+ l.seed_extension :py
146
+ l.reserved %w(Data False Float Int None Numeric Oxphys True acos and array asin assert atan break class close continue cos def del e elif else except exec exp fabs finally float floor for from global if import in input int is lambda log log10 not open or pass pi print raise range return sin sqrt tan try type while write zeros)
147
+
148
+ l.map_boolean('bool') { |x| x ? 'True' : 'False' }
149
+ l.map_integer('int') { |x| x.to_i.inspect }
150
+ l.map_long('int') { |x| x.to_i.inspect }
151
+ l.map_float('float') { |x| x.to_f.inspect }
152
+ l.map_double('float') { |x| x.to_f.inspect }
153
+ l.map_char('str') { |x| x.to_s.inspect }
154
+ l.map_string('str') { |x| x.to_s.inspect }
155
+ l.map_null('object') { |x| x.nil? && 'None' }
74
156
  end
75
157
 
76
158
  language :qt do |l|
@@ -83,8 +165,19 @@ language :ruby do |l|
83
165
  l.comment '#'
84
166
  l.multiline_comment '=begin', '=end'
85
167
  l.extension :rb
168
+ l.seed_extension :rb
86
169
  l.named_scope_begin {|name| "module #{name} # named scope"}
87
170
  l.named_scope_end {|name| "end # named scope #{name}"}
171
+ l.reserved %w(BEGIN END __FILE__ __LINE__ alias and begin break case class def defined? do else elsif end ensure false for if in module next nill not or redo rescue retry return self super then true undef unless until when while)
172
+
173
+ l.map_boolean('!!') { |x| (!!x).inspect }
174
+ l.map_integer('Fixnum') { |x| x.to_i.inspect }
175
+ l.map_long('Fixnum') { |x| x.to_i.inspect }
176
+ l.map_float('Float') { |x| x.to_f.inspect }
177
+ l.map_double('Float') { |x| x.to_f.inspect }
178
+ l.map_char('String') { |x| x.to_s.inspect }
179
+ l.map_string('String') { |x| x.to_s.inspect }
180
+ l.map_null('Object') { |x| x.nil? && 'nil' }
88
181
  end
89
182
 
90
183
  language :xml do |l|
data/bin/cog CHANGED
@@ -21,17 +21,28 @@ switch :colorless
21
21
 
22
22
  desc 'Add cog to the project in the present working directory'
23
23
  command :init do |c|
24
-
25
24
  c.action do |gopt, opt, args|
26
25
  Cog.initialize_project
27
26
  end
28
27
  end
29
28
 
30
- desc 'Manage project generators'
29
+ desc 'Run and manage project generators'
30
+ long_desc 'Omit generator name to run all of them'
31
+ arg_name 'name'
31
32
  command [:generator, :gen] do |c|
32
33
 
33
- c.default_command :run
34
-
34
+ c.default_desc 'Run generators'
35
+ c.action do |gopt, opt, args|
36
+ Cog::Embeds.gather_from_project
37
+ if args.empty?
38
+ Cog::Controllers::GeneratorController.run_all
39
+ else
40
+ args.each do |name|
41
+ Cog::Controllers::GeneratorController.run name
42
+ end
43
+ end
44
+ end
45
+
35
46
  c.desc 'List project generators'
36
47
  c.command :list do |sub|
37
48
  sub.action do |gopt, opt, args|
@@ -62,35 +73,15 @@ command [:generator, :gen] do |c|
62
73
  end
63
74
  end
64
75
  end
65
-
66
- c.desc 'Run project generators'
67
- c.long_desc 'Omit generator name to run all of them'
68
- c.arg_name 'name'
69
- c.command :run do |sub|
70
- sub.action do |gopt, opt, args|
71
- Cog::Embeds.gather_from_project
72
- if args.empty?
73
- Cog::Controllers::GeneratorController.run_all
74
- else
75
- args.each do |name|
76
- Cog::Controllers::GeneratorController.run name
77
- end
78
- end
79
- end
80
- end
81
76
  end
82
77
 
83
- desc 'List or create DSLs known as cog plugins'
84
- command :plugin do |c|
85
-
86
- c.default_command :list
87
-
88
- c.desc 'List the available plugins'
89
- c.command :list do |sub|
90
- sub.action do |gopt, opt, args|
91
- x = Cog::Controllers::PluginController.list
92
- puts x.join "\n" unless x.empty?
93
- end
78
+ desc 'List or create plugins'
79
+ command [:plugin, :pl] do |c|
80
+
81
+ c.default_desc 'List the available plugins'
82
+ c.action do |gopt, opt, args|
83
+ x = Cog::Controllers::PluginController.list
84
+ puts x.join "\n" unless x.empty?
94
85
  end
95
86
 
96
87
  c.desc 'Create a new plugin'
@@ -104,22 +95,17 @@ command :plugin do |c|
104
95
  end
105
96
  end
106
97
 
107
- desc 'Manage templates'
98
+ desc 'List or create ERB templates'
108
99
  command [:template, :tm] do |c|
109
100
 
110
- c.default_command :list
111
-
112
- c.desc 'List the available templates'
113
- c.command :list do |sub|
114
- sub.action do |gopt, opt, args|
115
- x = Cog::Controllers::TemplateController.list
116
- puts x.join "\n" unless x.empty?
117
- end
101
+ c.default_desc 'List the available templates'
102
+ c.action do |gopt, opt, args|
103
+ x = Cog::Controllers::TemplateController.list
104
+ puts x.join "\n" unless x.empty?
118
105
  end
119
106
 
120
107
  c.desc 'Create a new project template'
121
108
  c.command :new do |sub|
122
-
123
109
  sub.action do |gopt, opt, args|
124
110
  args.each do |name|
125
111
  Cog::Controllers::TemplateController.create name, :force_override => opt[:f]
@@ -128,22 +114,15 @@ command [:template, :tm] do |c|
128
114
  end
129
115
  end
130
116
 
131
- desc 'Review supported languages'
132
- command [:language, :lang] do |c|
133
-
134
- c.default_command :list
135
-
136
- c.desc 'List the supported languages'
137
- c.command :list do |sub|
138
- sub.action do
139
- summary = Cog.language_summary
140
- w = summary.collect {|info| info.name.length}.max
141
- summary.each do |info|
142
- puts info.to_s(w)
143
- end
117
+ desc 'List supported languages'
118
+ command :lang do |c|
119
+ c.action do
120
+ summary = Cog.language_summary
121
+ w = summary.collect {|info| info.name.length}.max
122
+ summary.each do |info|
123
+ puts info.to_s(w)
144
124
  end
145
125
  end
146
-
147
126
  end
148
127
 
149
128
  pre do |gopt, command, opt, args|
@@ -0,0 +1,7 @@
1
+ <% unless abstract? %>
2
+ <%= return_type.to_prim %> <%= seed.name %>::<%= name %>(<%= params.collect(&:stamp_decl).join ', ' %>)
3
+ {
4
+ // keep: <%= keep_name %>
5
+ }
6
+
7
+ <% end %>
@@ -0,0 +1,7 @@
1
+ /**
2
+ <%= desc %>
3
+ <% params.each do |p| %>
4
+ @param <%= p.name %> <%= p.desc %>
5
+ <% end %>
6
+ */
7
+ <%= return_type.to_prim %> <%= name %>(<%= params.collect(&:stamp_decl).join ', ' %>)<% if abstract? %> = 0<% end %>;
@@ -0,0 +1,11 @@
1
+ <%= warning %>
2
+
3
+ #include "<%= header_path %>"
4
+
5
+ <% if in_scope %>
6
+ <%= use_named_scope in_scope %>
7
+ <% end %>
8
+
9
+ <% features.each do |f| %>
10
+ <%= f.stamp_method %>
11
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <%= warning %>
2
+
3
+ <%= guard %>
4
+
5
+ <% if in_scope %>
6
+ <%= named_scope_begin in_scope %>
7
+ <% end %>
8
+
9
+ class <%= name %>
10
+ {
11
+ <% features.each do |f| %>
12
+ <%= f.stamp_method %>
13
+ <% end %>
14
+ };
15
+
16
+ <%= end_all_scopes %>
@@ -0,0 +1 @@
1
+ <%= type.to_prim %> <% if qualify? %><%= scope %>::<% end %><%= name %>
data/lib/cog.rb CHANGED
@@ -4,6 +4,7 @@ require 'rainbow'
4
4
 
5
5
  require 'cog/errors'
6
6
  require 'cog/native_extensions'
7
+ require 'cog/primitive'
7
8
 
8
9
  # This top level module serves as a singleton instance of the {Config} interface. It is configured with various cogfiles, which are evaluated as instances of {DSL::Cogfile}.
9
10
  module Cog
@@ -18,6 +19,7 @@ module Cog
18
19
  autoload :Helpers, 'cog/helpers'
19
20
  autoload :Language, 'cog/language'
20
21
  autoload :Plugin, 'cog/plugin'
22
+ autoload :Seed, 'cog/seed'
21
23
  autoload :VERSION, 'cog/version'
22
24
 
23
25
  extend Config
@@ -35,4 +37,9 @@ module Cog
35
37
  nil
36
38
  end
37
39
 
40
+ def self.seed(name, &block)
41
+ s = DSL::SeedDSL.new name
42
+ block.call s unless block.nil?
43
+ s.seed
44
+ end
38
45
  end
@@ -17,7 +17,6 @@ module Cog
17
17
  # @yield within this block the {#active_language} will be set to the desired value
18
18
  # @return [Object] the value returned by the block
19
19
  def activate_language(key, opt={}, &block)
20
- throw :ActivateLanguageRequiresABlock if block.nil?
21
20
  opt, key = key, nil if key.is_a? Hash
22
21
  key = if opt[:ext]
23
22
  ext = opt[:ext].to_s.downcase
@@ -31,9 +30,11 @@ module Cog
31
30
  end
32
31
  if key
33
32
  @active_languages << @language[key]
34
- r = block.call
35
- @active_languages.pop
36
- r
33
+ if block
34
+ r = block.call
35
+ @active_languages.pop
36
+ r
37
+ end
37
38
  else
38
39
  block.call
39
40
  end
data/lib/cog/dsl.rb CHANGED
@@ -2,8 +2,9 @@ module Cog
2
2
  module DSL
3
3
 
4
4
  autoload :Cogfile, 'cog/dsl/cogfile'
5
+ autoload :FeatureDSL, 'cog/dsl/feature_dsl'
5
6
  autoload :LanguageDSL, 'cog/dsl/language_dsl'
6
- autoload :PluginDSL, 'cog/dsl/plugin_dsl'
7
+ autoload :SeedDSL, 'cog/dsl/seed_dsl'
7
8
 
8
9
  end
9
10
  end
@@ -33,12 +33,12 @@ module Cog
33
33
  nil
34
34
  end
35
35
 
36
- # Define the directory in which to generate code
36
+ # Define the directory in which to generate code. A call to this method will be ignored if the containing cogfile is being treated as a plugin.
37
37
  # @param path [String] a file system path to a directory
38
38
  # @param absolute [Boolean] if +false+, the path is relative to {Config::ProjectConfig#project_root}
39
39
  # @return [nil]
40
40
  def project_path(path, absolute=false)
41
- return if @cogfile_context[:plugin_path_only]
41
+ return if plugin_path_only? || plugin?
42
42
  path = File.join @cogfile_context[:cogfile_dir], path unless absolute
43
43
  config_eval { @project_path = path }
44
44
  end
@@ -48,7 +48,7 @@ module Cog
48
48
  # @param absolute [Boolean] if +false+, the path is relative to {Config::ProjectConfig#project_root}
49
49
  # @return [nil]
50
50
  def generator_path(path, absolute=false)
51
- return if @cogfile_context[:plugin_path_only]
51
+ return if plugin_path_only?
52
52
  add_config_path :generator, path, absolute
53
53
  end
54
54
 
@@ -57,15 +57,16 @@ module Cog
57
57
  # @param absolute [Boolean] if +false+, the path is relative to {Config::ProjectConfig#project_root}
58
58
  # @return [nil]
59
59
  def template_path(path, absolute=false)
60
- return if @cogfile_context[:plugin_path_only]
60
+ return if plugin_path_only?
61
61
  add_config_path :template, path, absolute
62
62
  end
63
63
 
64
- # Define a directory in which to find plugins
64
+ # Define a directory in which to find plugins. A call to this method will be ignored if the containing cogfile is itself being treated as a plugin.
65
65
  # @param path [String] a file system path
66
66
  # @param absolute [Boolean] if +false+, the path is relative to {Config::ProjectConfig#project_root}
67
67
  # @return [nil]
68
68
  def plugin_path(path, absolute=false)
69
+ return if plugin?
69
70
  path = add_config_path :plugin, path, absolute
70
71
  if path && File.exists?(path)
71
72
  raise Errors::PluginPathIsNotADirectory.new path unless File.directory?(path)
@@ -77,7 +78,7 @@ module Cog
77
78
  # @param map [Hash] key-value pairs from this mapping will override the default language map supplied by +cog+
78
79
  # @return [nil]
79
80
  def language_extensions(map)
80
- return if @cogfile_context[:plugin_path_only]
81
+ return if plugin_path_only?
81
82
  config_eval do
82
83
  map.each_pair do |key, value|
83
84
  @language_extension_map[key.to_s.downcase] = value.to_s.downcase
@@ -90,7 +91,7 @@ module Cog
90
91
  # @yieldparam lang [LanguageDSL] an interface for defining the language
91
92
  # @return [Object] the return value of the block
92
93
  def language(key, &block)
93
- return if @cogfile_context[:plugin_path_only]
94
+ return if plugin_path_only?
94
95
  dsl = LanguageDSL.new key
95
96
  r = block.call dsl
96
97
  lang = dsl.finalize
@@ -100,25 +101,43 @@ module Cog
100
101
  r
101
102
  end
102
103
 
103
- # Register an autoload variable in the class {GeneratorSandbox}. That way when generators are run as instances of a sandbox, they will be able to load plugins just by referencing them using the provided +identifier_name+.
104
+ # Register an autoload variable in the class {GeneratorSandbox}. That way when generators are run as instances of a sandbox, they will be able to load plugins just by referencing them using the provided +identifier_name+. A call to this method will be ignored unless the containing cogfile is being treated as a plugin.
104
105
  # @param identifier_name [String] identifier by which the plugin can be referenced in generators
105
106
  # @param path [String] path to the ruby file to load when the identifier is referenced (relative to the cogfile)
106
107
  # @return [nil]
107
108
  def autoload_plugin(identifier_name, path)
108
- GeneratorSandbox.autoload_plugin(identifier_name, File.join(@cogfile_context[:plugin].path, path))
109
+ if plugin?
110
+ GeneratorSandbox.autoload_plugin(identifier_name, File.join(plugin.path, path))
111
+ end
109
112
  end
110
113
 
111
- # Define a block to call when stamping a generator for a plugin. A call to this method should only be used in plugin cogfiles.
114
+ # Define a block to call when stamping a generator for a plugin. A call to this method will be ignored unless the containing cogfile is being treated as a plugin.
112
115
  # @yieldparam name [String] name of the generator to stamp
113
116
  # @yieldparam dest [String] file system path where the file will be created
114
117
  # @yieldreturn [nil]
115
118
  # @return [nil]
116
119
  def stamp_generator(&block)
117
- @cogfile_context[:plugin].stamp_generator_block = block
120
+ plugin.stamp_generator_block = block if plugin?
118
121
  end
119
122
 
120
123
  private
121
124
 
125
+ # @return [Plugin,nil] the plugin description
126
+ def plugin
127
+ @cogfile_context[:plugin]
128
+ end
129
+
130
+ # @return [Boolean] is this a plugin cogfile?
131
+ def plugin?
132
+ !@cogfile_context[:plugin].nil?
133
+ end
134
+
135
+ # @return [Boolean] should only the {#plugin_path} call be processed?
136
+ def plugin_path_only?
137
+ @cogfile_context[:plugin_path_only]
138
+ end
139
+
140
+ # @return [String] path to the cogfile
122
141
  def cogfile_path
123
142
  @cogfile_context[:cogfile_path]
124
143
  end