jackdempsey-beet 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +6 -0
- data/VERSION +1 -1
- data/beet.gemspec +2 -2
- data/bin/beet +6 -17
- data/lib/beet/executor.rb +97 -26
- data/lib/beet/recipes/rails/jquery.rb +1 -2
- metadata +2 -2
data/TODO
CHANGED
@@ -0,0 +1,6 @@
|
|
1
|
+
* refactor methods in bin/beet to use each other (lots of duplication between generate and just_recipe
|
2
|
+
* refactor so you can use template names in the recipe calls along with local paths and remote paths
|
3
|
+
|
4
|
+
* fixup places where its obviously just rails stuff, like add_gems
|
5
|
+
* generate command in bin/beet should have executor stuff pulled out of case, ie, it should always run
|
6
|
+
* create a better way to mixin things from rails/whatever as needed inside Beet::Executor
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/beet.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{beet}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jack Dempsey"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-04}
|
10
10
|
s.default_executable = %q{beet}
|
11
11
|
s.email = %q{jack.dempsey@gmail.com}
|
12
12
|
s.executables = ["beet"]
|
data/bin/beet
CHANGED
@@ -15,27 +15,16 @@ class BeetRunner < Thor
|
|
15
15
|
map "--list" => :list
|
16
16
|
|
17
17
|
desc 'generate [app_name]', "the main app generate method"
|
18
|
-
method_options :recipes => :optional, :gems => :optional, :template => :optional
|
19
|
-
def generate(app_name,
|
20
|
-
|
21
|
-
|
22
|
-
puts "Generating rails project #{app_name}..."
|
23
|
-
if options[:template]
|
24
|
-
system("rails #{app_name} -m #{::TEMPLATE_LOCATIONS[options[:template]]}")
|
25
|
-
else
|
26
|
-
system("rails #{app_name}")
|
27
|
-
end
|
28
|
-
executor = Beet::Executor.new(app_name, options)
|
29
|
-
executor.start
|
30
|
-
else
|
31
|
-
puts "type not recognized!"
|
32
|
-
end
|
18
|
+
method_options :recipes => :optional, :gems => :optional, :template => :optional, :save => :optional, :use => :optional
|
19
|
+
def generate(app_name, project_type=:rails)
|
20
|
+
executor = Beet::Executor.new(app_name, options.merge('project_type' => project_type))
|
21
|
+
executor.start
|
33
22
|
end
|
34
23
|
|
35
24
|
desc 'just_recipe', "when you just need a recipe"
|
36
|
-
method_options :recipes => :optional, :gems => :optional
|
25
|
+
method_options :recipes => :optional, :gems => :optional, :save => :optional, :use => :optional
|
37
26
|
def just_recipe(app_name='.')
|
38
|
-
executor = Beet::Executor.new(app_name, options)
|
27
|
+
executor = Beet::Executor.new(app_name, options.merge('generate' => false))
|
39
28
|
executor.start
|
40
29
|
end
|
41
30
|
|
data/lib/beet/executor.rb
CHANGED
@@ -2,51 +2,60 @@ require 'open-uri'
|
|
2
2
|
require 'beet/logger'
|
3
3
|
module Beet
|
4
4
|
class Executor
|
5
|
+
BEET_DATA_FILE = "~/.beet.yml"
|
5
6
|
include Beet::Execution
|
6
7
|
include Beet::FileSystem
|
7
8
|
include Beet::Interaction
|
8
9
|
|
9
|
-
# TODO create a better way to mixin things from rails/whatever as needed
|
10
10
|
include Beet::Rails
|
11
11
|
include Beet::Capistrano
|
12
12
|
include Beet::SCM
|
13
13
|
|
14
|
-
attr_reader :root, :logger
|
14
|
+
attr_reader :root, :logger, :options, :template
|
15
15
|
attr_accessor :recipes, :project_name, :gems
|
16
16
|
|
17
17
|
def initialize(project_name, options={}) # :nodoc:
|
18
|
-
@root =
|
19
|
-
root
|
20
|
-
elsif project_name.include?('/')
|
21
|
-
File.dirname(project_name)
|
22
|
-
else
|
23
|
-
Dir.pwd
|
24
|
-
end
|
18
|
+
@root = calculate_project_root(project_name)
|
25
19
|
@project_name = project_name == '.' ? File.basename(Dir.pwd) : project_name
|
26
20
|
@logger = Beet::Logger.new
|
27
21
|
@gems = []
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
22
|
+
@template = options[:template]
|
23
|
+
@options = options
|
24
|
+
@recipes = []
|
25
|
+
@project_type = options[:project_type]
|
26
|
+
@generate = true unless options[:generate] == false
|
27
|
+
extract_commands_from_options
|
28
|
+
end
|
29
|
+
|
30
|
+
def start
|
31
|
+
if @options[:use]
|
32
|
+
puts "Loading saved configuration: #{@options[:use]}"
|
33
|
+
data = load_saved_recipe_file
|
34
|
+
if config = data[@options[:use]]
|
35
|
+
@gems.concat(config[:gems]) if config[:gems]
|
36
|
+
@template = config[:template] if config[:template]
|
37
|
+
@recipes.concat(config[:recipes]) if config[:recipes]
|
35
38
|
end
|
36
39
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
case @project_type
|
42
|
+
when :rails
|
43
|
+
if @generate
|
44
|
+
puts "Generating rails project #{project_name}..."
|
45
|
+
if @options[:template]
|
46
|
+
system("rails #{project_name} -m #{TEMPLATE_LOCATIONS[options[:template]]}")
|
47
|
+
else
|
48
|
+
system("rails #{project_name}")
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
45
|
-
end
|
46
52
|
|
47
|
-
def start
|
48
53
|
run_recipes
|
49
54
|
add_gems
|
55
|
+
|
56
|
+
if @options[:save]
|
57
|
+
save_run
|
58
|
+
end
|
50
59
|
end
|
51
60
|
|
52
61
|
def run_recipes
|
@@ -60,6 +69,25 @@ module Beet
|
|
60
69
|
end
|
61
70
|
end
|
62
71
|
|
72
|
+
def log(*args)
|
73
|
+
logger.log(*args)
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def calculate_project_root(project_name)
|
79
|
+
# if the name looks like ~/projects/foobar then thats the root
|
80
|
+
if project_name.include?('/')
|
81
|
+
project_name
|
82
|
+
# if we're running inside the app, then current dir is it
|
83
|
+
elsif File.basename(Dir.pwd) == project_name
|
84
|
+
Dir.pwd
|
85
|
+
# assume the root is ./project_name
|
86
|
+
else
|
87
|
+
File.join(Dir.pwd, project_name)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
63
91
|
def add_gems
|
64
92
|
if @gems
|
65
93
|
@gems.each do |gem_data|
|
@@ -68,11 +96,54 @@ module Beet
|
|
68
96
|
end
|
69
97
|
end
|
70
98
|
|
71
|
-
def
|
72
|
-
|
99
|
+
def extract_commands_from_options
|
100
|
+
if @options[:gems]
|
101
|
+
@options[:gems].split(/[\s,]+/).each do |gem|
|
102
|
+
if location = gem_location(gem)
|
103
|
+
@gems << {:name => gem, :source => location}
|
104
|
+
else
|
105
|
+
puts "gem: #{gem} not found. Did you spell it correctly? If so, submit a patch with its location!"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
if @options[:recipes]
|
110
|
+
@options[:recipes].split(/[\s,]+/).each do |recipe|
|
111
|
+
if file = recipe_location(recipe)
|
112
|
+
@recipes << file
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
73
116
|
end
|
74
117
|
|
75
|
-
|
118
|
+
def save_run
|
119
|
+
require 'yaml'
|
120
|
+
name = if options[:save] == true
|
121
|
+
ask("Enter a name for this configuration: ")
|
122
|
+
else
|
123
|
+
options[:save]
|
124
|
+
end
|
125
|
+
data = load_saved_recipe_file
|
126
|
+
data[name] = {:gems => @gems, :recipes => @recipes, :template => @template}
|
127
|
+
write_saved_recipe_file(data)
|
128
|
+
end
|
129
|
+
|
130
|
+
def beet_data_file
|
131
|
+
File.expand_path(BEET_DATA_FILE)
|
132
|
+
end
|
133
|
+
|
134
|
+
def load_saved_recipe_file
|
135
|
+
if File.exists?(beet_data_file)
|
136
|
+
YAML.load_file(beet_data_file)
|
137
|
+
else
|
138
|
+
{}
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def write_saved_recipe_file(data)
|
143
|
+
File.open(beet_data_file, "wb") do |f|
|
144
|
+
f.write(YAML::dump(data))
|
145
|
+
end
|
146
|
+
end
|
76
147
|
|
77
148
|
def gem_location(gem_name)
|
78
149
|
GEM_LOCATIONS[gem_name]
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
1
|
+
FileUtils.rm_r Dir.glob("public/javascripts/*.js")
|
2
2
|
|
3
3
|
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js > public/javascripts/jquery.js"
|
4
4
|
run "curl -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js"
|
5
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackdempsey-beet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Dempsey
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-04 00:00:00 -07:00
|
13
13
|
default_executable: beet
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|