sprout 0.7.223-darwin → 0.7.224-darwin

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/lib/platform.rb CHANGED
@@ -54,9 +54,6 @@ module Platform #:nodoc:
54
54
  elsif RUBY_PLATFORM =~ /netbsd/i
55
55
  os = :unix
56
56
  impl = :netbsd
57
- elsif RUBY_PLATFORM =~ /solaris/i
58
- os = :unix
59
- impl = :solaris
60
57
  elsif RUBY_PLATFORM =~ /vista/i
61
58
  os = :win32
62
59
  impl = :vista
@@ -87,7 +84,6 @@ module Platform #:nodoc:
87
84
  end
88
85
 
89
86
  # whither AIX, SOLARIS, and the other unixen?
90
- # i386-solaris2.11
91
87
 
92
88
  if RUBY_PLATFORM =~ /(i\d86)/i
93
89
  arch = :x86
data/lib/sprout.rb CHANGED
@@ -157,8 +157,7 @@ module Sprout
157
157
  command = "#{get_gem_preamble} uninstall -x -a -q #{sprout.name}"
158
158
 
159
159
  if(!confirmation)
160
- confirmation = remove_gems_confirmation
161
- break unless confirmation
160
+ break unless confirmation = remove_gems_confirmation
162
161
  end
163
162
  puts "executing #{command}"
164
163
  raise ">> Exited with errors: #{$?}" unless system(command)
@@ -30,7 +30,7 @@ module Sprout
30
30
  return target
31
31
  end
32
32
  end
33
- raise BuilderError.new("Sprout::Builder.build failed, unsupported platform [#{platform}] or unexpected yaml")
33
+ raise BuilderError.new("Sprout::Builder.build failed, unsupported platform or unexpected yaml")
34
34
  end
35
35
 
36
36
  private
@@ -55,9 +55,9 @@ module Sprout
55
55
  # Homepage where users can learn more about this gem
56
56
  attr_writer :homepage
57
57
  # A string remote file specification usually something like:
58
- #
58
+ #
59
59
  # t.sprout_spec =<<EOF
60
- # - !ruby/object:Sprout::RemoteFileTarget
60
+ # - !ruby/object:Sprout::RemoteFileTarget
61
61
  # platform: universal
62
62
  # url: http://as3flickrlib.googlecode.com/files/flickr-.87.zip
63
63
  # archive_path: flickr-.87/src
@@ -83,7 +83,7 @@ module Sprout
83
83
  @email = "projectsprouts@googlegroups.com"
84
84
  @homepage = "http://www.projectsprouts.org"
85
85
  end
86
-
86
+
87
87
  def execute(*args) # :nodoc:
88
88
  super
89
89
  raise GemWrapError.new("A version must be provided to produce a Gem!") unless @version
@@ -94,7 +94,7 @@ module Sprout
94
94
  # render_extensions(gem_package, extensions) if extensions.size
95
95
 
96
96
  Dir.chdir(gem_package) do
97
-
97
+
98
98
  spec = Gem::Specification.new do |s|
99
99
  files = []
100
100
  s.platform = Gem::Platform::RUBY
@@ -104,17 +104,15 @@ module Sprout
104
104
  s.name = @gem_name
105
105
  s.email = @email
106
106
  s.homepage = @homepage
107
- # added in order to avoid the lib not found error
108
- s.require_path = "sprout.spec"
109
107
  s.rubyforge_project = 'sprout'
110
108
  gem_dependencies.each do |dep|
111
109
  s.requirements << dep
112
110
  end
113
-
111
+
114
112
  sprout_requirement = s.requirements.collect do |req|
115
113
  (req[0] == 'sprout')
116
114
  end
117
-
115
+
118
116
  if(!sprout_requirement)
119
117
  s.add_dependency('sprout', '>= 0.7.209')
120
118
  end
@@ -133,13 +131,13 @@ module Sprout
133
131
  Gem::Builder.new(spec).build
134
132
  end
135
133
 
136
- FileUtils.mv("#{gem_package}/#{@gem_name}-#{@version}.gem", @package)
134
+ FileUtils.mv("#{gem_package}/#{@gem_name}-#{@version}.gem", @package)
137
135
  FileUtils.rm_rf(gem_package)
138
136
  end
139
-
137
+
140
138
  # Add a gem dependency either with only the gem name
141
139
  # or with a full name and version hash like:
