sprout 0.5.15 → 0.5.19

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprout might be problematic. Click here for more details.

data/bin/sprout CHANGED
@@ -17,15 +17,12 @@ include PatternPark
17
17
  OPTIONS = {
18
18
  :locations => [],
19
19
  :project_name => nil,
20
- :found_project_name => nil,
21
20
  :sprout_name => nil,
22
21
  :update => false,
23
22
  :update => false,
24
23
  :clean => false
25
24
  }
26
25
 
27
- MANDATORY_OPTIONS = %w( sprout_name )
28
-
29
26
  parser = OptionParser.new do |opts|
30
27
  opts.banner = <<BANNER
31
28
  Sprouts is an open-source, cross-platform project generation and configuration tool
@@ -40,6 +37,11 @@ Options are:
40
37
  BANNER
41
38
  opts.separator ""
42
39
  opts.on("-s", "--sprout=NAME", String,
40
+ "[DEPRECATED] The name of the sprout to create (e.g., as2 as3, haxe, or mxml)"
41
+ ) do |name|
42
+ OPTIONS[:sprout_name] = name
43
+ end
44
+ opts.on("-n", "--name=NAME", String,
43
45
  "The name of the sprout to create (e.g., as2 as3, haxe, or mxml)"
44
46
  ) do |name|
45
47
  OPTIONS[:sprout_name] = name
@@ -63,33 +65,10 @@ BANNER
63
65
  "Show this help message.") { puts opts; exit }
64
66
  opts.parse!(ARGV)
65
67
 
66
- OPTIONS[:project_name] = ARGV.pop
67
-
68
- if(OPTIONS[:sprout_name].nil?)
69
- puts "\n[ERROR] You MUST provide a sprout name.\n\n"
70
- end
71
-
72
- if(OPTIONS[:sprout_name] && !OPTIONS[:project_name])
73
- dir = Sprout.project_path
74
- begin
75
- rakefile = Sprout.rakefile
76
- if(!rakefile.nil? && File.exists?(rakefile))
77
- require rakefile
78
- name = ProjectModel.instance.project_name
79
- end
80
- rescue LoadError
81
- name = File.basename(File.dirname(dir))
82
- end
83
- puts "\n[WARNING] No project name specified, Do you want to use '#{name}' as the project name and install the #{OPTIONS[:sprout_name]} sprout into #{dir}? [Yn]\n\n"
84
- answer = $stdin.gets.chomp
85
- if(answer.downcase != "y" && answer != "")
86
- puts opts; exit
87
- end
88
- OPTIONS[:found_project_name] = name
89
- end
90
-
91
- if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
92
- puts opts; puts ''; exit
68
+ if(OPTIONS[:sprout_name].nil? && OPTIONS[:update])
69
+ OPTIONS[:sprout_name] = ARGV.pop
70
+ else
71
+ OPTIONS[:project_name] = ARGV.pop
93
72
  end
94
73
  end
95
74
 
@@ -97,7 +76,6 @@ end
97
76
 
98
77
  sprout_name = OPTIONS[:sprout_name]
99
78
  project_name = OPTIONS[:project_name]
100
- found_project_name = OPTIONS[:found_project_name]
101
79
  locations = OPTIONS[:locations]
102
80
  update = OPTIONS[:update]
103
81
  clean = OPTIONS[:clean]
@@ -109,18 +87,65 @@ if(locations.size > 0)
109
87
  Sprout.insert_locations(OPTIONS[:locations])
110
88
  end
111
89
 
90
+ if(sprout_name.nil?)
91
+ puts "\n[ERROR] You MUST provide a sprout name, this is usually done with the -s [NAME] commandline option. Please enter a sprout name now:\n"
92
+ sprout_name = gets
93
+ end
94
+
112
95
  if(update)
113
- Sprout.update = true
114
96
  msg = <<EOF
115
97
  [WARNING] Are you sure you want to clobber all local sprout definitions referenced by "#{sprout_name}"? [Yn]
116
98
  EOF
117
99
  puts msg
118
100
  response = gets.chomp!
119
- if(response != '' && response.downcase != 'y')
101
+ if(response == '' || response.downcase == 'y')
102
+ Sprout.update = true
103
+ else
104
+ Log.puts("[ERROR] Sprout execution terminated, please try again.")
120
105
  exit
121
106
  end
122
107
  end
123
108
 
