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.

Files changed (211) hide show
  1. data/CHANGELOG.md +10 -0
  2. data/Gemfile +28 -0
  3. data/MIT-LICENSE +3 -2
  4. data/POSTINSTALL.rdoc +28 -0
  5. data/README.textile +152 -0
  6. data/bin/sprout +1 -131
  7. data/bin/sprout-generator +10 -0
  8. data/bin/sprout-library +11 -0
  9. data/bin/sprout-tool +10 -0
  10. data/lib/sprout.rb +4 -500
  11. data/lib/sprout/archive_unpacker.rb +122 -206
  12. data/lib/sprout/base.rb +90 -0
  13. data/lib/sprout/concern.rb +30 -0
  14. data/lib/sprout/dir.rb +23 -0
  15. data/lib/sprout/errors.rb +94 -0
  16. data/lib/sprout/executable.rb +496 -0
  17. data/lib/sprout/executable/boolean.rb +35 -0
  18. data/lib/sprout/executable/collection_param.rb +53 -0
  19. data/lib/sprout/executable/file_param.rb +53 -0
  20. data/lib/sprout/executable/files.rb +26 -0
  21. data/lib/sprout/executable/number.rb +10 -0
  22. data/lib/sprout/executable/param.rb +222 -0
  23. data/lib/sprout/executable/parameter_factory.rb +28 -0
  24. data/lib/sprout/executable/path.rb +21 -0
  25. data/lib/sprout/executable/paths.rb +21 -0
  26. data/lib/sprout/executable/string_param.rb +15 -0
  27. data/lib/sprout/executable/strings.rb +11 -0
  28. data/lib/sprout/executable/url.rb +10 -0
  29. data/lib/sprout/executable/urls.rb +10 -0
  30. data/lib/sprout/file_target.rb +76 -0
  31. data/lib/sprout/generator/base.rb +233 -0
  32. data/lib/sprout/generator/command.rb +67 -0
  33. data/lib/sprout/generator/directory_manifest.rb +49 -0
  34. data/lib/sprout/generator/file_manifest.rb +55 -0
  35. data/lib/sprout/generator/manifest.rb +13 -0
  36. data/lib/sprout/generator/template_manifest.rb +13 -0
  37. data/lib/sprout/generators/generator/generator_generator.rb +48 -0
  38. data/lib/sprout/generators/generator/templates/generator_class.rb +17 -0
  39. data/lib/sprout/generators/generator/templates/generator_executable +9 -0
  40. data/lib/sprout/generators/generator/templates/generator_template +1 -0
  41. data/lib/sprout/generators/generator/templates/generator_test.rb +37 -0
  42. data/lib/sprout/generators/generator/templates/generator_test_helper.rb +16 -0
  43. data/lib/sprout/generators/library/library_generator.rb +20 -0
  44. data/lib/sprout/generators/library/templates/library.gemspec +19 -0
  45. data/lib/sprout/generators/library/templates/library.rb +15 -0
  46. data/lib/sprout/generators/ruby/ruby_generator.rb +59 -0
  47. data/lib/sprout/generators/ruby/templates/ruby_base.rb +10 -0
  48. data/lib/sprout/generators/ruby/templates/ruby_executable +6 -0
  49. data/lib/sprout/generators/ruby/templates/ruby_gemfile +4 -0
  50. data/lib/sprout/generators/ruby/templates/ruby_input.rb +7 -0
  51. data/lib/sprout/generators/tool/templates/Gemfile +4 -0
  52. data/lib/sprout/generators/tool/templates/tool.gemspec +22 -0
  53. data/lib/sprout/generators/tool/templates/tool.rb +38 -0
  54. data/lib/sprout/generators/tool/tool_generator.rb +36 -0
  55. data/lib/sprout/library.rb +111 -0
  56. data/lib/sprout/log.rb +1 -0
  57. data/lib/sprout/platform.rb +71 -0
  58. data/lib/sprout/process_runner.rb +80 -40
  59. data/lib/sprout/progress_bar.rb +341 -0
  60. data/lib/sprout/rdoc_parser.rb +91 -0
  61. data/lib/sprout/remote_file_loader.rb +72 -50
  62. data/lib/sprout/remote_file_target.rb +44 -152
  63. data/lib/sprout/ruby_feature.rb +167 -0
  64. data/lib/sprout/specification.rb +197 -0
  65. data/lib/sprout/string.rb +19 -0
  66. data/lib/sprout/system.rb +35 -0
  67. data/lib/sprout/system/base_system.rb +225 -0
  68. data/lib/sprout/system/java_system.rb +9 -0
  69. data/lib/sprout/system/osx_system.rb +26 -0
  70. data/lib/sprout/system/unix_system.rb +72 -0
  71. data/lib/sprout/system/vista_system.rb +16 -0
  72. data/lib/sprout/system/win_nix_system.rb +41 -0
  73. data/lib/sprout/system/win_system.rb +76 -0
  74. data/lib/sprout/test/sprout_test_case.rb +211 -0
  75. data/lib/sprout/version.rb +9 -4
  76. data/rakefile.rb +85 -144
  77. data/script/console +10 -0
  78. data/script/destroy +14 -0
  79. data/script/generate +14 -0
  80. data/sprout.gemspec +26 -0
  81. data/test/fixtures/archive_unpacker/copyable/some_file.exe +0 -0
  82. data/test/fixtures/archive_unpacker/copyable/some_file.rb +0 -0
  83. data/test/fixtures/archive_unpacker/copyable/some_file.swc +0 -0
  84. data/test/fixtures/archive_unpacker/tgz/some folder.tgz +0 -0
  85. data/test/fixtures/archive_unpacker/tgz/some_file.tgz +0 -0
  86. data/test/fixtures/archive_unpacker/zip/some folder.zip +0 -0
  87. data/test/fixtures/archive_unpacker/zip/some_file.zip +0 -0
  88. data/test/fixtures/examples/app_generator.rb +127 -0
  89. data/test/fixtures/examples/echo_inputs.rb +151 -0
  90. data/test/fixtures/executable/echochamber_gem/bin/echochamber +3 -0
  91. data/test/fixtures/executable/echochamber_gem/echo_chamber.rb +10 -0
  92. data/test/fixtures/executable/flex3sdk_gem/flex3sdk.rb +11 -0
  93. data/test/fixtures/executable/flex3sdk_gem/mxmlc +3 -0
  94. data/test/fixtures/executable/flex3sdk_gem/mxmlc.bat +3 -0
  95. data/test/fixtures/executable/mxmlc.rb +805 -0
  96. data/test/fixtures/executable/params/input.as +0 -0
  97. data/test/fixtures/executable/params/input2.as +0 -0
  98. data/test/fixtures/executable/params/input3.as +0 -0
  99. data/test/fixtures/executable/params/mxmlc +5 -0
  100. data/test/fixtures/executable/path with spaces/input.as b/data/test/fixtures/executable/path with → spaces/input.as +0 -0
  101. data/test/fixtures/executable/path with spaces/input2.as b/data/test/fixtures/executable/path with → spaces/input2.as +0 -0
  102. data/test/fixtures/executable/path with spaces/input3.as b/data/test/fixtures/executable/path with → spaces/input3.as +0 -0
  103. data/test/fixtures/executable/paths/folder1/file1 +0 -0
  104. data/test/fixtures/executable/paths/folder1/file2 +0 -0
  105. data/test/fixtures/executable/paths/folder1/file3 +0 -0
  106. data/test/fixtures/executable/paths/folder2/file4 +0 -0
  107. data/test/fixtures/executable/paths/folder2/file5 +0 -0
  108. data/test/fixtures/executable/paths/folder3/file6 +0 -0
  109. data/test/fixtures/executable/src/Main.as +0 -0
  110. data/test/fixtures/executable/windows_line_endings +47 -0
  111. data/test/fixtures/generators/song_generator.rb +11 -0
  112. data/test/fixtures/generators/song_subclass/least_favorite.rb +10 -0
  113. data/test/fixtures/generators/song_subclass/templates/Song.txt +3 -0
  114. data/test/fixtures/generators/temp_generator.rb +24 -0
  115. data/test/fixtures/generators/templates/Main.as +9 -0
  116. data/test/fixtures/generators/templates/OtherFileTemplate +1 -0
  117. data/test/fixtures/generators/templates/SomeFile +1 -0
  118. data/test/fixtures/generators/templates/SomeSubclassFile +2 -0
  119. data/test/fixtures/generators/templates/Song.txt +3 -0
  120. data/test/fixtures/generators/templates/destroy +0 -0
  121. data/test/fixtures/generators/templates/generate +0 -0
  122. data/test/fixtures/library/archive/Archive.swc +0 -0
  123. data/test/fixtures/library/sources/lib/a/A.as +0 -0
  124. data/test/fixtures/library/sources/lib/b/B.as +0 -0
  125. data/test/fixtures/library/sources/src/Source.as +0 -0
  126. data/test/fixtures/process_runner/chmod_script.sh +3 -0
  127. data/test/fixtures/process_runner/dir with spaces/chmod_script.sh +3 -0
  128. data/test/fixtures/process_runner/failure +5 -0
  129. data/test/fixtures/process_runner/success +4 -0
  130. data/test/fixtures/remote_file_loader/md5/echochamber-test.zip +0 -0
  131. data/test/fixtures/remote_file_loader/md5/file_with_known_md5 +0 -0
  132. data/test/fixtures/remote_file_target/bin/echochamber +3 -0
  133. data/test/fixtures/remote_file_target/bin/echochamber.bat +3 -0
  134. data/test/fixtures/remote_file_target/echochamber-test.zip +0 -0
  135. data/test/fixtures/specification/asunit4.rb +25 -0
  136. data/test/fixtures/specification/ext/AsUnit-4.1.pre.swc +0 -0
  137. data/test/fixtures/specification/flashplayer.rb +30 -0
  138. data/test/fixtures/specification/flex4sdk.rb +72 -0
  139. data/test/fixtures/specification/flexunit4.sproutspec +17 -0
  140. data/test/fixtures/specification/lib/as3reflection/Reflection.as +0 -0
  141. data/test/fixtures/specification/src/AsUnit.as +0 -0
  142. data/test/fixtures/user/mxmlc_crlf +3 -0
  143. data/test/unit/archive_unpacker_test.rb +108 -0
  144. data/test/unit/boolean_param_test.rb +38 -0
  145. data/test/unit/executable_option_parser_test.rb +142 -0
  146. data/test/unit/executable_param_test.rb +76 -0
  147. data/test/unit/executable_test.rb +237 -0
  148. data/test/unit/fake_executable_task.rb +22 -0
  149. data/test/unit/fake_other_executable.rb +20 -0
  150. data/test/unit/fake_process_runner.rb +29 -0
  151. data/test/unit/file_param_test.rb +61 -0
  152. data/test/unit/file_target_test.rb +42 -0
  153. data/test/unit/files_param_test.rb +72 -0
  154. data/test/unit/generator_generator_test.rb +85 -0
  155. data/test/unit/generator_test.rb +333 -0
  156. data/test/unit/library_generator_test.rb +41 -0
  157. data/test/unit/library_test.rb +88 -0
  158. data/test/unit/osx_system_test.rb +20 -0
  159. data/test/unit/path_param_test.rb +43 -0
  160. data/test/unit/paths_param_test.rb +53 -0
  161. data/test/unit/platform_test.rb +76 -0
  162. data/test/unit/process_runner_test.rb +104 -0
  163. data/test/unit/rdoc_parser_test.rb +15 -0
  164. data/test/unit/remote_file_loader_test.rb +34 -0
  165. data/test/unit/remote_file_target_test.rb +105 -0
  166. data/test/unit/ruby_feature_test.rb +108 -0
  167. data/test/unit/ruby_generator_test.rb +70 -0
  168. data/test/unit/specification_test.rb +73 -0
  169. data/test/unit/sprout_test.rb +170 -0
  170. data/test/unit/sprout_test_helper.rb +18 -0
  171. data/test/unit/string_param_test.rb +19 -0
  172. data/test/unit/string_test.rb +20 -0
  173. data/test/unit/strings_param_test.rb +27 -0
  174. data/test/unit/test_helper.rb +1 -0
  175. data/test/unit/tool_generator_test.rb +43 -0
  176. data/test/unit/unix_system_test.rb +52 -0
  177. data/test/unit/user_test.rb +147 -0
  178. data/test/unit/vista_system_test.rb +40 -0
  179. data/test/unit/win_nix_system_test.rb +26 -0
  180. data/test/unit/win_system_test.rb +61 -0
  181. metadata +318 -113
  182. data/doc/Bundle +0 -14
  183. data/doc/Generator +0 -35
  184. data/doc/Library +0 -63
  185. data/doc/Task +0 -21
  186. data/doc/Tool +0 -20
  187. data/lib/platform.rb +0 -113
  188. data/lib/progress_bar.rb +0 -354
  189. data/lib/sprout/builder.rb +0 -51
  190. data/lib/sprout/bundle_resolver.rb +0 -349
  191. data/lib/sprout/commands/generate.rb +0 -9
  192. data/lib/sprout/dynamic_accessors.rb +0 -40
  193. data/lib/sprout/general_tasks.rb +0 -6
  194. data/lib/sprout/generator.rb +0 -7
  195. data/lib/sprout/generator/base_mixins.rb +0 -186
  196. data/lib/sprout/generator/named_base.rb +0 -227
  197. data/lib/sprout/project_model.rb +0 -278
  198. data/lib/sprout/simple_resolver.rb +0 -88
  199. data/lib/sprout/tasks/erb_resolver.rb +0 -118
  200. data/lib/sprout/tasks/gem_wrap_task.rb +0 -214
  201. data/lib/sprout/tasks/git_task.rb +0 -134
  202. data/lib/sprout/tasks/library_task.rb +0 -118
  203. data/lib/sprout/tasks/sftp_task.rb +0 -248
  204. data/lib/sprout/tasks/ssh_task.rb +0 -153
  205. data/lib/sprout/tasks/tool_task.rb +0 -836
  206. data/lib/sprout/tasks/zip_task.rb +0 -158
  207. data/lib/sprout/tool_task_model.rb +0 -19
  208. data/lib/sprout/user.rb +0 -415
  209. data/lib/sprout/version_file.rb +0 -89
  210. data/lib/sprout/zip_util.rb +0 -61
  211. data/samples/gem_wrap/rakefile.rb +0 -17