142
- #
140
+ #
143
141
  # t.add_dependency('sprout-flashplayer-tool')
144
142
  # or
145
143
  # t.add_dependency('sprout-flashplayer-tool' => '9.115.0')
@@ -151,12 +149,12 @@ module Sprout
151
149
  def gem_dependencies
152
150
  return @gem_dependencies ||= []
153
151
  end
154
-
152
+
155
153
  # Add files to include in the gem/ext folder
156
154
  def extensions
157
155
  return @extensions ||= []
158
156
  end
159
-
157
+
160
158
  private
161
159
 
162
160
  def gem_package
@@ -367,8 +367,7 @@ module Sprout
367
367
  end
368
368
  param = param_hash[cleaned]
369
369
 
370
- matched = name =~ /=$/
371
- if(matched)
370
+ if(name =~ /=$/)
372
371
  param.value = args.shift
373
372
  elsif(param)
374
373
  param.value
@@ -0,0 +1,207 @@
1
+
2
+ module Sprout
3
+
4
+ class TemplateResolver < Hash #:nodoc:
5
+ include Singleton
6
+
7
+ attr_accessor :replace_all,
8
+ :ignore_all
9
+
10
+ @@SPROUT_FILE_NAME = 'Sprout'
11
+ @@RENDER_IGNORE_FILES = ['asclass_config.rb', 'SWFMillTemplate.erb', 'Template.erb']
12
+ @@BINARY_EXTENSIONS = ['.jpg', '.png', '.gif', '.doc', '.xls', '.exe', '.swf', 'fla', '.psd']
13
+ @@LOG_PREFIX = ">> Created file: "
14
+ @@DELETE_PREFIX = ">> Deleted file: "
15
+
16
+ def initialize
17
+ super
18
+ @replace_all = false
19
+ @ignore_all = false
20
+ end
21
+
22
+ def copy_files(from, to, render=false)
23
+ created_files = Array.new
24
+ if(!File.exists? from)
25
+ raise UsageError.new('TemplateResolver attempted to copy files from (' + from + ') but it does not exist...')
26
+ end
27
+ if(File.directory? from)
28
+ Dir.open(from).each do |filename|
29
+ if(!Sprout.ignore_file? filename)
30
+ fullname = File.join(from, filename)
31
+ new_fullname = File.join(to, filename)
32
+ cleaned_filename = clean_file_name(filename)
33
+ cleaned_fullname = File.join(to, cleaned_filename)
34
+ if(File.directory? fullname)
35
+ Dir.mkdir(new_fullname) unless File.exists? new_fullname
36
+ puts new_fullname
37
+ copy_files(fullname, new_fullname, render)
38
+ else
39
+ file = copy_file(fullname, cleaned_fullname, render)
40
+ end
41
+ end
42
+ end
43
+ else
44
+ raise UsageError.new("copy_files called with a file (" + from + ") instead of a directory!")
45
+ end
46
+
47
+ return created_files
48
+ end
49
+
50
+ def puts(file, is_delete=false)
51
+ prefix = (is_delete) ? @@DELETE_PREFIX : @@LOG_PREFIX
52
+ Log.puts(prefix + file.gsub(Dir.pwd + '/', ''))
53
+ end
54
+
55
+ def b(path)
56
+ (is_binary?(path)) ? 'b' : ''
57
+ end
58
+
59
+ def copy_file(from, to, render=false, delegate=nil)
60
+ if(write_file?(to))
61
+ content = nil
62
+ File.open(from, 'r' + b(from)) do |f|
63
+ content = f.read
64
+ end
65
+ if(render && should_render?(from))
66
+ begin
67
+ bind = (delegate.nil?) ? binding : delegate.get_binding
68
+ content = ERB.new(content, nil, '>').result(bind)
69
+ rescue NameError => e
70
+ Log.puts '>> Template ' + from + ' references a value that is not defined'
71
+ raise e
72
+ end
73
+ end
74
+ FileUtils.makedirs(File.dirname(to))
75
+ File.open(to, 'w' + b(to)) do |f|
76
+ f.write(content)
77
+ end
78
+ puts to
79
+ return to
80
+ end
81
+ return nil
82
+ end
83
+
84
+ def should_render?(file)
85
+ if(is_binary?(file) || @@RENDER_IGNORE_FILES.index(File.basename(file)))
86
+ return false
87
+ end
88
+ return true
89
+ end
90
+
91
+ def write_file?(file)
92
+ if(!File.exists?(file))
93
+ return true
94
+ elsif(@replace_all)
95
+ puts(file, true)
96
+ File.delete(file)
97
+ return true
98
+ elsif(@ignore_all)
99
+ return false
100
+ end
101
+
102
+ relative = file.gsub(Dir.pwd, '')
103
+ msg = <<EOF
104
+
105
+ [WARNING] Sprout Encountered an existing file at [#{relative}], what would you like to do?
106
+ (r)eplace, (i)gnore, (R)eplace all or (I)gnore all?
107
+
108
+ EOF
109
+ if(Log.debug)
110
+ return false
111
+ end
112
+
113
+ $stdout.puts msg
114
+ answer = $stdin.gets.chomp
115
+ if(answer == 'r')
116
+ return true
117
+ elsif(answer == 'i')
118
+ return false
119
+ elsif(answer == 'R')
120
+ msg = <<EOF
121
+
122
+ Are you sure you want to replace ALL duplicate files?
123
+ (y)es or (n)o
124
+
125
+ EOF
126
+ $stdout.puts msg
127
+ answer = $stdin.gets.chomp
128
+ if(answer == 'y')
129
+ @replace_all = true
130
+ else
131
+ write_file?(file)
132
+ end
133
+ elsif(answer == 'I')
134
+ @ignore_all = true
135
+ return false
136
+ else
137
+ $stdout.puts "I didn't understand that response... Please choose from the following choices:\n\n"
138
+ write_file?(file)
139
+ end
140
+ end
141
+
142
+ def render_file filename
143
+ file = File.open(filename, 'r')
144
+ resolved = ERB.new(file.read, nil, '>').result(binding)
145
+ file.close
146
+ file = File.open(filename, 'w')
147
+ file.write(resolved)
148
+ file.close
149
+ end
150
+
151
+ def clean_file_name name
152
+ return name.gsub(@@SPROUT_FILE_NAME, project_name)
153
+ end
154
+
155
+ def project_name
156
+ return Sprout.project_name
157
+ end
158
+
159
+ def instance_name
160
+ return project_name[0,1].downcase + project_name[1,project_name.size]
161
+ end
162
+
163
+ #TODO: Figure out if the file is plain text or not... Possible?
164
+ def is_binary? file
165
+ file_extension = File.extname(file).downcase
166
+ @@BINARY_EXTENSIONS.each do |ext|
167
+ if(file_extension == ext)
168
+ return true
169
+ end
170
+ end
171
+ return false
172
+ end
173
+
174
+ =begin
175
+ Found this code for binary inspection here:
176
+ http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/44940
177
+ it's not 100%, but better than what I'm doing with extensions.
178
+ This should be tested and inserted above
179
+ if it works.
180
+
181
+ NON_ASCII_PRINTABLE = /[^\x20-\x7e\s]/
182
+
183
+ def nonbinary?(io, forbidden, size = 1024)
184
+ while buf = io.read(size)
185
+ return false if forbidden =~ buf
186
+ end
187
+ true
188
+ end
189
+
190
+ # usage: ruby this_script.rb filename ...
191
+ ARGV.each do |fn|
192
+ begin
193
+ open(fn) do |f|
194
+ if nonbinary?(f, NON_ASCII_PRINTABLE)
195
+ puts "#{fn}: ascii printable"
196
+ else
197
+ puts "#{fn}: binary"
198
+ end
199
+ end
200
+ rescue StandardError => e
201
+ puts "#$0: #$!"
202
+ end
203
+ end
204
+ =end
205
+
206
+ end
207
+ end
@@ -3,7 +3,7 @@ module Sprout
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- TINY = 225
6
+ TINY = 224
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  MAJOR_MINOR = [MAJOR, MINOR].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.223
4
+ version: 0.7.224
5
5
  platform: darwin
6
6
  authors:
7
7
  - Luke Bayes
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-23 00:00:00 -08:00
12
+ date: 2010-02-15 00:00:00 -08:00
13
13
  default_executable: sprout
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -122,6 +122,7 @@ files:
122
122
  - lib/sprout/tasks/ssh_task.rb
123
123
  - lib/sprout/tasks/tool_task.rb
124
124
  - lib/sprout/tasks/zip_task.rb
125
+ - lib/sprout/template_resolver.rb
125
126
  - lib/sprout/tool_task_model.rb
126
127
  - lib/sprout/user.rb
127
128
  - lib/sprout/version.rb