cog 0.0.20 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/cog +54 -53
- data/lib/cog.rb +4 -3
- data/lib/cog/built_in_tools/basic.rb +10 -0
- data/lib/cog/built_in_tools/basic/cog_tool.rb +15 -0
- data/lib/cog/config.rb +111 -33
- data/lib/cog/config/tool.rb +99 -0
- data/lib/cog/controllers.rb +13 -0
- data/lib/cog/controllers/generator_controller.rb +45 -0
- data/lib/cog/controllers/template_controller.rb +31 -0
- data/lib/cog/controllers/tool_controller.rb +53 -0
- data/lib/cog/errors.rb +51 -9
- data/lib/cog/generator.rb +1 -74
- data/lib/cog/helpers.rb +1 -0
- data/lib/cog/helpers/cascading_template_set.rb +75 -0
- data/lib/cog/helpers/string.rb +9 -3
- data/lib/cog/version.rb +1 -1
- data/templates/basic/generator.rb.erb +12 -0
- data/templates/{cog/generator/basic-template.txt.erb.erb → basic/template.txt.erb.erb} +0 -0
- data/templates/cog/{tool → custom_tool}/Gemfile.erb +4 -0
- data/templates/cog/{tool → custom_tool}/LICENSE.erb +1 -1
- data/templates/cog/custom_tool/README.markdown.erb +18 -0
- data/templates/cog/custom_tool/Rakefile.erb +15 -0
- data/templates/cog/custom_tool/cog_tool.rb.erb +15 -0
- data/templates/cog/custom_tool/generator.rb.erb.erb +9 -0
- data/templates/cog/{tool → custom_tool}/template.txt.erb.erb +0 -0
- data/templates/cog/custom_tool/tool.gemspec.erb +18 -0
- data/templates/cog/{tool → custom_tool}/tool.rb.erb +5 -13
- data/templates/cog/{tool → custom_tool}/version.rb.erb +1 -1
- metadata +24 -17
- data/lib/cog/tool.rb +0 -81
- data/templates/cog/generator/basic.rb.erb +0 -12
- data/templates/cog/tool/API.rdoc.erb +0 -7
- data/templates/cog/tool/README.markdown.erb +0 -18
- data/templates/cog/tool/Rakefile.erb +0 -15
- data/templates/cog/tool/generator.rb.erb.erb +0 -6
- data/templates/cog/tool/tool.gemspec.erb +0 -18
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
require 'rdoc/task'
|
5
|
+
|
6
|
+
YARD::Rake::YardocTask.new do |t|
|
7
|
+
t.files = ["lib/**/*.rb", "README.markdown"]
|
8
|
+
t.options = [
|
9
|
+
'--query', '@api.text != "unstable" && @api.text != "developer"']
|
10
|
+
end
|
11
|
+
|
12
|
+
spec = eval(File.read('<%= @tool_name %>.gemspec'))
|
13
|
+
|
14
|
+
Gem::PackageTask.new(spec) do |pkg|
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'cog'
|
2
|
+
|
3
|
+
# Register <%= @tool_name %> as a tool with cog
|
4
|
+
Cog::Config.instance.register_tool __FILE__ do |tool|
|
5
|
+
|
6
|
+
# Define how new <%= @tool_name %> generators are created
|
7
|
+
#
|
8
|
+
# Add context as required by your generator template.
|
9
|
+
#
|
10
|
+
# When the block is executed, +self+ will be an instance of Cog::Config::Tool::GeneratorStamper
|
11
|
+
tool.stamp_generator do
|
12
|
+
stamp '<%= @tool_name %>/generator.rb', generator_dest, :absolute_destination => true
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Ensure we require the local version and not one we might have installed already
|
2
|
+
require File.join([File.dirname(__FILE__),'lib','<%= @tool_name %>/version.rb'])
|
3
|
+
spec = Gem::Specification.new do |s|
|
4
|
+
s.name = '<%= @tool_name %>'
|
5
|
+
s.version = <%= @tool_module %>::VERSION
|
6
|
+
s.author = '<%= @tool_author %>'
|
7
|
+
s.email = '<%= @tool_email %>'
|
8
|
+
s.homepage = ''
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = '<%= @tool_description %>'
|
11
|
+
s.files = %w(LICENSE) + Dir.glob('cog/**/*') + Dir.glob('lib/**/*.rb')
|
12
|
+
s.require_paths << 'lib'
|
13
|
+
s.has_rdoc = 'yard'
|
14
|
+
s.extra_rdoc_files = ['API.rdoc']
|
15
|
+
s.rdoc_options << '--title' << '<%= @tool_name %>' << '-ri'
|
16
|
+
s.add_development_dependency('rake')
|
17
|
+
s.add_development_dependency('yard')
|
18
|
+
end
|
@@ -1,18 +1,10 @@
|
|
1
1
|
$LOAD_PATH << File.join(File.dirname(__FILE__))
|
2
|
-
require '<%= @
|
2
|
+
require '<%= @tool_name %>/version'
|
3
3
|
require 'cog'
|
4
4
|
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# Set the template which is used to create generators for this tool
|
10
|
-
# Do not remove this line
|
11
|
-
Cog::Config.instance.tool_generator_template = '<%= @name %>/generator.rb'
|
12
|
-
|
13
|
-
# Custom cog tool <%= @name %>
|
14
|
-
module <%= @module_name %>
|
15
|
-
|
5
|
+
# Custom cog tool <%= @tool_name %>
|
6
|
+
module <%= @tool_module %>
|
7
|
+
|
16
8
|
# Root of the DSL
|
17
9
|
# Feel free to rename this to something more appropriate
|
18
10
|
def self.widget(generator_name, &block)
|
@@ -36,7 +28,7 @@ module <%= @module_name %>
|
|
36
28
|
end
|
37
29
|
|
38
30
|
def generate
|
39
|
-
stamp '<%= @
|
31
|
+
stamp '<%= @tool_name %>/<%= @tool_name %>.txt', "generated_#{@generator_name}.txt"
|
40
32
|
end
|
41
33
|
end
|
42
34
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.20
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kevin Tonon
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-11-
|
18
|
+
date: 2012-11-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: gli
|
@@ -85,30 +85,37 @@ files:
|
|
85
85
|
- bin/cog
|
86
86
|
- Default.cogfile
|
87
87
|
- LICENSE
|
88
|
-
- templates/
|
89
|
-
- templates/
|
90
|
-
- templates/cog/
|
91
|
-
- templates/cog/
|
92
|
-
- templates/cog/
|
93
|
-
- templates/cog/
|
94
|
-
- templates/cog/
|
95
|
-
- templates/cog/
|
96
|
-
- templates/cog/
|
97
|
-
- templates/cog/
|
98
|
-
- templates/cog/
|
99
|
-
- templates/cog/
|
88
|
+
- templates/basic/generator.rb.erb
|
89
|
+
- templates/basic/template.txt.erb.erb
|
90
|
+
- templates/cog/custom_tool/cog_tool.rb.erb
|
91
|
+
- templates/cog/custom_tool/Gemfile.erb
|
92
|
+
- templates/cog/custom_tool/generator.rb.erb.erb
|
93
|
+
- templates/cog/custom_tool/LICENSE.erb
|
94
|
+
- templates/cog/custom_tool/Rakefile.erb
|
95
|
+
- templates/cog/custom_tool/README.markdown.erb
|
96
|
+
- templates/cog/custom_tool/template.txt.erb.erb
|
97
|
+
- templates/cog/custom_tool/tool.gemspec.erb
|
98
|
+
- templates/cog/custom_tool/tool.rb.erb
|
99
|
+
- templates/cog/custom_tool/version.rb.erb
|
100
100
|
- templates/warning.h.erb
|
101
|
+
- lib/cog/built_in_tools/basic/cog_tool.rb
|
102
|
+
- lib/cog/built_in_tools/basic.rb
|
101
103
|
- lib/cog/config/cogfile.rb
|
104
|
+
- lib/cog/config/tool.rb
|
102
105
|
- lib/cog/config.rb
|
106
|
+
- lib/cog/controllers/generator_controller.rb
|
107
|
+
- lib/cog/controllers/template_controller.rb
|
108
|
+
- lib/cog/controllers/tool_controller.rb
|
109
|
+
- lib/cog/controllers.rb
|
103
110
|
- lib/cog/errors.rb
|
104
111
|
- lib/cog/generator.rb
|
112
|
+
- lib/cog/helpers/cascading_template_set.rb
|
105
113
|
- lib/cog/helpers/string.rb
|
106
114
|
- lib/cog/helpers.rb
|
107
115
|
- lib/cog/spec_helpers/matchers/match_maker.rb
|
108
116
|
- lib/cog/spec_helpers/matchers.rb
|
109
117
|
- lib/cog/spec_helpers/runner.rb
|
110
118
|
- lib/cog/spec_helpers.rb
|
111
|
-
- lib/cog/tool.rb
|
112
119
|
- lib/cog/version.rb
|
113
120
|
- lib/cog.rb
|
114
121
|
- yard-templates/default/fulldoc/html/css/common.css
|
data/lib/cog/tool.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'cog/config'
|
2
|
-
require 'cog/generator'
|
3
|
-
require 'rainbow'
|
4
|
-
|
5
|
-
module Cog
|
6
|
-
|
7
|
-
# @see https://github.com/ktonon/cog#tools Introduction to Tools
|
8
|
-
class Tool
|
9
|
-
|
10
|
-
# A list of available tools
|
11
|
-
# @param verbose [Boolean] should full paths be listed for tools which are explicitly referenced?
|
12
|
-
# @return [Array<String>] a list of strings which can be passed to +require+
|
13
|
-
def self.list(verbose=false)
|
14
|
-
x = (ENV['COG_TOOLS'] || '').split ':'
|
15
|
-
if x.all? {|path| path.slice(-3..-1) != '.rb' || File.exists?(path)}
|
16
|
-
if verbose
|
17
|
-
x.collect {|path| path.slice(-3..-1) == '.rb' ? File.expand_path(path) : path}
|
18
|
-
else
|
19
|
-
x.collect {|path| path.slice(-3..-1) == '.rb' ? File.basename(path).slice(0..-4) : path}
|
20
|
-
end
|
21
|
-
else
|
22
|
-
x.each do |path|
|
23
|
-
if !File.exists? path
|
24
|
-
STDERR.write "No such cog tool at path '#{path}'\n".color(:red)
|
25
|
-
elsif !File.directory? path
|
26
|
-
STDERR.write "Not a cog tool at path '#{path}'\n".color(:red)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
[]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Generate a new tool with the given name
|
34
|
-
# @param name [String] name of the tool to create. Should not conflict with other tool names
|
35
|
-
# @return [Boolean] was the tool created successfully?
|
36
|
-
def self.create(name)
|
37
|
-
if File.exists? name
|
38
|
-
STDERR.write "A #{File.directory?(name) ? :directory : :file} named '#{name}' already exists\n".color(:red)
|
39
|
-
false
|
40
|
-
else
|
41
|
-
Object.new.instance_eval do
|
42
|
-
extend Generator
|
43
|
-
@name = name.to_s.downcase
|
44
|
-
@module_name = name.to_s.capitalize
|
45
|
-
@letter = name.to_s.slice(0,1).downcase
|
46
|
-
@author = '<Your name goes here>'
|
47
|
-
@email = 'youremail@...'
|
48
|
-
@description = 'A one-liner'
|
49
|
-
@cog_version = Cog::VERSION
|
50
|
-
stamp 'cog/tool/tool.rb', "#{@name}/lib/#{@name}.rb", :absolute_destination => true
|
51
|
-
stamp 'cog/tool/version.rb', "#{@name}/lib/#{@name}/version.rb", :absolute_destination => true
|
52
|
-
stamp 'cog/tool/generator.rb.erb', "#{@name}/cog/templates/#{@name}/generator.rb.erb", :absolute_destination => true
|
53
|
-
stamp 'cog/tool/template.txt.erb', "#{@name}/cog/templates/#{@name}/#{@name}.txt.erb", :absolute_destination => true
|
54
|
-
stamp 'cog/tool/Gemfile', "#{@name}/Gemfile", :absolute_destination => true
|
55
|
-
stamp 'cog/tool/Rakefile', "#{@name}/Rakefile", :absolute_destination => true
|
56
|
-
stamp 'cog/tool/tool.gemspec', "#{@name}/#{@name}.gemspec", :absolute_destination => true
|
57
|
-
stamp 'cog/tool/API.rdoc', "#{@name}/API.rdoc", :absolute_destination => true
|
58
|
-
stamp 'cog/tool/LICENSE', "#{@name}/LICENSE", :absolute_destination => true
|
59
|
-
stamp 'cog/tool/README.markdown', "#{@name}/README.markdown", :absolute_destination => true
|
60
|
-
end
|
61
|
-
true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Find an available tool with the given name
|
66
|
-
# @param name [String] name of the tool to search for
|
67
|
-
# @return [String] a fully qualified tool path, which can be passed to +require+
|
68
|
-
def self.find(name)
|
69
|
-
x = (ENV['COG_TOOLS'] || '').split ':'
|
70
|
-
x.each do |path|
|
71
|
-
if path.slice(-3..-1) == '.rb'
|
72
|
-
short = File.basename(path).slice(0..-4)
|
73
|
-
return path if short == name
|
74
|
-
else
|
75
|
-
return path if path == name
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'rake/clean'
|
2
|
-
require 'rubygems'
|
3
|
-
require 'rubygems/package_task'
|
4
|
-
require 'rdoc/task'
|
5
|
-
|
6
|
-
Rake::RDocTask.new do |rd|
|
7
|
-
rd.main = "API.rdoc"
|
8
|
-
rd.rdoc_files.include("API.rdoc", "lib/**/*.rb")
|
9
|
-
rd.title = '<%= @module_name %> API Docs'
|
10
|
-
end
|
11
|
-
|
12
|
-
spec = eval(File.read('<%= @name %>.gemspec'))
|
13
|
-
|
14
|
-
Gem::PackageTask.new(spec) do |pkg|
|
15
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# Ensure we require the local version and not one we might have installed already
|
2
|
-
require File.join([File.dirname(__FILE__),'lib','<%= @name %>/version.rb'])
|
3
|
-
spec = Gem::Specification.new do |s|
|
4
|
-
s.name = '<%= @name %>'
|
5
|
-
s.version = <%= @module_name %>::VERSION
|
6
|
-
s.author = '<%= @author %>'
|
7
|
-
s.email = '<%= @email %>'
|
8
|
-
s.homepage = ''
|
9
|
-
s.platform = Gem::Platform::RUBY
|
10
|
-
s.summary = '<%= @description %>'
|
11
|
-
s.files = %w(LICENSE) + Dir.glob('cog/**/*') + Dir.glob('lib/**/*.rb')
|
12
|
-
s.require_paths << 'lib'
|
13
|
-
s.has_rdoc = true
|
14
|
-
s.extra_rdoc_files = ['API.rdoc']
|
15
|
-
s.rdoc_options << '--title' << '<%= @name %>' << '-ri'
|
16
|
-
s.add_development_dependency('rake')
|
17
|
-
s.add_development_dependency('rdoc')
|
18
|
-
end
|