@@ -1,51 +0,0 @@
1
-
2
- module Sprout
3
-
4
- class BuilderError < StandardError #:nodoc:
5
- end
6
-
7
- # accepts a destination path and a sprout specification
8
- # and will download and unpack the platform-specific
9
- # archives that are identified in the spec
10
- class Builder # :nodoc:
11
-
12
- def self.build(file_targets_yaml, gem_name=nil, gem_version=nil)
13
- destination = Builder.gem_file_cache(gem_name, gem_version)
14
- data = nil
15
-
16
- File.open(file_targets_yaml, 'r') do |f|
17
- data = f.read
18
- end
19
-
20
- targets = YAML.load(data)
21
- targets.each do |target|
22
- # iterate over the provided RemoteFileTargets until we
23
- # encounter one that is appropriate for our platform,
24
- # or one that claims to be universal.
25
- # When authoring a sprout.spec for libraries or tools,
26
- # put the most specific RemoteFileTargets first, then
27
- # universals to catch unexpected platforms.
28
- target.gem_name = gem_name
29
- target.gem_version = gem_version
30
- if(target.platform == platform || target.platform == 'universal')
31
- target.install_path = FileUtils.mkdir_p(destination)
32
- target.resolve
33
- return target
34
- end
35
- end
36
- raise BuilderError.new("Sprout::Builder.build failed, unsupported platform [#{platform}] or unexpected yaml")
37
- end
38
-
39
- private
40
-
41
- def self.gem_file_cache(gem_name, gem_version)
42
- Sprout.gem_file_cache(gem_name, gem_version)
43
- end
44
-
45
- def self.platform
46
- @@platform ||= User.new.platform.to_s
47
- end
48
-
49
- end
50
- end
51
-
@@ -1,349 +0,0 @@
1
- # Taken from http://github.com/carlhuda/bundler
2
- module Gem
3
- class Dependency
4
- def required_by
5
- @required_by ||= []
6
- end
7
- end
8
- class Specification
9
- def required_by
10
- @required_by ||= []
11
- end
12
- end
13
- end
14
-
15
- module Sprout
16
-
17
- class Index
18
- def self.from_installed_gems
19
- #Source::SystemGems.new.specs
20
- index = Index.new
21
- Gem::cache.each do |name, spec|
22
- index << spec
23
- end
24
- index
25
- end
26
-
27
- def self.from_cached_specs(path)
28
- # index = Index.new
29
- # Sprout::cache
30
- # Dir["#{path}/*.gem"].each do |gemfile|
31
- # spec = Gem::Format.from_file_by_path(gemfile).spec
32
- # index << spec
33
- # end
34
-
35
- # index
36
- end
37
-
38
- def initialize
39
- @cache = {}
40
- @specs = Hash.new { |h,k| h[k] = [] }
41
- end
42
-
43
- def initialize_copy(o)
44
- super
45
- @cache = {}
46
- @specs = Hash.new { |h,k| h[k] = [] }
47
- merge!(o)
48
- end
49
-
50
- def empty?
51
- each { return false }
52
- true
53
- end
54
-
55
- def search(query)
56
- case query
57
- when Gem::Specification then search_by_spec(query)
58
- when String then @specs[query]
59
- else search_by_dependency(query)
60
- end
61
- end
62
-
63
- alias [] search
64
-
65
- def <<(spec)
66
- arr = @specs[spec.name]
67
-
68
- arr.delete_if do |s|
69
- s.version == spec.version && s.platform == spec.platform
70
- end
71
-
72
- arr << spec
73
- spec
74
- end
75
-
76
- def each(&blk)
77
- @specs.values.each do |specs|
78
- specs.each(&blk)
79
- end
80
- end
81
-
82
- def merge!(other)
83
- other.each do |spec|
84
- self << spec
85
- end
86
- self
87
- end
88
-
89
- def merge(other)
90
- dup.merge!(other)
91
- end
92
-
93
- def freeze
94
- @specs.each do |k,v|
95
- v.freeze
96
- end
97
- super
98
- end
99
-
100
- private
101
-
102
- def search_by_spec(spec)
103
- @specs[spec.name].select { |s| s.version == spec.version }
104
- end
105
-
106
- def search_by_dependency(dependency)
107
- @cache[dependency.hash] ||= begin
108
- specs = @specs[dependency.name]
109
-
110
- #wants_prerelease = dependency.requirement.prerelease?
111
- #only_prerelease = specs.all? {|spec| spec.version.prerelease? }
112
- found = specs.select { |spec| dependency =~ spec }
113
-
114
- #unless wants_prerelease || only_prerelease
115
- # found.reject! { |spec| spec.version.prerelease? }
116
- #end
117
-
118
- found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\\0" : s.platform.to_s] }
119
- end
120
-
121
- end
122
-
123
- end
124
-
125
- class Resolver
126
- attr_reader :errors
127
-
128
- # Figures out the best possible configuration of gems that satisfies
129
- # the list of passed dependencies and any child dependencies without
130
- # causing any gem activation errors.
131
- #
132
- # ==== Parameters
133
- # *dependencies<Gem::Dependency>:: The list of dependencies to resolve
134
- #
135
- # ==== Returns
136
- # <GemBundle>,nil:: If the list of dependencies can be resolved, a
137
- # collection of gemspecs is returned. Otherwise, nil is returned.
138
- def self.resolve(requirements, index, source_requirements = {})
139
- resolver = new(index, source_requirements)
140
- result = catch(:success) do
141
- resolver.resolve(requirements, {})
142
- output = resolver.errors.inject("") do |o, (conflict, (origin, requirement))|
143
- if origin
144
- o << " Conflict on: #{conflict.inspect}:\\n"
145
- o << " * #{conflict} (#{origin.version}) activated by #{origin.required_by.first}\\n"
146
- o << " * #{requirement} required by #{requirement.required_by.first}\\n"
147
- else
148
- o << " #{requirement} not found in any of the sources\\n"
149
- o << " required by #{requirement.required_by.first}\\n"
150
- end
151
- o << " All possible versions of origin requirements conflict."
152
- end
153
- raise VersionConflict, "No compatible versions could be found for required dependencies:\\n #{output}"
154
- nil
155
- end
156
- if result
157
- # Order gems in order of dependencies. Every gem's dependency is at
158
- # a smaller index in the array.
159
- ordered = []
160
- result.values.each do |spec1|
161
- index = nil
162
- place = ordered.detect do |spec2|
163
- spec1.dependencies.any? { |d| d.name == spec2.name }
164
- end
165
- place ?
166
- ordered.insert(ordered.index(place), spec1) :
167
- ordered << spec1
168
- end
169
- ordered.reverse
170
- end
171
- end
172
-
173
- def self.resolve_libraries(library_names)
174
- index = Index.from_installed_gems
175
- lib_specs = library_names.map {|lib| Sprout.find_gem_spec "sprout-#{lib}-library" }
176
- resolved_specs = resolve lib_specs, index
177
- library_names_with_dependencies = []
178
- resolved_specs.each do |l|
179
- if l.name =~ /\Asprout-(.*)-library\Z/
180
- library_names_with_dependencies << $1
181
- end
182
- end
183
- library_names_with_dependencies
184
- end
185
-
186
- def initialize(index, source_requirements)
187
- @errors = {}
188
- @stack = []
189
- @index = index
190
- @source_requirements = source_requirements
191
- end
192
-
193
- def debug
194
- puts yield if defined?($debug) && $debug
195
- end
196
-
197
- def resolve(reqs, activated)
198
- # If the requirements are empty, then we are in a success state. Aka, all
199
- # gem dependencies have been resolved.
200
- throw :success, activated if reqs.empty?
201
-
202
- debug { STDIN.gets ; print "\\e[2J\\e[f" ; "==== Iterating ====\\n\\n" }
203
-
204
- # Sort dependencies so that the ones that are easiest to resolve are first.
205
- # Easiest to resolve is defined by:
206
- # 1) Is this gem already activated?
207
- # 2) Do the version requirements include prereleased gems?
208
- # 3) Sort by number of gems available in the source.
209
- reqs = reqs.sort_by do |a|
210
- [ activated[a.name] ? 0 : 1,
211
- #a.requirement.prerelease? ? 0 : 1,
212
- @errors[a.name] ? 0 : 1,
213
- activated[a.name] ? 0 : search(a).size ]
214
- end
215
-
216
- debug { "Activated:\\n" + activated.values.map { |a| " #{a.name} (#{a.version})" }.join("\\n") }
217
- debug { "Requirements:\\n" + reqs.map { |r| " #{r.name} (#{r.requirement})"}.join("\\n") }
218
-
219
- activated = activated.dup
220
- # Pull off the first requirement so that we can resolve it
221
- current = reqs.shift
222
-
223
- debug { "Attempting:\\n #{current.name} (#{current.requirement})"}
224
-
225
- # Check if the gem has already been activated, if it has, we will make sure
226
- # that the currently activated gem satisfies the requirement.
227
- if existing = activated[current.name]
228
- if current.requirement.satisfied_by?(existing.version)
229
- debug { " * [SUCCESS] Already activated" }
230
- @errors.delete(existing.name)
231
- # Since the current requirement is satisfied, we can continue resolving
232
- # the remaining requirements.
233
- resolve(reqs, activated)
234
- else
235
- debug { " * [FAIL] Already activated" }
236
- @errors[existing.name] = [existing, current]
237
- debug { current.required_by.map {|d| " * #{d.name} (#{d.requirement})" }.join("\\n") }
238
- # debug { " * All current conflicts:\\n" + @errors.keys.map { |c| " - #{c}" }.join("\\n") }
239
- # Since the current requirement conflicts with an activated gem, we need
240
- # to backtrack to the current requirement's parent and try another version
241
- # of it (maybe the current requirement won't be present anymore). If the
242
- # current requirement is a root level requirement, we need to jump back to
243
- # where the conflicting gem was activated.
244
- parent = current.required_by.last || existing.required_by.last
245
- # We track the spot where the current gem was activated because we need
246
- # to keep a list of every spot a failure happened.
247
- debug { " -> Jumping to: #{parent.name}" }
248
- throw parent.name, existing.required_by.last.name
249
- end
250
- else
251
- # There are no activated gems for the current requirement, so we are going
252
- # to find all gems that match the current requirement and try them in decending
253
- # order. We also need to keep a set of all conflicts that happen while trying
254
- # this gem. This is so that if no versions work, we can figure out the best
255
- # place to backtrack to.
256
- conflicts = Set.new
257
-
258
- # Fetch all gem versions matching the requirement
259
- #
260
- # TODO: Warn / error when no matching versions are found.
261
- matching_versions = search(current)
262
-
263
- if matching_versions.empty?
264
- if current.required_by.empty?
265
- if current.source
266
- name = current.name
267
- versions = @source_requirements[name][name].map { |s| s.version }
268
- message = "Could not find gem '#{current}' in #{current.source}.\\n"
269
- if versions.any?
270
- message << "Source contains '#{current.name}' at: #{versions.join(', ')}"
271
- else
272
- message << "Source does not contain any versions of '#{current}'"
273
- end
274
-
275
- raise GemNotFound, message
276
- else
277
- raise GemNotFound, "Could not find gem '#{current}' in any of the sources."
278
- end
279
- location = current.source ? current.source.to_s : "any of the sources"
280
- raise GemNotFound, "Could not find gem '#{current}' in #{location}.\\n"
281
- else
282
- @errors[current.name] = [nil, current]
283
- end
284
- end
285
-
286
- matching_versions.reverse_each do |spec|
287
- conflict = resolve_requirement(spec, current, reqs.dup, activated.dup)
288
- conflicts << conflict if conflict
289
- end
290
- # If the current requirement is a root level gem and we have conflicts, we
291
- # can figure out the best spot to backtrack to.
292
- if current.required_by.empty? && !conflicts.empty?
293
- # Check the current "catch" stack for the first one that is included in the
294
- # conflicts set. That is where the parent of the conflicting gem was required.
295
- # By jumping back to this spot, we can try other version of the parent of
296
- # the conflicting gem, hopefully finding a combination that activates correctly.
297
- @stack.reverse_each do |savepoint|
298
- if conflicts.include?(savepoint)
299
- debug { " -> Jumping to: #{savepoint}" }
300
- throw savepoint
301
- end
302
- end
303
- end
304
- end
305
- end
306
-
307
- def resolve_requirement(spec, requirement, reqs, activated)
308
- # We are going to try activating the spec. We need to keep track of stack of
309
- # requirements that got us to the point of activating this gem.
310
- spec.required_by.replace requirement.required_by
311
- spec.required_by << requirement
312
-
313
- activated[spec.name] = spec
314
- debug { " Activating: #{spec.name} (#{spec.version})" }
315
- debug { spec.required_by.map { |d| " * #{d.name} (#{d.requirement})" }.join("\\n") }
316
-
317
- # Now, we have to loop through all child dependencies and add them to our
318
- # array of requirements.
319
- debug { " Dependencies"}
320
- spec.dependencies.each do |dep|
321
- next if dep.type == :development
322
- debug { " * #{dep.name} (#{dep.requirement})" }
323
- dep.required_by.replace(requirement.required_by)
324
- dep.required_by << requirement
325
- reqs << dep
326
- end
327
-
328
- # We create a savepoint and mark it by the name of the requirement that caused
329
- # the gem to be activated. If the activated gem ever conflicts, we are able to
330
- # jump back to this point and try another version of the gem.
331
- length = @stack.length
332
- @stack << requirement.name
333
- retval = catch(requirement.name) do
334
- resolve(reqs, activated)
335
- end
336
- # Since we're doing a lot of throw / catches. A push does not necessarily match
337
- # up to a pop. So, we simply slice the stack back to what it was before the catch
338
- # block.
339
- @stack.slice!(length..-1)
340
- retval
341
- end
342
-
343
- def search(dep)
344
- index = @source_requirements[dep.name] || @index
345
- index.search(dep)
346
- end
347
-
348
- end
349
- end
@@ -1,9 +0,0 @@
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
@@ -1,40 +0,0 @@
1
-
2
- # DynamicAccessors provides support for
3
- # simply setting and getting values of any kind from
4
- # any object that includes it.
5
- #
6
- # require 'dynamic_accessors'
7
- #
8
- # class Foo
9
- # include DynamicAccessors
10
- # end
11
- #
12
- # foo = Foo.new
13
- # foo.bar = "Hello World"
14
- # foo.friends = ['a', 'b', 'c']
15
- # puts "foo.bar: #{foo.bar}"
16
- # puts "foo.friends: #{foo.friends.join(', ')}"
17
-
18
- module DynamicAccessors
19
-
20
- def initialize(*params)
21
- super
22
- @missing_params_hash = Hash.new
23
- end
24
-
25
- def each_attribute
26
- @missing_params_hash.each do |param|
27
- yield param if block_given?
28
- end
29
- end
30
-
31
- def method_missing(method, *params, &block)
32
- if(method.to_s.match(/=$/))
33
- method = method.to_s.gsub('=', '').to_sym
34
- return @missing_params_hash[method] = params.shift
35
- else
36
- return @missing_params_hash[method] if @missing_params_hash.keys.collect(&:to_sym).include?(method)
37
- end
38
- super
39
- end
40
- end