109
+ if(sprout_name && !project_name)
110
+ dir = Sprout.project_path
111
+
112
+ begin
113
+ rakefile = Sprout.rakefile
114
+ if(!rakefile.nil? && File.exists?(rakefile))
115
+ require rakefile
116
+ name = ProjectModel.instance.project_name
117
+ puts 'rakefile: ' + rakefile
118
+ else
119
+ raise LoadError.new('rakefile was not found')
120
+ end
121
+ rescue LoadError
122
+ name = File.basename(dir).capitalize
123
+ end
124
+
125
+ puts "\n[WARNING] No project name specified, please choose from the following:"
126
+ puts "(1) Enter Name: Let me enter a project name and execute from #{dir}"
127
+ puts "(2) No Project: I'm just updating some sprout definitions"
128
+ puts "(3) End Process: OOPs, I'll start over..."
129
+ if(name != nil && name != '')
130
+ puts "(4) Use Inferred Name: '#{name}' and load '#{sprout_name}' into #{dir}"
131
+ end
132
+
133
+ answer = $stdin.gets.chomp
134
+
135
+ case answer
136
+ when "1" :
137
+ puts "Enter a project name now:"
138
+ project_name = gets.chomp!
139
+ when "2" :
140
+ when "4" :
141
+ project_name = name
142
+ else
143
+ Log.puts("[ERROR] Sprout execution terminated, please try again.")
144
+ exit
145
+ end
146
+
147
+ end
148
+
124
149
  # Create a new named Project
125
150
  if(sprout_name && project_name)
126
151
  path = File.join(Sprout.project_path, project_name)
@@ -152,14 +177,7 @@ if(sprout_name && project_name)
152
177
  sprout.execute
153
178
  end
154
179
 
155
- if(sprout_name && !project_name)
156
- sprout = Sprout.load(sprout_name)
157
- sprout.execute
158
- end
159
-
160
- # Resolve the sprout within the current project
161
- if(found_project_name && update && sprout_name)
162
- Sprout.project_name = found_project_name
180
+ if(sprout_name && update && !project_name)
163
181
  sprout = Sprout.load(sprout_name)
164
182
  sprout.execute
165
183
  end
@@ -180,7 +180,8 @@ module PatternPark
180
180
 
181
181
  def is_targz?(file)
182
182
  parts = file.split('.')
183
- return (parts.pop == 'gz' && parts.pop == 'tar')
183
+ part = parts.pop
184
+ return (part == 'tgz' || part == 'gz' && parts.pop == 'tar')
184
185
  end
185
186
 
186
187
  def is_gzip?(file)
@@ -199,4 +200,4 @@ module PatternPark
199
200
  return (file.split('.').pop == 'dmg')
200
201
  end
201
202
  end
202
- end
203
+ end
@@ -20,8 +20,12 @@ module PatternPark
20
20
  if(!file_name.nil?)
21
21
  return
22
22
  end
23
- @file_name = url.split('/').pop
24
- @downloaded_path = File.join(Sprout.cache, type, install_path, file_name)
23
+ if(url.nil? || url == '')
24
+ @file_name = ''
25
+ else
26
+ @file_name = url.split('/').pop
27
+ @downloaded_path = File.join(Sprout.cache, type, install_path, file_name)
28
+ end
25
29
  if(archive_type == 'txt' || archive_type == 'exe')
26
30
  @install_path = File.join(Sprout.cache, type, install_path)
27
31
  else
@@ -43,6 +47,9 @@ module PatternPark
43
47
  if(Sprout.update || !File.exists?(install_path))
44
48
  # unpack into install path
45
49
  loader.unpack_downloaded_file(downloaded_path, install_path)
50
+ if(post_install)
51
+ eval(post_install)
52
+ end
46
53
  end
47
54
  end
48
55
  end
data/lib/sprout.rb CHANGED
@@ -54,9 +54,9 @@ module PatternPark
54
54
  loader = RemoteFileLoader.new
55
55
  loader.get_remote_file(url + name, local)
56
56
  sprout = Sprout.load_local(local)
57
- if(sprout.post_install)
58
- eval(sprout.post_install)
59
- end
57
+ # if(sprout.post_install)
58
+ # eval(sprout.post_install)
59
+ # end
60
60
  return sprout
61
61
  rescue OpenURI::HTTPError => e
62
62
  Log.puts("[WARNING] Sprout not found at: #{url + name}, trying next location")
@@ -104,8 +104,14 @@ module PatternPark
104
104
  # Begin loading and resolving this Sprout instance
105
105
  # and recursively call on dependencies
106
106
  def resolve
107
- load_target
108
- load_dependencies
107
+ begin
108
+ load_target
109
+ load_dependencies
110
+ rescue StandardError => e
111
+ puts "[ERROR] Sprout '#{name}' encountered an error, this may prevent your project from working correctly!"
112
+ puts e
113
+ puts e.backtrace
114
+ end
109
115
  end
110
116
 
111
117
  def execute
@@ -128,7 +134,7 @@ module PatternPark
128
134
  if(target)
129
135
  # Forward type name so that RemoteFileTargets can place
130
136
  # downloaded files into the appropriate user home folder
131
- target.type = type
137
+ target.type = type
132
138
  target.resolve
133
139
  end
134
140
  end
@@ -2,7 +2,7 @@ module Sprout #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- TINY = 16
5
+ TINY = 20
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: sprout
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.15
6
+ version: 0.5.19
7
7
  date: 2007-07-02 00:00:00 -07:00
8
8
  summary: "Sprouts is an open-source, cross-platform project generation and configuration
9
9
  tool."