gn 0.0.1.alpha → 0.0.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/Readme.md +1 -1
- data/bin/gn +44 -12
- metadata +7 -7
data/Readme.md
CHANGED
@@ -27,7 +27,7 @@ Say you want to generate always a typical README file, like this one, you should
|
|
27
27
|
* Create a templates folder and the template itself.
|
28
28
|
|
29
29
|
mkdir readme/templates
|
30
|
-
touch readme/templates/readme
|
30
|
+
touch readme/templates/readme.mote
|
31
31
|
|
32
32
|
* Inside the readme template, put your typical Readme content.
|
33
33
|
* To include dynamic data, just use {{variable}}, where variable is a public method on Plan::Readme. So writing {{name}} will produce CHANGEME.
|
data/bin/gn
CHANGED
@@ -9,33 +9,49 @@ class Gn
|
|
9
9
|
|
10
10
|
def initialize(name)
|
11
11
|
@name = name
|
12
|
-
|
12
|
+
if location
|
13
|
+
process
|
14
|
+
else
|
15
|
+
puts "Plan named '#{name}' doesn't exist"
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
|
-
def
|
19
|
+
def process
|
16
20
|
load_plan
|
17
|
-
Plan.constants.each do |
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
f.write Mote.parse(File.read(template), blueprint).call
|
21
|
+
Plan.constants.each do |constant_name|
|
22
|
+
constant = Plan.const_get(constant_name)
|
23
|
+
if constant.class == Class
|
24
|
+
puts "-> Generating #{constant_name}"
|
25
|
+
generate_from constant_name, constant.new
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
30
|
+
def generate_from(constant_name, blueprint)
|
31
|
+
template = File.join(templates_location,
|
32
|
+
"#{constant_name.to_s.downcase}.mote")
|
33
|
+
FileUtils.mkdir_p(File.dirname(blueprint.destination))
|
34
|
+
File.open(blueprint.destination, "w") do |f|
|
35
|
+
f.write Mote.parse(File.read(template), blueprint).call
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
27
39
|
def location
|
28
|
-
@location ||=
|
40
|
+
@location ||= available_locations.detect do |path|
|
29
41
|
Dir.exists?(path)
|
30
42
|
end
|
31
43
|
end
|
32
44
|
|
45
|
+
def available_locations
|
46
|
+
[name, "./plans/#{name}", "#{ENV['HOME']}/.plans/#{name}"]
|
47
|
+
end
|
48
|
+
|
33
49
|
def templates_location
|
34
50
|
File.join(@location, "templates")
|
35
51
|
end
|
36
52
|
|
37
53
|
def load_plan
|
38
|
-
file = Tempfile.new('plan_init')
|
54
|
+
file = Tempfile.new('plan_init.rb')
|
39
55
|
file.write(File.read(File.join(location, "init.rb")))
|
40
56
|
file.close
|
41
57
|
open_with_editor(file)
|
@@ -46,7 +62,23 @@ class Gn
|
|
46
62
|
editor = ENV['EDITOR'] || "vi"
|
47
63
|
system("#{editor} #{file.path}")
|
48
64
|
end
|
49
|
-
|
65
|
+
|
50
66
|
end
|
51
67
|
|
52
|
-
|
68
|
+
name = ARGV.first.to_s.strip
|
69
|
+
|
70
|
+
if name.empty? || name == "-h" || name == "--help"
|
71
|
+
puts <<-USAGE
|
72
|
+
Usage: gn <name>
|
73
|
+
|
74
|
+
Run the first <name> generator that is found in the following locations:
|
75
|
+
|
76
|
+
* <name>/init.rb
|
77
|
+
* plans/<name>/init.rb
|
78
|
+
* ~/.plans/<name>/init.rb
|
79
|
+
|
80
|
+
See http://lucasefe.github.com/gn for more information.
|
81
|
+
USAGE
|
82
|
+
else
|
83
|
+
Gn.new(name)
|
84
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Leandro López
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-06-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: mote
|
18
|
-
requirement: &
|
18
|
+
requirement: &70315208785640 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
version: '0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *70315208785640
|
27
27
|
description: Simple Generator for the masses
|
28
28
|
email:
|
29
29
|
- lucasefe@gmail.com
|
@@ -51,9 +51,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
|
-
- - ! '
|
54
|
+
- - ! '>='
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
56
|
+
version: '0'
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
59
|
rubygems_version: 1.8.11
|