sprout 0.7.246 → 1.0.0.pre
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/CHANGELOG.md +10 -0
- data/Gemfile +28 -0
- data/MIT-LICENSE +3 -2
- data/POSTINSTALL.rdoc +28 -0
- data/README.textile +152 -0
- data/bin/sprout +1 -131
- data/bin/sprout-generator +10 -0
- data/bin/sprout-library +11 -0
- data/bin/sprout-tool +10 -0
- data/lib/sprout.rb +4 -500
- data/lib/sprout/archive_unpacker.rb +122 -206
- data/lib/sprout/base.rb +90 -0
- data/lib/sprout/concern.rb +30 -0
- data/lib/sprout/dir.rb +23 -0
- data/lib/sprout/errors.rb +94 -0
- data/lib/sprout/executable.rb +496 -0
- data/lib/sprout/executable/boolean.rb +35 -0
- data/lib/sprout/executable/collection_param.rb +53 -0
- data/lib/sprout/executable/file_param.rb +53 -0
- data/lib/sprout/executable/files.rb +26 -0
- data/lib/sprout/executable/number.rb +10 -0
- data/lib/sprout/executable/param.rb +222 -0
- data/lib/sprout/executable/parameter_factory.rb +28 -0
- data/lib/sprout/executable/path.rb +21 -0
- data/lib/sprout/executable/paths.rb +21 -0
- data/lib/sprout/executable/string_param.rb +15 -0
- data/lib/sprout/executable/strings.rb +11 -0
- data/lib/sprout/executable/url.rb +10 -0
- data/lib/sprout/executable/urls.rb +10 -0
- data/lib/sprout/file_target.rb +76 -0
- data/lib/sprout/generator/base.rb +233 -0
- data/lib/sprout/generator/command.rb +67 -0
- data/lib/sprout/generator/directory_manifest.rb +49 -0
- data/lib/sprout/generator/file_manifest.rb +55 -0
- data/lib/sprout/generator/manifest.rb +13 -0
- data/lib/sprout/generator/template_manifest.rb +13 -0
- data/lib/sprout/generators/generator/generator_generator.rb +48 -0
- data/lib/sprout/generators/generator/templates/generator_class.rb +17 -0
- data/lib/sprout/generators/generator/templates/generator_executable +9 -0
- data/lib/sprout/generators/generator/templates/generator_template +1 -0
- data/lib/sprout/generators/generator/templates/generator_test.rb +37 -0
- data/lib/sprout/generators/generator/templates/generator_test_helper.rb +16 -0
- data/lib/sprout/generators/library/library_generator.rb +20 -0
- data/lib/sprout/generators/library/templates/library.gemspec +19 -0
- data/lib/sprout/generators/library/templates/library.rb +15 -0
- data/lib/sprout/generators/ruby/ruby_generator.rb +59 -0
- data/lib/sprout/generators/ruby/templates/ruby_base.rb +10 -0
- data/lib/sprout/generators/ruby/templates/ruby_executable +6 -0
- data/lib/sprout/generators/ruby/templates/ruby_gemfile +4 -0
- data/lib/sprout/generators/ruby/templates/ruby_input.rb +7 -0
- data/lib/sprout/generators/tool/templates/Gemfile +4 -0
- data/lib/sprout/generators/tool/templates/tool.gemspec +22 -0
- data/lib/sprout/generators/tool/templates/tool.rb +38 -0
- data/lib/sprout/generators/tool/tool_generator.rb +36 -0
- data/lib/sprout/library.rb +111 -0
- data/lib/sprout/log.rb +1 -0
- data/lib/sprout/platform.rb +71 -0
- data/lib/sprout/process_runner.rb +80 -40
- data/lib/sprout/progress_bar.rb +341 -0
- data/lib/sprout/rdoc_parser.rb +91 -0
- data/lib/sprout/remote_file_loader.rb +72 -50
- data/lib/sprout/remote_file_target.rb +44 -152
- data/lib/sprout/ruby_feature.rb +167 -0
- data/lib/sprout/specification.rb +197 -0
- data/lib/sprout/string.rb +19 -0
- data/lib/sprout/system.rb +35 -0
- data/lib/sprout/system/base_system.rb +225 -0
- data/lib/sprout/system/java_system.rb +9 -0
- data/lib/sprout/system/osx_system.rb +26 -0
- data/lib/sprout/system/unix_system.rb +72 -0
- data/lib/sprout/system/vista_system.rb +16 -0
- data/lib/sprout/system/win_nix_system.rb +41 -0
- data/lib/sprout/system/win_system.rb +76 -0
- data/lib/sprout/test/sprout_test_case.rb +211 -0
- data/lib/sprout/version.rb +9 -4
- data/rakefile.rb +85 -144
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/sprout.gemspec +26 -0
- data/test/fixtures/archive_unpacker/copyable/some_file.exe +0 -0
- data/test/fixtures/archive_unpacker/copyable/some_file.rb +0 -0
- data/test/fixtures/archive_unpacker/copyable/some_file.swc +0 -0
- data/test/fixtures/archive_unpacker/tgz/some folder.tgz +0 -0
- data/test/fixtures/archive_unpacker/tgz/some_file.tgz +0 -0
- data/test/fixtures/archive_unpacker/zip/some folder.zip +0 -0
- data/test/fixtures/archive_unpacker/zip/some_file.zip +0 -0
- data/test/fixtures/examples/app_generator.rb +127 -0
- data/test/fixtures/examples/echo_inputs.rb +151 -0
- data/test/fixtures/executable/echochamber_gem/bin/echochamber +3 -0
- data/test/fixtures/executable/echochamber_gem/echo_chamber.rb +10 -0
- data/test/fixtures/executable/flex3sdk_gem/flex3sdk.rb +11 -0
- data/test/fixtures/executable/flex3sdk_gem/mxmlc +3 -0
- data/test/fixtures/executable/flex3sdk_gem/mxmlc.bat +3 -0
- data/test/fixtures/executable/mxmlc.rb +805 -0
- data/test/fixtures/executable/params/input.as +0 -0
- data/test/fixtures/executable/params/input2.as +0 -0
- data/test/fixtures/executable/params/input3.as +0 -0
- data/test/fixtures/executable/params/mxmlc +5 -0
- data/test/fixtures/executable/path with spaces/input.as b/data/test/fixtures/executable/path with → spaces/input.as +0 -0
- data/test/fixtures/executable/path with spaces/input2.as b/data/test/fixtures/executable/path with → spaces/input2.as +0 -0
- data/test/fixtures/executable/path with spaces/input3.as b/data/test/fixtures/executable/path with → spaces/input3.as +0 -0
- data/test/fixtures/executable/paths/folder1/file1 +0 -0
- data/test/fixtures/executable/paths/folder1/file2 +0 -0
- data/test/fixtures/executable/paths/folder1/file3 +0 -0
- data/test/fixtures/executable/paths/folder2/file4 +0 -0
- data/test/fixtures/executable/paths/folder2/file5 +0 -0
- data/test/fixtures/executable/paths/folder3/file6 +0 -0
- data/test/fixtures/executable/src/Main.as +0 -0
- data/test/fixtures/executable/windows_line_endings +47 -0
- data/test/fixtures/generators/song_generator.rb +11 -0
- data/test/fixtures/generators/song_subclass/least_favorite.rb +10 -0
- data/test/fixtures/generators/song_subclass/templates/Song.txt +3 -0
- data/test/fixtures/generators/temp_generator.rb +24 -0
- data/test/fixtures/generators/templates/Main.as +9 -0
- data/test/fixtures/generators/templates/OtherFileTemplate +1 -0
- data/test/fixtures/generators/templates/SomeFile +1 -0
- data/test/fixtures/generators/templates/SomeSubclassFile +2 -0
- data/test/fixtures/generators/templates/Song.txt +3 -0
- data/test/fixtures/generators/templates/destroy +0 -0
- data/test/fixtures/generators/templates/generate +0 -0
- data/test/fixtures/library/archive/Archive.swc +0 -0
- data/test/fixtures/library/sources/lib/a/A.as +0 -0
- data/test/fixtures/library/sources/lib/b/B.as +0 -0
- data/test/fixtures/library/sources/src/Source.as +0 -0
- data/test/fixtures/process_runner/chmod_script.sh +3 -0
- data/test/fixtures/process_runner/dir with spaces/chmod_script.sh +3 -0
- data/test/fixtures/process_runner/failure +5 -0
- data/test/fixtures/process_runner/success +4 -0
- data/test/fixtures/remote_file_loader/md5/echochamber-test.zip +0 -0
- data/test/fixtures/remote_file_loader/md5/file_with_known_md5 +0 -0
- data/test/fixtures/remote_file_target/bin/echochamber +3 -0
- data/test/fixtures/remote_file_target/bin/echochamber.bat +3 -0
- data/test/fixtures/remote_file_target/echochamber-test.zip +0 -0
- data/test/fixtures/specification/asunit4.rb +25 -0
- data/test/fixtures/specification/ext/AsUnit-4.1.pre.swc +0 -0
- data/test/fixtures/specification/flashplayer.rb +30 -0
- data/test/fixtures/specification/flex4sdk.rb +72 -0
- data/test/fixtures/specification/flexunit4.sproutspec +17 -0
- data/test/fixtures/specification/lib/as3reflection/Reflection.as +0 -0
- data/test/fixtures/specification/src/AsUnit.as +0 -0
- data/test/fixtures/user/mxmlc_crlf +3 -0
- data/test/unit/archive_unpacker_test.rb +108 -0
- data/test/unit/boolean_param_test.rb +38 -0
- data/test/unit/executable_option_parser_test.rb +142 -0
- data/test/unit/executable_param_test.rb +76 -0
- data/test/unit/executable_test.rb +237 -0
- data/test/unit/fake_executable_task.rb +22 -0
- data/test/unit/fake_other_executable.rb +20 -0
- data/test/unit/fake_process_runner.rb +29 -0
- data/test/unit/file_param_test.rb +61 -0
- data/test/unit/file_target_test.rb +42 -0
- data/test/unit/files_param_test.rb +72 -0
- data/test/unit/generator_generator_test.rb +85 -0
- data/test/unit/generator_test.rb +333 -0
- data/test/unit/library_generator_test.rb +41 -0
- data/test/unit/library_test.rb +88 -0
- data/test/unit/osx_system_test.rb +20 -0
- data/test/unit/path_param_test.rb +43 -0
- data/test/unit/paths_param_test.rb +53 -0
- data/test/unit/platform_test.rb +76 -0
- data/test/unit/process_runner_test.rb +104 -0
- data/test/unit/rdoc_parser_test.rb +15 -0
- data/test/unit/remote_file_loader_test.rb +34 -0
- data/test/unit/remote_file_target_test.rb +105 -0
- data/test/unit/ruby_feature_test.rb +108 -0
- data/test/unit/ruby_generator_test.rb +70 -0
- data/test/unit/specification_test.rb +73 -0
- data/test/unit/sprout_test.rb +170 -0
- data/test/unit/sprout_test_helper.rb +18 -0
- data/test/unit/string_param_test.rb +19 -0
- data/test/unit/string_test.rb +20 -0
- data/test/unit/strings_param_test.rb +27 -0
- data/test/unit/test_helper.rb +1 -0
- data/test/unit/tool_generator_test.rb +43 -0
- data/test/unit/unix_system_test.rb +52 -0
- data/test/unit/user_test.rb +147 -0
- data/test/unit/vista_system_test.rb +40 -0
- data/test/unit/win_nix_system_test.rb +26 -0
- data/test/unit/win_system_test.rb +61 -0
- metadata +318 -113
- data/doc/Bundle +0 -14
- data/doc/Generator +0 -35
- data/doc/Library +0 -63
- data/doc/Task +0 -21
- data/doc/Tool +0 -20
- data/lib/platform.rb +0 -113
- data/lib/progress_bar.rb +0 -354
- data/lib/sprout/builder.rb +0 -51
- data/lib/sprout/bundle_resolver.rb +0 -349
- data/lib/sprout/commands/generate.rb +0 -9
- data/lib/sprout/dynamic_accessors.rb +0 -40
- data/lib/sprout/general_tasks.rb +0 -6
- data/lib/sprout/generator.rb +0 -7
- data/lib/sprout/generator/base_mixins.rb +0 -186
- data/lib/sprout/generator/named_base.rb +0 -227
- data/lib/sprout/project_model.rb +0 -278
- data/lib/sprout/simple_resolver.rb +0 -88
- data/lib/sprout/tasks/erb_resolver.rb +0 -118
- data/lib/sprout/tasks/gem_wrap_task.rb +0 -214
- data/lib/sprout/tasks/git_task.rb +0 -134
- data/lib/sprout/tasks/library_task.rb +0 -118
- data/lib/sprout/tasks/sftp_task.rb +0 -248
- data/lib/sprout/tasks/ssh_task.rb +0 -153
- data/lib/sprout/tasks/tool_task.rb +0 -836
- data/lib/sprout/tasks/zip_task.rb +0 -158
- data/lib/sprout/tool_task_model.rb +0 -19
- data/lib/sprout/user.rb +0 -415
- data/lib/sprout/version_file.rb +0 -89
- data/lib/sprout/zip_util.rb +0 -61
- data/samples/gem_wrap/rakefile.rb +0 -17
data/lib/sprout/general_tasks.rb
DELETED
data/lib/sprout/generator.rb
DELETED
@@ -1,186 +0,0 @@
|
|
1
|
-
|
2
|
-
class Gem::SourceIndex
|
3
|
-
|
4
|
-
# This feature seems to be getting deprecated from the latest
|
5
|
-
# gems releases (1.3.x).
|
6
|
-
# We actually need it and don't want the nagging - so,
|
7
|
-
# copied sources from RubyGems SVN trunk, and mixing in...
|
8
|
-
# :-(
|
9
|
-
# There should be a more stable integration point with RubyGems
|
10
|
-
# Any ideas or contributions are welcome!
|
11
|
-
def sprout_search(gem_pattern, platform_only = false)
|
12
|
-
version_requirement = nil
|
13
|
-
only_platform = false
|
14
|
-
|
15
|
-
# unless Gem::Dependency === gem_pattern
|
16
|
-
# warn "#{Gem.location_of_caller.join ':'}:Warning: Gem::SourceIndex#search support for #{gem_pattern.class} patterns is deprecated"
|
17
|
-
# end
|
18
|
-
|
19
|
-
case gem_pattern
|
20
|
-
when Regexp then
|
21
|
-
version_requirement = platform_only || Gem::Requirement.default
|
22
|
-
when Gem::Dependency then
|
23
|
-
only_platform = platform_only
|
24
|
-
version_requirement = gem_pattern.version_requirements
|
25
|
-
gem_pattern = if Regexp === gem_pattern.name then
|
26
|
-
gem_pattern.name
|
27
|
-
elsif gem_pattern.name.empty? then
|
28
|
-
//
|
29
|
-
else
|
30
|
-
/^#{Regexp.escape gem_pattern.name}$/
|
31
|
-
end
|
32
|
-
else
|
33
|
-
version_requirement = platform_only || Gem::Requirement.default
|
34
|
-
gem_pattern = /#{gem_pattern}/i
|
35
|
-
end
|
36
|
-
|
37
|
-
unless Gem::Requirement === version_requirement then
|
38
|
-
version_requirement = Gem::Requirement.create version_requirement
|
39
|
-
end
|
40
|
-
|
41
|
-
specs = @gems.values.select do |spec|
|
42
|
-
spec.name =~ gem_pattern and
|
43
|
-
version_requirement.satisfied_by? spec.version
|
44
|
-
end
|
45
|
-
|
46
|
-
if only_platform then
|
47
|
-
specs = specs.select do |spec|
|
48
|
-
Gem::Platform.match spec.platform
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
begin
|
53
|
-
specs.sort_by { |s| s.sort_obj }
|
54
|
-
rescue NoMethodError => e
|
55
|
-
puts "It looks like your RubyGems installation is not compatible with this version of Sprouts.\n\nTo update, run:\ngem update --system\n\n"
|
56
|
-
raise e
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
module RubiGen # :nodoc:[all]
|
62
|
-
|
63
|
-
class Base # :nodoc:[all]
|
64
|
-
|
65
|
-
def initialize(runtime_args, runtime_options = {})
|
66
|
-
@args = runtime_args
|
67
|
-
parse!(@args, runtime_options)
|
68
|
-
|
69
|
-
# Derive source and destination paths.
|
70
|
-
@source_root = options[:source] || File.join(spec.path, 'templates')
|
71
|
-
|
72
|
-
if options[:destination]
|
73
|
-
@destination_root = options[:destination]
|
74
|
-
elsif defined? Sprout::Sprout.project_path
|
75
|
-
@destination_root = Sprout::Sprout.project_path
|
76
|
-
else
|
77
|
-
@destination_root = Dir.pwd
|
78
|
-
end
|
79
|
-
|
80
|
-
# Silence the logger if requested.
|
81
|
-
logger.quiet = options[:quiet]
|
82
|
-
|
83
|
-
# Raise usage error if help is requested.
|
84
|
-
usage if options[:help]
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
# GemGeneratorSource hits the mines to quarry for generators. The latest versions
|
90
|
-
# of gems named sprout-#{sprout_name}-bundle are selected.
|
91
|
-
class GemGeneratorSource < AbstractGemSource # :nodoc:[all]
|
92
|
-
|
93
|
-
def initialize(name=nil)
|
94
|
-
super()
|
95
|
-
@sprout_name = name
|
96
|
-
end
|
97
|
-
|
98
|
-
# Yield latest versions of generator gems.
|
99
|
-
def each
|
100
|
-
Gem::cache.sprout_search(/sprout-*#{@sprout_name}-bundle$/).inject({}) do |latest, gem|
|
101
|
-
hem = latest[gem.name]
|
102
|
-
latest[gem.name] = gem if hem.nil? or gem.version > hem.version
|
103
|
-
latest
|
104
|
-
end.values.each do |gem|
|
105
|
-
yield Spec.new(gem.name.sub(/sprout-*#{@sprout_name}-bundle$/, ''), gem.full_gem_path, label)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def each_sprout
|
110
|
-
Gem::cache.sprout_search(/^sprout-.*/).inject({}) do |latest, gem|
|
111
|
-
hem = latest[gem.name]
|
112
|
-
latest[gem.name] = gem if hem.nil? or gem.version > hem.version
|
113
|
-
latest
|
114
|
-
end.values.each do |gem|
|
115
|
-
yield Spec.new(gem.name, gem.full_gem_path, label)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# GemPathSource looks for generators within any RubyGem's
|
121
|
-
# /sprout/generators/<generator_name>/<generator_name>_generator.rb file.
|
122
|
-
# It will only include generators from sprouts whose name includes
|
123
|
-
# #{sprout_name}-bundle
|
124
|
-
class GemPathSource < AbstractGemSource # :nodoc:[all]
|
125
|
-
|
126
|
-
def initialize(name=nil)
|
127
|
-
super()
|
128
|
-
@sprout_name = name
|
129
|
-
end
|
130
|
-
|
131
|
-
# Yield each generator within generator subdirectories.
|
132
|
-
def each
|
133
|
-
generator_full_paths.each do |generator|
|
134
|
-
yield Spec.new(File.basename(generator).sub(/_generator.rb$/, ''), File.dirname(generator), label)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
private
|
139
|
-
def generator_full_paths
|
140
|
-
@generator_full_paths ||=
|
141
|
-
Gem::cache.inject({}) do |latest, name_gem|
|
142
|
-
name, gem = name_gem
|
143
|
-
hem = latest[gem.name]
|
144
|
-
latest[gem.name] = gem if hem.nil? or gem.version > hem.version
|
145
|
-
latest
|
146
|
-
end.values.inject([]) do |mem, gem|
|
147
|
-
Dir[gem.full_gem_path + '/lib/sprout/**/generators/**/*_generator.rb'].each do |generator|
|
148
|
-
if(@sprout_name && gem.name.match(/sprout-#{@sprout_name}-bundle/))
|
149
|
-
mem << generator
|
150
|
-
end
|
151
|
-
end
|
152
|
-
mem
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
module Lookup # :nodoc:[all]
|
158
|
-
module ClassMethods # :nodoc:[all]
|
159
|
-
|
160
|
-
def use_sprout_sources!(sprout_name, project_path=nil)
|
161
|
-
reset_sources
|
162
|
-
|
163
|
-
# Project-specific generator paths
|
164
|
-
if project_path
|
165
|
-
sources << PathSource.new(:project, "#{project_path}/generators")
|
166
|
-
sources << PathSource.new(:script, "#{project_path}/script/generators")
|
167
|
-
sources << PathSource.new(:vendor, "#{project_path}/vendor/generators")
|
168
|
-
end
|
169
|
-
|
170
|
-
# System-wide generator paths
|
171
|
-
system_path = "#{Sprout::Sprout.sprout_cache}/generators/#{sprout_name}"
|
172
|
-
if(File.exists?(system_path))
|
173
|
-
sources << PathSource.new(:system, system_path)
|
174
|
-
end
|
175
|
-
|
176
|
-
# Gem generators will collect all
|
177
|
-
# rubygems that end with -bundle or -generators
|
178
|
-
if(Object.const_defined?(:Gem))
|
179
|
-
sources << GemGeneratorSource.new(sprout_name)
|
180
|
-
sources << GemPathSource.new(sprout_name)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
@@ -1,227 +0,0 @@
|
|
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.dup
|
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
|
data/lib/sprout/project_model.rb
DELETED
@@ -1,278 +0,0 @@
|
|
1
|
-
|
2
|
-
module Sprout
|
3
|
-
# The ProjectModel gives you a place to describe your project so that you
|
4
|
-
# don't need to repeat yourself throughout a rakefile.
|
5
|
-
#
|
6
|
-
# The default set of properties are also used from code generators, library tasks and sometimes tools.
|
7
|
-
#
|
8
|
-
# The ProjectModel can be configured as follows:
|
9
|
-
# project_model :model do |p|
|
10
|
-
# p.name = 'SomeProject'
|
11
|
-
# p.source_path << 'somedir/otherdir'
|
12
|
-
# p.library_path << 'somedir'
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# This class should have some reasonable default values, but can be modified from any rakefile.
|
16
|
-
# If you don't find some properties that you'd like on the ProjectModel, you can simply add
|
17
|
-
# new properties and use them however you wish.
|
18
|
-
#
|
19
|
-
# Arbitrary properties can be added as follows:
|
20
|
-
# m = project_model :model do |p|
|
21
|
-
# p.unknown_property = 'someValue'
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# puts "Unknown Property: #{m.unknown_property}"
|
25
|
-
#
|
26
|
-
# The ProjectModel is typically treated as if it is a Singleton, and many helper tasks
|
27
|
-
# will automatically go look for their model at:
|
28
|
-
#
|
29
|
-
# Sprout::ProjectModel.instance
|
30
|
-
#
|
31
|
-
# Unlike a real Singleton, this static property will actually be populated with the most
|
32
|
-
# recently instantiated ProjectModel, and any well-behaved helper task will also
|
33
|
-
# allow you to send in a model as a prerequisite.
|
34
|
-
#
|
35
|
-
# project_model :model_a
|
36
|
-
# project_model :model_b
|
37
|
-
#
|
38
|
-
# desc 'Compile and run a'
|
39
|
-
# debug :debug_a => :model_a
|
40
|
-
#
|
41
|
-
# desc 'Compile and run b'
|
42
|
-
# debug :debug_b => :model_b
|
43
|
-
#
|
44
|
-
class ProjectModel < Hash
|
45
|
-
|
46
|
-
# Relative path to the folder where compile time assets will be stored
|
47
|
-
attr_accessor :asset_dir
|
48
|
-
# The folder where binary files will be created. Usually this is where any build artifacts like SWF files get placed.
|
49
|
-
attr_accessor :bin_dir
|
50
|
-
# The Background Color of the SWF file
|
51
|
-
attr_accessor :background_color
|
52
|
-
# Contributors to the SWF file
|
53
|
-
attr_accessor :contributors
|
54
|
-
# If you don't want to use the default compiler for your language
|
55
|
-
# set it manually here.
|
56
|
-
# Possible values are:
|
57
|
-
# * sprout-flex2sdk-tool
|
58
|
-
# * sprout-flex3sdk-tool
|
59
|
-
# * sprout-flex4sdk-tool (Experimental)
|
60
|
-
# * sprout-mtasc-tool
|
61
|
-
attr_accessor :compiler_gem_name
|
62
|
-
# The version number of the compiler gem to use
|
63
|
-
attr_accessor :compiler_gem_version
|
64
|
-
# The primary creator of the SWF file
|
65
|
-
attr_accessor :creator
|
66
|
-
# Directory where documentation should be placed.
|
67
|
-
attr_accessor :doc_dir
|
68
|
-
# CSS documents that should be individually compiled
|
69
|
-
# for runtime stylesheet loading.
|
70
|
-
attr_accessor :external_css
|
71
|
-
# The default frame rate of the SWF file
|
72
|
-
attr_accessor :frame_rate
|
73
|
-
# The default height of the SWF file
|
74
|
-
# _(This value is overridden when embedded in an HTML page)_
|
75
|
-
attr_accessor :height
|
76
|
-
# The technology language that is being used, right now this value can be 'as2', 'as3' or 'mxml'.
|
77
|
-
# Code generators take advantage of this setting to determine which templates to use
|
78
|
-
# and build tasks use this setting to determin the input file suffix (.as or .mxml).
|
79
|
-
attr_accessor :language
|
80
|
-
# The relative path to your library directory. Defaults to 'lib'
|
81
|
-
#
|
82
|
-
# Any remote .SWC and source libraries that are referenced in your rakefile will be installed
|
83
|
-
# into this directory. Source libraries will be placed in a folder that matches the library name,
|
84
|
-
# while SWCs will be simply placed directly into the lib_dir.
|
85
|
-
attr_accessor :lib_dir
|
86
|
-
# Array of sprout library symbols
|
87
|
-
attr_accessor :libraries
|
88
|
-
# The Array of SWC paths to add to all compilation tasks
|
89
|
-
attr_accessor :library_path
|
90
|
-
# The locale for the SWF file
|
91
|
-
attr_accessor :locale
|
92
|
-
# A collection of Flex Module root source files. If this collection
|
93
|
-
# has items added to it, the deploy task will generate a 'link_report' from
|
94
|
-
# the main application compilation and then consume it as 'load_externs' for
|
95
|
-
# each module compilation.
|
96
|
-
attr_accessor :modules
|
97
|
-
# Organization responsible for this SWF file
|
98
|
-
attr_accessor :organization
|
99
|
-
# The production file that this Project will generate
|
100
|
-
attr_accessor :output
|
101
|
-
# Terminal command to preprocessor application that accepts STDIN and returns on STDOUT
|
102
|
-
attr_accessor :preprocessor
|
103
|
-
# Folder where preprocessed files will be created. Defaults to '.preprocessed'
|
104
|
-
attr_accessor :preprocessed_path
|
105
|
-
# The real name of the project, usually capitalized like a class name 'SomeProject'
|
106
|
-
attr_accessor :project_name
|
107
|
-
# The folder where compile time skins can be loaded from
|
108
|
-
attr_accessor :skin_dir
|
109
|
-
# The skin file that will be generated
|
110
|
-
attr_accessor :skin_output
|
111
|
-
# The Array of source paths to add to all compilation tasks
|
112
|
-
# _Do not add task-specific paths (like lib/asunit) to this value_
|
113
|
-
attr_accessor :source_path
|
114
|
-
# The relative path to your main source directory. Defaults to 'src'
|
115
|
-
attr_accessor :src_dir
|
116
|
-
# Enforce strict type checking
|
117
|
-
attr_accessor :strict
|
118
|
-
# The relative path to the directory where swc files should be kept.
|
119
|
-
# This value defaults to lib_dir
|
120
|
-
attr_accessor :swc_dir
|
121
|
-
# Relative path to the folder that contains your test cases
|
122
|
-
attr_accessor :test_dir
|
123
|
-
# The test executable
|
124
|
-
attr_accessor :test_output
|
125
|
-
# The test runner SWF height
|
126
|
-
attr_accessor :test_height
|
127
|
-
# The test runner SWF width
|
128
|
-
attr_accessor :test_width
|
129
|
-
# Tasks that can, will use the Flex Compiler SHell.
|
130
|
-
attr_accessor :use_fcsh
|
131
|
-
# Flash Player Tasks will launch using the Flex Debugger.
|
132
|
-
attr_accessor :use_fdb
|
133
|
-
# The default width of the SWF file
|
134
|
-
# _(This value is overridden when embedded in an HTML page)_
|
135
|
-
attr_accessor :width
|
136
|
-
|
137
|
-
# Static method that returns the most recently instantiated ProjectModel,
|
138
|
-
# or instantiates one if none have been created yet.
|
139
|
-
def self.instance
|
140
|
-
@@instance ||= ProjectModel.new
|
141
|
-
yield @@instance if block_given?
|
142
|
-
return @@instance
|
143
|
-
end
|
144
|
-
|
145
|
-
# Decorates the static instance method.
|
146
|
-
def self.setup
|
147
|
-
@@instance ||= ProjectModel.new
|
148
|
-
yield @@instance if block_given?
|
149
|
-
return @@instance
|
150
|
-
end
|
151
|
-
|
152
|
-
def self.destroy # :nodoc:
|
153
|
-
@@instance = nil
|
154
|
-
end
|
155
|
-
|
156
|
-
def initialize
|
157
|
-
super
|
158
|
-
@project_name = ''
|
159
|
-
@doc_dir = 'doc'
|
160
|
-
@src_dir = 'src'
|
161
|
-
@lib_dir = 'lib'
|
162
|
-
@swc_dir = 'lib'
|
163
|
-
@bin_dir = 'bin'
|
164
|
-
@test_dir = 'test'
|
165
|
-
@asset_dir = 'assets'
|
166
|
-
@skin_dir = File.join(@asset_dir, 'skins')
|
167
|
-
@frame_rate = 24
|
168
|
-
@language = 'as3'
|
169
|
-
|
170
|
-
@external_css = []
|
171
|
-
@libraries = []
|
172
|
-
@library_path = []
|
173
|
-
@modules = []
|
174
|
-
@source_path = []
|
175
|
-
|
176
|
-
@model_dir = nil
|
177
|
-
@view_dir = nil
|
178
|
-
@controller_dir = nil
|
179
|
-
|
180
|
-
@test_height = 550
|
181
|
-
@test_width = 900
|
182
|
-
@@instance = self
|
183
|
-
end
|
184
|
-
|
185
|
-
# Path to the project directory from which all other paths are created
|
186
|
-
def project_path
|
187
|
-
return Sprout.project_path
|
188
|
-
end
|
189
|
-
|
190
|
-
def model_dir=(dir)
|
191
|
-
@model_dir = dir
|
192
|
-
end
|
193
|
-
|
194
|
-
# Simple MVC helper for project-wide models if your project is called 'SomeProject'
|
195
|
-
# this will default to:
|
196
|
-
# SomeProject/src/someproject/models
|
197
|
-
def model_dir
|
198
|
-
if(@model_dir.nil?)
|
199
|
-
@model_dir = File.join(src_dir, project_name.downcase, 'models')
|
200
|
-
end
|
201
|
-
return @model_dir
|
202
|
-
end
|
203
|
-
|
204
|
-
def view_dir=(dir)
|
205
|
-
@view_dir = dir
|
206
|
-
end
|
207
|
-
|
208
|
-
# Simple MVC helper for project-wide views if your project is called 'SomeProject'
|
209
|
-
# this will default to:
|
210
|
-
# SomeProject/src/someproject/views
|
211
|
-
def view_dir
|
212
|
-
if(@view_dir.nil?)
|
213
|
-
@view_dir = File.join(src_dir, project_name.downcase, 'views')
|
214
|
-
end
|
215
|
-
return @view_dir
|
216
|
-
end
|
217
|
-
|
218
|
-
def controller_dir=(dir)
|
219
|
-
@controller_dir = dir
|
220
|
-
end
|
221
|
-
|
222
|
-
# Simple MVC helper for project-wide views if your project is called 'SomeProject'
|
223
|
-
# this will default to:
|
224
|
-
# SomeProject/src/someproject/controllers
|
225
|
-
def controller_dir
|
226
|
-
if(@controller_dir.nil?)
|
227
|
-
@controller_dir = File.join(src_dir, project_name.downcase, 'controllers')
|
228
|
-
end
|
229
|
-
return @controller_dir
|
230
|
-
end
|
231
|
-
|
232
|
-
# Alias for project_name
|
233
|
-
def name=(name)
|
234
|
-
@project_name = name
|
235
|
-
end
|
236
|
-
|
237
|
-
def name
|
238
|
-
@project_name
|
239
|
-
end
|
240
|
-
|
241
|
-
def to_s
|
242
|
-
return "[Sprout::ProjectModel project_name=#{project_name}]"
|
243
|
-
end
|
244
|
-
|
245
|
-
protected
|
246
|
-
|
247
|
-
def method_missing(method_name, *args)
|
248
|
-
method_name = method_name.to_s
|
249
|
-
if method_name =~ /=$/
|
250
|
-
super if args.size > 1
|
251
|
-
self[method_name[0...-1]] = args[0]
|
252
|
-
else
|
253
|
-
super unless has_key?(method_name) and args.empty?
|
254
|
-
self[method_name]
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
# Helper method to expose the project model as a Rake Task
|
261
|
-
def project_model(task_name)
|
262
|
-
model = Sprout::ProjectModel.new
|
263
|
-
yield model if block_given?
|
264
|
-
|
265
|
-
t = task task_name
|
266
|
-
|
267
|
-
def t.project_model=(model)
|
268
|
-
@model = model
|
269
|
-
end
|
270
|
-
|
271
|
-
def t.project_model
|
272
|
-
return @model
|
273
|
-
end
|
274
|
-
|
275
|
-
t.project_model = model
|
276
|
-
return model
|
277
|
-
end
|
278
|
-
|