jackdempsey-beet 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +1 -0
- data/VERSION +1 -1
- data/beet.gemspec +1 -1
- data/bin/beet +13 -3
- data/lib/beet/executor.rb +26 -16
- metadata +1 -1
data/TODO
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
* refactor methods in bin/beet to use each other (lots of duplication between generate and just_recipe
|
2
|
+
( maybe just make generate a boolean option rather than a method )
|
2
3
|
* refactor so you can use template names in the recipe calls along with local paths and remote paths
|
3
4
|
|
4
5
|
* fixup places where its obviously just rails stuff, like add_gems
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/beet.gemspec
CHANGED
data/bin/beet
CHANGED
@@ -15,6 +15,7 @@ class BeetRunner < Thor
|
|
15
15
|
map "-h" => :help
|
16
16
|
map "-v" => :version
|
17
17
|
map "-l" => :list
|
18
|
+
map "-d" => :display
|
18
19
|
map "--list" => :list
|
19
20
|
|
20
21
|
desc 'generate [app_name]', "the main app generate method"
|
@@ -39,10 +40,17 @@ class BeetRunner < Thor
|
|
39
40
|
recipes = paths.map do |path|
|
40
41
|
Dir.glob(path)
|
41
42
|
end.flatten.compact
|
42
|
-
puts "
|
43
|
+
puts "\nRecipes: (e.g. beet -g app -r rails/git)"
|
43
44
|
pp recipes
|
44
|
-
puts "
|
45
|
-
pp TEMPLATE_LOCATIONS.
|
45
|
+
puts "\nTemplates: (e.g. beet -g app -t bort)"
|
46
|
+
pp TEMPLATE_LOCATIONS.sort.map {|array| array[0] + " => " + array[1]}
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'display', "Display the code for the recipes/templates"
|
50
|
+
method_options :recipes => :optional, :template => :optional
|
51
|
+
def display(app_name='.')
|
52
|
+
executor = Beet::Executor.new(app_name,options.merge('generate' => false, 'display' => true))
|
53
|
+
executor.start
|
46
54
|
end
|
47
55
|
|
48
56
|
desc 'version', "the current version of beet"
|
@@ -60,6 +68,8 @@ Usage: #{$0} /path/to/your/app [options]
|
|
60
68
|
|
61
69
|
Options:
|
62
70
|
-g, --generate Run the generate command to build a project
|
71
|
+
-j, --just_recipe Run the just_recipe command to only run specified recipes, templates, etc.
|
72
|
+
-d, --display Instead of running, show the template or recipe body
|
63
73
|
|
64
74
|
Beet Info:
|
65
75
|
-v, --version Show the Beet version number and quit.
|
data/lib/beet/executor.rb
CHANGED
@@ -25,6 +25,7 @@ module Beet
|
|
25
25
|
@recipes = []
|
26
26
|
@project_type = options[:project_type]
|
27
27
|
@generate = true unless options[:generate] == false
|
28
|
+
@display = options[:display]
|
28
29
|
extract_commands_from_options
|
29
30
|
end
|
30
31
|
|
@@ -39,34 +40,43 @@ module Beet
|
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
if @display
|
44
|
+
puts open(TEMPLATE_LOCATIONS[options[:template]]).read
|
45
|
+
else
|
46
|
+
case @project_type
|
47
|
+
when :rails
|
48
|
+
if @generate
|
49
|
+
puts "Generating rails project #{project_name}..."
|
50
|
+
if @options[:template]
|
51
|
+
system("rails #{project_name} -m #{TEMPLATE_LOCATIONS[options[:template]]}")
|
52
|
+
else
|
53
|
+
system("rails #{project_name}")
|
54
|
+
end
|
50
55
|
end
|
51
56
|
end
|
52
|
-
end
|
53
57
|
|
54
|
-
|
55
|
-
|
56
|
-
add_gems
|
58
|
+
add_gems
|
57
59
|
|
58
|
-
|
60
|
+
print_todo
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
+
if @options[:save]
|
63
|
+
save_run
|
64
|
+
end
|
62
65
|
end
|
66
|
+
|
67
|
+
run_recipes
|
68
|
+
|
63
69
|
end
|
64
70
|
|
65
71
|
def run_recipes
|
66
72
|
@recipes.each do |recipe|
|
67
73
|
begin
|
68
74
|
code = open(recipe).read
|
69
|
-
|
75
|
+
if @display
|
76
|
+
puts code
|
77
|
+
else
|
78
|
+
in_root { self.instance_eval(code) }
|
79
|
+
end
|
70
80
|
rescue LoadError, Errno::ENOENT => e
|
71
81
|
raise "The recipe [#{recipe}] could not be loaded. Error: #{e}"
|
72
82
|
end
|