sprout 0.7.191-mswin32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,35 @@
1
+
2
+ module Sprout
3
+
4
+ # accepts a destination path and a sprout specification
5
+ # and will download and unpack the platform-specific
6
+ # archives that are identified in the spec
7
+ class Builder # :nodoc:
8
+
9
+ class BuilderError < StandardError #:nodoc:
10
+ end
11
+
12
+ def self.build(file_targets_yaml, destination)
13
+ data = nil
14
+
15
+ File.open(file_targets_yaml, 'r') do |f|
16
+ data = f.read
17
+ end
18
+
19
+ usr = User.new
20
+ platform = usr.platform.to_s
21
+
22
+ targets = YAML.load(data)
23
+ targets.each do |target|
24
+ if(target.platform == 'universal' || target.platform == platform)
25
+ target.install_path = FileUtils.mkdir_p(destination)
26
+ target.resolve
27
+ return target
28
+ end
29
+ end
30
+ raise BuilderError.new("Sprout::Builder.build failed, unsupported platform or unexpected yaml")
31
+ end
32
+
33
+ end
34
+ end
35
+
@@ -0,0 +1,9 @@
1
+ =begin
2
+ require 'rubygems'
3
+ gem 'activesupport', '>= 2.0.2'
4
+ require 'generator'
5
+ require 'sprout'
6
+
7
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
8
+ RubiGen::Scripts::Generate.new.run(ARGV)
9
+ =end
@@ -0,0 +1,6 @@
1
+
2
+ require 'sprout/tasks/sftp_task'
3
+ require 'sprout/tasks/ssh_task'
4
+ require 'sprout/tasks/zip_task'
5
+ require 'sprout/tasks/gem_wrap_task'
6
+ require 'sprout/tasks/library_task'
@@ -0,0 +1,6 @@
1
+ # gem 'activesupport', '>= 2.0.2'
2
+ require 'rubigen'
3
+ require 'sprout/generator/base_mixins'
4
+ require 'sprout/generator/named_base'
5
+
6
+ # This is the entry point for sprout generator features
@@ -0,0 +1,126 @@
1
+ module RubiGen # :nodoc:[all]
2
+
3
+ class Base # :nodoc:[all]
4
+
5
+ def initialize(runtime_args, runtime_options = {})
6
+ @args = runtime_args
7
+ parse!(@args, runtime_options)
8
+
9
+ # Derive source and destination paths.
10
+ @source_root = options[:source] || File.join(spec.path, 'templates')
11
+
12
+ if options[:destination]
13
+ @destination_root = options[:destination]
14
+ elsif defined? Sprout::Sprout.project_path
15
+ @destination_root = Sprout::Sprout.project_path
16
+ else
17
+ @destination_root = Dir.pwd
18
+ end
19
+
20
+ # Silence the logger if requested.
21
+ logger.quiet = options[:quiet]
22
+
23
+ # Raise usage error if help is requested.
24
+ usage if options[:help]
25
+ end
26
+
27
+ end
28
+
29
+ # GemGeneratorSource hits the mines to quarry for generators. The latest versions
30
+ # of gems named sprout-#{sprout_name}-bundle are selected.
31
+ class GemGeneratorSource < AbstractGemSource # :nodoc:[all]
32
+
33
+ def initialize(name=nil)
34
+ super()
35
+ @sprout_name = name
36
+ end
37
+
38
+ # Yield latest versions of generator gems.
39
+ def each
40
+ Gem::cache.search(/sprout-*#{@sprout_name}-bundle$/).inject({}) { |latest, gem|
41
+ hem = latest[gem.name]
42
+ latest[gem.name] = gem if hem.nil? or gem.version > hem.version
43
+ latest
44
+ }.values.each { |gem|
45
+ yield Spec.new(gem.name.sub(/sprout-*#{@sprout_name}-bundle$/, ''), gem.full_gem_path, label)
46
+ }
47
+ end
48
+
49
+ def each_sprout
50
+ Gem::cache.search(/^sprout-.*/).inject({}) { |latest, gem|
51
+ hem = latest[gem.name]
52
+ latest[gem.name] = gem if hem.nil? or gem.version > hem.version
53
+ latest
54
+ }.values.each { |gem|
55
+ yield Spec.new(gem.name, gem.full_gem_path, label)
56
+ }
57
+ end
58
+ end
59
+
60
+ # GemPathSource looks for generators within any RubyGem's
61
+ # /sprout/generators/<generator_name>/<generator_name>_generator.rb file.
62
+ # It will only include generators from sprouts whose name includes
63
+ # #{sprout_name}-bundle
64
+ class GemPathSource < AbstractGemSource # :nodoc:[all]
65
+
66
+ def initialize(name=nil)
67
+ super()
68
+ @sprout_name = name
69
+ end
70
+
71
+ # Yield each generator within generator subdirectories.
72
+ def each
73
+ generator_full_paths.each do |generator|
74
+ yield Spec.new(File.basename(generator).sub(/_generator.rb$/, ''), File.dirname(generator), label)
75
+ end
76
+ end
77
+
78
+ private
79
+ def generator_full_paths
80
+ @generator_full_paths ||=
81
+ Gem::cache.inject({}) do |latest, name_gem|
82
+ name, gem = name_gem
83
+ hem = latest[gem.name]
84
+ latest[gem.name] = gem if hem.nil? or gem.version > hem.version
85
+ latest
86
+ end.values.inject([]) do |mem, gem|
87
+ Dir[gem.full_gem_path + '/lib/sprout/**/generators/**/*_generator.rb'].each do |generator|
88
+ if(@sprout_name && gem.name.match(/sprout-#{@sprout_name}-bundle/))
89
+ mem << generator
90
+ end
91
+ end
92
+ mem
93
+ end
94
+ end
95
+ end
96
+
97
+ module Lookup # :nodoc:[all]
98
+ module ClassMethods # :nodoc:[all]
99
+
100
+ def use_sprout_sources!(sprout_name, project_path=nil)
101
+ reset_sources
102
+
103
+ # Project-specific generator paths
104
+ if project_path
105
+ sources << PathSource.new(:project, "#{project_path}/generators")
106
+ sources << PathSource.new(:script, "#{project_path}/script/generators")
107
+ sources << PathSource.new(:vendor, "#{project_path}/vendor/generators")
108
+ end
109
+
110
+ # System-wide generator paths
111
+ system_path = "#{Sprout::Sprout.sprout_cache}/generators/#{sprout_name}"
112
+ if(File.exists?(system_path))
113
+ sources << PathSource.new(:system, system_path)
114
+ end
115
+
116
+ # Gem generators will collect all
117
+ # rubygems that end with -bundle or -generators
118
+ if(Object.const_defined?(:Gem))
119
+ sources << GemGeneratorSource.new(sprout_name)
120
+ sources << GemPathSource.new(sprout_name)
121
+ end
122
+ end
123
+ end
124
+ end
125
+
126
+ end
@@ -0,0 +1,227 @@
1
+
2
+ module Sprout
3
+ module Generator #:nodoc:
4
+
5
+ class NamedBaseError < StandardError #:nodoc:
6
+ end
7
+
8
+ # The NamedBase is a good default base class for ActionScript class Generators.
9
+ # This class will accept the first command line argument and create
10
+ # many helpful properties for concrete generators to use.
11
+ #
12
+ # Can accept class names in following formats:
13
+ # * src/package/package/ClassName.as
14
+ # * test/package/package/ClassName.as
15
+ # * package/package/ClassName
16
+ # * package.package.ClassName
17
+ #
18
+ # Regardless of which format the name was sent in, the helper
19
+ # methods should provide valid results
20
+ #
21
+ class NamedBase < RubiGen::Base
22
+
23
+ # Fully qualified class named including package name like 'flash.display.Sprite'
24
+ attr_reader :full_class_name
25
+ # Path to the class file relative to your src_dir like 'flash/display/Sprite.as'
26
+ attr_reader :class_file
27
+ # The directory that contains the file, relative to your src_dir like 'flash/diplay'
28
+ attr_reader :class_dir
29
+ # The unqualified name of the class like 'Sprite'
30
+ attr_reader :class_name
31
+ # The package name of the class like 'flash.display'
32
+ attr_reader :package_name
33
+
34
+ def initialize(runtime_args, runtime_options = {})
35
+ super
36
+
37
+ rakefile = Sprout.project_rakefile
38
+ if(rakefile && File.exists?(rakefile))
39
+ load rakefile
40
+ end
41
+ @model = ProjectModel.instance
42
+
43
+ # Had to stop throwing on no args because the suite generator does
44
+ # not require the user to send in a class name....
45
+ #usage("Final argument must be a name parameter") if runtime_args.empty?
46
+ @args = runtime_args.dup
47
+ assign_names! @args.shift
48
+ end
49
+
50
+ # Quick access to the source directory identified by your project model
51
+ def src_dir
52
+ return model.src_dir
53
+ end
54
+
55
+ # Quick access to the test directory identified by your project model
56
+ def test_dir
57
+ return model.test_dir
58
+ end
59
+
60
+ # Quick access to the library directory identified by your project model
61
+ def lib_dir
62
+ return model.lib_dir
63
+ end
64
+
65
+ # The path to your project. This will either be the directory from which
66
+ # the sprout gem was executed, or the nearest ancestor directory that
67
+ # contains a properly named rakefile.
68
+ def project_path
69
+ return model.project_path
70
+ end
71
+
72
+ # The project_name that was either sent to the sprout gem or
73
+ # defined in your rakefile project model
74
+ def project_name
75
+ @project_name ||= (Sprout.project_name || model.project_name)
76
+ end
77
+
78
+ # The technology language that is stored in your project model usually (as2 or as3)
79
+ def language
80
+ return model.language
81
+ end
82
+
83
+ # Name of possible test case for this class_name
84
+ def test_case_name
85
+ @test_case_name ||= class_name + 'Test'
86
+ end
87
+
88
+ # Full name of the possible test case for this class_name
89
+ def full_test_case_name
90
+ full_class_name + 'Test'
91
+ end
92
+
93
+ # Full path to the parent directory that contains the class
94
+ # like 'src/flash/display' for flash.display.Sprite class.
95
+ def full_class_dir
96
+ @full_class_dir ||= File.join(src_dir, class_dir)
97
+ # pull trailing slash for classes in the root package
98
+ @full_class_dir.gsub!(/\/$/, '')
99
+ @full_class_dir
100
+ end
101
+
102
+ # Full path to the class file from your project_path like 'src/flash/display/Sprite.as'
103
+ def full_class_path
104
+ @full_class_path ||= File.join(src_dir, class_file)
105
+ end
106
+
107
+ # Filesystem path to the folder that contains the TestCase file
108
+ def full_test_dir
109
+ @full_test_dir ||= full_class_dir.gsub(src_dir, test_dir)
110
+ end
111
+
112
+ # Filesystem path to the TestCase file
113
+ def full_test_case_path
114
+ @full_test_case_path ||= File.join(full_test_dir, test_case_name + '.as')
115
+ end
116
+
117
+ # Path to the in-project generate script
118
+ # pulled out for DOS branching
119
+ def generate_script_path
120
+ usr = User.new
121
+ if(usr.is_a?(WinUser) && !usr.is_a?(CygwinUser))
122
+ return File.join(class_name, 'script', "generate.rb")
123
+ else
124
+ return File.join(class_name, 'script', "generate")
125
+ end
126
+ end
127
+
128
+ def instance_name
129
+ name = class_name.dup;
130
+ char = name[0, 1]
131
+ name[0, 1] = char.downcase
132
+ if(name.size > 10)
133
+ name = 'instance'
134
+ end
135
+ return name
136
+ end
137
+
138
+ # Will return whether the user originally requested a class name
139
+ # that looks like a test case (e.g., name.match(/Test$/) )
140
+ def user_requested_test
141
+ @user_requested_test ||= false
142
+ end
143
+
144
+ # Glob that is used to search for test cases and build
145
+ # up the test suites
146
+ def test_glob
147
+ return @test_glob ||= '**/**/*Test.as'
148
+ end
149
+
150
+ def test_glob=(glob)
151
+ @test_glob = glob
152
+ end
153
+
154
+ # Collection of all test case files either assigned or found
155
+ # using the test_glob as provided.
156
+ def test_cases
157
+ @test_cases ||= Dir.glob(test_dir + test_glob)
158
+ end
159
+
160
+ def test_cases=(collection)
161
+ @test_cases = collection
162
+ end
163
+
164
+ # Get the list of test_cases (which are files) as a
165
+ # list of fully qualified class names
166
+ def test_case_classes
167
+ @test_case_classes = self.test_cases.dup
168
+ @test_case_classes.collect! do |file|
169
+ actionscript_file_to_class_name(file)
170
+ end
171
+ @test_case_classes
172
+ end
173
+
174
+ # Transform a file name in the source or test path
175
+ # to a fully-qualified class name
176
+ def actionscript_file_to_class_name(file)
177
+ name = file.dup
178
+ name.gsub!(/^#{Dir.pwd}\//, '')
179
+ name.gsub!(/^#{test_dir}\//, '')
180
+ name.gsub!(/^#{src_dir}\//, '')
181
+ name.gsub!(/.as$/, '')
182
+ name.gsub!(/#{File::SEPARATOR}/, '.')
183
+ return name
184
+ end
185
+
186
+ protected
187
+
188
+ def banner
189
+ "Usage: #{$0} [options] packagename.ClassName"
190
+ end
191
+
192
+ def model
193
+ @model ||= ProjectModel.instance
194
+ end
195
+
196
+ def assign_names!(name)
197
+ # trim file name suffix in case it was submitted
198
+ name.gsub!(/\//, '.')
199
+ name.gsub!(/\.as$/, '')
200
+ name.gsub!(/\.mxml$/, '')
201
+ if(model)
202
+ # Pull leading src_dir from class name if submitted
203
+ name.gsub!(/^#{src_dir}\./, '')
204
+ name.gsub!(/^#{test_dir}\./, '')
205
+ end
206
+
207
+ if(name.match(/Test$/))
208
+ @user_requested_test = true
209
+ name = name.gsub(/Test$/, '')
210
+ end
211
+ if(name.match(/^I/) || name.match(/able$/))
212
+ @user_requested_interface = true
213
+ end
214
+
215
+ @full_class_name = name
216
+ parts = name.split('.')
217
+ @class_name = parts.pop
218
+ @package_name = parts.join('.')
219
+ @class_file = @full_class_name.split('.').join(File::SEPARATOR) + '.as'
220
+ @class_dir = File.dirname(@class_file)
221
+ if(@class_dir == '.')
222
+ @class_dir = ''
223
+ end
224
+ end
225
+ end
226
+ end
227
+ end
@@ -0,0 +1,46 @@
1
+
2
+ module Sprout #:nodoc:
3
+
4
+ class Log #:nodoc:
5
+ @@debug = false
6
+ @@output = ''
7
+ @@printout = ''
8
+
9
+ def Log.debug=(debug)
10
+ @@debug = debug
11
+ end
12
+
13
+ def Log.debug
14
+ return @@debug
15
+ end
16
+
17
+ def Log.puts(msg)
18
+ @@output << msg + "\n"
19
+ Log.flush
20
+ end
21
+
22
+ def Log.print(msg)
23
+ @@printout << msg
24
+ Log.flush_print
25
+ end
26
+
27
+ def Log.printf(msg)
28
+ @@printout << msg
29
+ Log.flush_print
30
+ end
31
+
32
+ def Log.flush_print
33
+ if(!Log.debug)
34
+ $stdout.print @@printout
35
+ @@printout = ''
36
+ end
37
+ end
38
+
39
+ def Log.flush
40
+ if(!Log.debug)
41
+ $stdout.puts @@output
42
+ @@output = ''
43
+ end
44
+ end
45
+ end
46
+ end