buildr-hx 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "buildr", "~> 1.4.6"
10
+ gem "shoulda", ">= 0"
11
+ gem "bundler", "~> 1.0.0"
12
+ gem "jeweler", "~> 1.5.2"
13
+ gem "simplecov", :require => false
14
+ gem "simplecov-rcov", :require => false
15
+ gem "rspec", "~> 2.1.0"
16
+ gem "ci_reporter", "~> 1.6.5"
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ atoulme-Antwrap (0.7.1)
5
+ rjb (>= 1.0.3)
6
+ builder (2.1.2)
7
+ buildr (1.4.6)
8
+ atoulme-Antwrap (= 0.7.1)
9
+ builder (= 2.1.2)
10
+ diff-lcs (= 1.1.2)
11
+ highline (= 1.5.1)
12
+ hoe (= 2.3.3)
13
+ json_pure (= 1.4.3)
14
+ minitar (= 0.5.3)
15
+ net-sftp (= 2.0.4)
16
+ net-ssh (= 2.0.23)
17
+ rake (= 0.8.7)
18
+ rjb (= 1.3.3)
19
+ rspec (= 2.1.0)
20
+ rspec-core (= 2.1.0)
21
+ rspec-expectations (= 2.1.0)
22
+ rspec-mocks (= 2.1.0)
23
+ rubyforge (= 2.0.3)
24
+ rubyzip (= 0.9.4)
25
+ xml-simple (= 1.0.12)
26
+ ci_reporter (1.6.5)
27
+ builder (>= 2.1.2)
28
+ diff-lcs (1.1.2)
29
+ git (1.2.5)
30
+ highline (1.5.1)
31
+ hoe (2.3.3)
32
+ rake (>= 0.8.7)
33
+ rubyforge (>= 1.0.4)
34
+ jeweler (1.5.2)
35
+ bundler (~> 1.0.0)
36
+ git (>= 1.2.5)
37
+ rake
38
+ json_pure (1.4.3)
39
+ minitar (0.5.3)
40
+ multi_json (1.0.3)
41
+ net-sftp (2.0.4)
42
+ net-ssh (>= 2.0.9)
43
+ net-ssh (2.0.23)
44
+ rake (0.8.7)
45
+ rjb (1.3.3)
46
+ rspec (2.1.0)
47
+ rspec-core (~> 2.1.0)
48
+ rspec-expectations (~> 2.1.0)
49
+ rspec-mocks (~> 2.1.0)
50
+ rspec-core (2.1.0)
51
+ rspec-expectations (2.1.0)
52
+ diff-lcs (~> 1.1.2)
53
+ rspec-mocks (2.1.0)
54
+ rubyforge (2.0.3)
55
+ json_pure (>= 1.1.7)
56
+ rubyzip (0.9.4)
57
+ shoulda (2.11.3)
58
+ simplecov (0.5.4)
59
+ multi_json (~> 1.0.3)
60
+ simplecov-html (~> 0.5.3)
61
+ simplecov-html (0.5.3)
62
+ simplecov-rcov (0.2.3)
63
+ simplecov (>= 0.4.1)
64
+ xml-simple (1.0.12)
65
+
66
+ PLATFORMS
67
+ ruby
68
+
69
+ DEPENDENCIES
70
+ buildr (~> 1.4.6)
71
+ bundler (~> 1.0.0)
72
+ ci_reporter (~> 1.6.5)
73
+ jeweler (~> 1.5.2)
74
+ rspec (~> 2.1.0)
75
+ shoulda
76
+ simplecov
77
+ simplecov-rcov
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 devboy
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = buildr-hx
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to buildr-hx
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 devboy. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+ require 'rake'
12
+
13
+ require 'jeweler'
14
+ require File.dirname(__FILE__)+"/rake/jeweler_prerelease_tasks"
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = "buildr-hx"
17
+ gem.homepage = "http://github.com/devboy/buildr-hx"
18
+ gem.license = "MIT"
19
+ gem.summary = "Buildr extension to allow haXe development."
20
+ gem.description = "Build like you code - now supporting haXe"
21
+ gem.email = "dominic @nospam@ devboy.org"
22
+ gem.authors = ["Dominic Graefen"]
23
+ gem.add_runtime_dependency("buildr",">=1.4.6")
24
+ end
25
+ Jeweler::RubygemsDotOrgTasks.new
26
+ Jeweler::PrereleaseTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ require 'ci/reporter/rake/rspec'
31
+
32
+ ENV["CI_REPORTS"] ||= File.expand_path( File.join( File.dirname(__FILE__), "test", "report" ) )
33
+ RSpec::Core::RakeTask.new(:spec) do |spec|
34
+ spec.pattern = FileList['spec/**/*_spec.rb']
35
+ end
36
+
37
+ task :spec => "ci:setup:rspec"
38
+
39
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
40
+ spec.pattern = 'spec/**/*_spec.rb'
41
+ spec.rcov = true
42
+ end
43
+
44
+ task :test => :spec
45
+ task :default => :spec
46
+
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "buildr-hx #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1.pre
data/buildr-hx.iml ADDED
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="jdk" jdkName="RVM: ruby-1.9.2-p180" jdkType="RUBY_SDK" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ </component>
9
+ </module>
10
+
data/lib/buildr-hx.rb ADDED
File without changes
data/rake/jeweler.rb ADDED
@@ -0,0 +1,17 @@
1
+ class Jeweler
2
+ require File.dirname(__FILE__)+'/pre_release_to_git'
3
+ require File.dirname(__FILE__)+'/pre_release_gemspec'
4
+
5
+ def prerelease_to_git
6
+ Jeweler::Commands::PreReleaseToGit.build_for(self).run
7
+ end
8
+
9
+ def prerelease_gemspec
10
+ Jeweler::Commands::PreReleaseGemspec.build_for(self).run
11
+ end
12
+
13
+ def is_prerelease_version?
14
+ version.end_with? ".pre"
15
+ end
16
+
17
+ end
@@ -0,0 +1,50 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require File.dirname(__FILE__)+"/jeweler"
4
+
5
+ class Jeweler
6
+ class PrereleaseTasks < Rake::TaskLib
7
+ attr_accessor :jeweler
8
+
9
+ def initialize
10
+ yield self if block_given?
11
+
12
+ define
13
+ end
14
+
15
+ def jeweler
16
+ @jeweler ||= Rake.application.jeweler
17
+ end
18
+
19
+ def define
20
+ namespace :git do
21
+ desc "Tag and push prerelease to git. (happens by default with `rake prerelease`)"
22
+ task :prerelease do
23
+ jeweler.prerelease_to_git
24
+ end
25
+ end
26
+
27
+ namespace :gemspec do
28
+ desc "Regenerate and validate gemspec, and then commits and pushes to git on develop branch"
29
+ task :prerelease do
30
+ jeweler.prerelease_gemspec
31
+ end
32
+ end
33
+
34
+ desc "Verifies that it is a prerelease version."
35
+ task :is_prerelease_version => :version_required do
36
+ abort "it's not a prerelease version" unless jeweler.is_prerelease_version?
37
+ end
38
+
39
+ namespace :rubygems do
40
+ desc "Release gem to Gemcutter"
41
+ task :release => [:gemspec, :build] do
42
+ jeweler.release_gem_to_rubygems
43
+ end
44
+ end
45
+
46
+ desc "Make a prerelease to rubygems."
47
+ task :prerelease => [:is_prerelease_version, 'gemspec:prerelease', 'git:prerelease', 'rubygems:release']
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,80 @@
1
+ class Jeweler
2
+ module Commands
3
+ class PreReleaseGemspec
4
+ attr_accessor :gemspec, :version, :repo, :output, :gemspec_helper, :base_dir
5
+
6
+ def initialize(attributes = {})
7
+ self.output = $stdout
8
+
9
+ attributes.each_pair do |key, value|
10
+ send("#{key}=", value)
11
+ end
12
+ end
13
+
14
+ def run
15
+ unless clean_staging_area?
16
+ system "git status"
17
+ raise "Unclean staging area! Be sure to commit or .gitignore everything first. See `git status` above."
18
+ end
19
+
20
+ repo.checkout('develop')
21
+
22
+ regenerate_gemspec!
23
+ commit_gemspec! if gemspec_changed?
24
+
25
+ output.puts "Pushing develop to origin"
26
+ repo.push
27
+ end
28
+
29
+ def clean_staging_area?
30
+ # surprisingly simpler than ruby-git
31
+ `git ls-files --deleted --modified --others --exclude-standard` == ""
32
+ end
33
+
34
+ def commit_gemspec!
35
+ gemspec_gitpath = working_subdir.join(gemspec_helper.path)
36
+ repo.add(gemspec_gitpath.to_s)
37
+ output.puts "Committing #{gemspec_gitpath}"
38
+ repo.commit "Regenerate gemspec for version #{version}"
39
+ end
40
+
41
+ def regenerate_gemspec!
42
+ gemspec_helper.update_version(version)
43
+ gemspec_helper.write
44
+ end
45
+
46
+ def gemspec_changed?
47
+ # OMGHAX. ruby-git status always ends up being 'M', so let's do it a crazy way
48
+ system "git status -s #{working_subdir.join(gemspec_helper.path)} | grep #{working_subdir.join(gemspec_helper.path)} > /dev/null 2>/dev/null"
49
+ end
50
+
51
+ def gemspec_helper
52
+ @gemspec_helper ||= Jeweler::GemSpecHelper.new(self.gemspec, self.base_dir)
53
+ end
54
+
55
+ def working_subdir
56
+ return @working_subdir if @working_subdir
57
+ cwd = base_dir_path
58
+ @working_subdir = cwd.relative_path_from(Pathname.new(repo.dir.path))
59
+ @working_subdir
60
+ end
61
+
62
+ def base_dir_path
63
+ Pathname.new(base_dir).realpath
64
+ end
65
+
66
+ def self.build_for(jeweler)
67
+ command = self.new
68
+
69
+ command.base_dir = jeweler.base_dir
70
+ command.gemspec = jeweler.gemspec
71
+ command.version = jeweler.version
72
+ command.repo = jeweler.repo
73
+ command.output = jeweler.output
74
+ command.gemspec_helper = jeweler.gemspec_helper
75
+
76
+ command
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,59 @@
1
+ class Jeweler
2
+ module Commands
3
+ class PreReleaseToGit
4
+ attr_accessor :gemspec, :version, :repo, :output, :gemspec_helper, :base_dir
5
+
6
+ def initialize(attributes = {})
7
+ self.output = $stdout
8
+
9
+ attributes.each_pair do |key, value|
10
+ send("#{key}=", value)
11
+ end
12
+ end
13
+
14
+ def run
15
+ unless clean_staging_area?
16
+ system "git status"
17
+ raise "Unclean staging area! Be sure to commit or .gitignore everything first. See `git status` above."
18
+ end
19
+
20
+ repo.checkout('develop')
21
+ repo.push
22
+
23
+ if release_not_tagged?
24
+ output.puts "Tagging #{release_tag}"
25
+ repo.add_tag(release_tag)
26
+
27
+ output.puts "Pushing #{release_tag} to origin"
28
+ repo.push('origin', release_tag)
29
+ end
30
+ end
31
+
32
+ def clean_staging_area?
33
+ `git ls-files --deleted --modified --others --exclude-standard` == ""
34
+ end
35
+
36
+ def release_tag
37
+ "v#{version}"
38
+ end
39
+
40
+ def release_not_tagged?
41
+ tag = repo.tag(release_tag) rescue nil
42
+ tag.nil?
43
+ end
44
+
45
+ def self.build_for(jeweler)
46
+ command = self.new
47
+
48
+ command.base_dir = jeweler.base_dir
49
+ command.gemspec = jeweler.gemspec
50
+ command.version = jeweler.version
51
+ command.repo = jeweler.repo
52
+ command.output = jeweler.output
53
+ command.gemspec_helper = jeweler.gemspec_helper
54
+
55
+ command
56
+ end
57
+ end
58
+ end
59
+ end
data/spec/sandbox.rb ADDED
@@ -0,0 +1,201 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ # The local repository we use for testing is void of any artifacts, which will break given
18
+ # that the code requires several artifacts. So we establish them first using the real local
19
+ # repository and cache these across test cases.
20
+ Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
21
+ repositories.remote << 'http://repo1.maven.org/maven2'
22
+ repositories.remote << 'http://scala-tools.org/repo-releases'
23
+
24
+ # Force Scala version for specs; don't want to rely on SCALA_HOME
25
+ #module Buildr::Scala
26
+ # SCALA_VERSION_FOR_SPECS = ENV["SCALA_VERSION"] || "2.8.1"
27
+ #end
28
+ #Buildr.settings.build['scala.version'] = Buildr::Scala::SCALA_VERSION_FOR_SPECS
29
+
30
+ # Add a 'require' here only for optional extensions, not for extensions that should be loaded by default.
31
+ #require 'buildr/clojure'
32
+ #require 'buildr/groovy'
33
+ #require 'buildr/scala'
34
+ #require 'buildr/bnd'
35
+ #require 'buildr/jaxb_xjc'
36
+
37
+ Java.load # Anything added to the classpath.
38
+ artifacts(
39
+ #TestFramework.frameworks.map(&:dependencies).flatten,
40
+ JUnit.ant_taskdef
41
+ #Buildr::Groovy.dependencies,
42
+ #Buildr::JaxbXjc.dependencies,
43
+ #Buildr::Bnd.dependencies,
44
+ #Buildr::Scala::Scalac.dependencies,
45
+ #Buildr::Scala::Specs.dependencies,
46
+ #Buildr::Shell::BeanShell.artifact,
47
+ #Buildr::Clojure.dependencies
48
+ ).each do |path|
49
+ file(path).invoke
50
+ end
51
+ #
52
+ ENV['HOME'] = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'home'))
53
+ mkpath ENV['HOME']
54
+
55
+ # Make Scala.version resilient to sandbox reset
56
+ #module Buildr::Scala
57
+ # DEFAULT_VERSION = SCALA_VERSION_FOR_SPECS
58
+ #
59
+ # class << self
60
+ # def version
61
+ # SCALA_VERSION_FOR_SPECS
62
+ # end
63
+ # end
64
+ #
65
+ # class Scalac
66
+ # class << self
67
+ # def use_installed?
68
+ # false
69
+ # end
70
+ # end
71
+ # end
72
+ #end
73
+
74
+ # We need to run all tests inside a _sandbox, tacking a snapshot of Buildr before the test,
75
+ # and restoring everything to its previous state after the test. Damn state changes.
76
+ module Sandbox
77
+
78
+ class << self
79
+ attr_reader :tasks, :rules
80
+
81
+ def included(spec)
82
+ spec.before(:each) { sandbox }
83
+ spec.after(:each) { reset }
84
+ end
85
+
86
+ # Require an optional extension without letting its callbacks pollute the Project class.
87
+ def require_optional_extension(extension_require_path)
88
+ project_callbacks_without_extension = Project.class_eval { @global_callbacks }.dup
89
+ begin
90
+ require extension_require_path
91
+ ensure
92
+ Project.class_eval { @global_callbacks = project_callbacks_without_extension }
93
+ end
94
+ end
95
+ end
96
+
97
+ @tasks = Buildr.application.tasks.collect do |original|
98
+ prerequisites = original.send(:prerequisites).map(&:to_s)
99
+ actions = original.instance_eval { @actions }.clone
100
+ lambda do
101
+ original.class.send(:define_task, original.name=>prerequisites).tap do |task|
102
+ task.comment = original.comment
103
+ actions.each { |action| task.enhance &action }
104
+ end
105
+ end
106
+ end
107
+ @rules = Buildr.application.instance_variable_get(:@rules)
108
+
109
+ def sandbox
110
+ @_sandbox = {}
111
+
112
+ # Create a temporary directory where we can create files, e.g,
113
+ # for projects, compilation. We need a place that does not depend
114
+ # on the current directory.
115
+ @_sandbox[:original_dir] = Dir.pwd
116
+ @temp = File.join(File.dirname(__FILE__), '../tmp')
117
+ FileUtils.mkpath @temp
118
+ Dir.chdir @temp
119
+
120
+ ARGV.clear
121
+ Buildr.application = Buildr::Application.new
122
+ Sandbox.tasks.each { |block| block.call }
123
+ Buildr.application.instance_variable_set :@rules, Sandbox.rules.clone
124
+ Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
125
+
126
+ @_sandbox[:load_path] = $LOAD_PATH.clone
127
+
128
+ # clear RUBYOPT since bundler hooks into it
129
+ # e.g. RUBYOPT=-I/usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib -rbundler/setup
130
+ # and so Buildr's own Gemfile configuration taints e.g., JRuby's environment
131
+ @_sandbox[:ruby_opt] = ENV["RUBYOPT"]
132
+ ENV["RUBYOPT"] = nil
133
+
134
+ #@_sandbox[:loaded_features] = $LOADED_FEATURES.clone
135
+
136
+ # Later on we'll want to lose all the on_define created during the test.
137
+ @_sandbox[:on_define] = Project.class_eval { (@on_define || []).dup }
138
+ @_sandbox[:extension_modules] = Project.class_eval { (@extension_modules || []).dup }
139
+ @_sandbox[:global_callbacks] = Project.class_eval { (@global_callbacks || []).dup }
140
+ @_sandbox[:layout] = Layout.default.clone
141
+
142
+ # Create a local repository we can play with. However, our local repository will be void
143
+ # of some essential artifacts (e.g. JUnit artifacts required by build task), so we create
144
+ # these first (see above) and keep them across test cases.
145
+ @_sandbox[:artifacts] = Artifact.class_eval { @artifacts }.clone
146
+ @_sandbox[:local_repository] = Buildr.repositories.local
147
+ ENV['HOME'] = File.expand_path('home')
148
+ ENV['BUILDR_ENV'] = 'development'
149
+
150
+ @_sandbox[:env_keys] = ENV.keys
151
+ ['DEBUG', 'TEST', 'HTTP_PROXY', 'HTTPS_PROXY', 'USER'].each { |k| ENV.delete(k) ; ENV.delete(k.downcase) }
152
+
153
+ # By default, remote repository is user's own local M2 repository
154
+ # since we don't want to remotely download artifacts into the sandbox over and over
155
+ Buildr.repositories.instance_eval do
156
+ @remote = ["file://" + @local]
157
+ @local = @release_to = nil
158
+ end
159
+ Buildr.options.proxy.http = nil
160
+
161
+ # Don't output crap to the console.
162
+ trace false
163
+ verbose false
164
+ end
165
+
166
+ # Call this from teardown.
167
+ def reset
168
+ # Get rid of all the projects and the on_define blocks we used.
169
+ Project.clear
170
+
171
+ on_define = @_sandbox[:on_define]
172
+ extension_modules = @_sandbox[:extension_modules]
173
+ global_callbacks = @_sandbox[:global_callbacks]
174
+
175
+ Project.class_eval do
176
+ @on_define = on_define
177
+ @global_callbacks = global_callbacks
178
+ @extension_modules = extension_modules
179
+ end
180
+
181
+ Layout.default = @_sandbox[:layout].clone
182
+
183
+ $LOAD_PATH.replace @_sandbox[:load_path]
184
+ ENV["RUBYOPT"] = @_sandbox[:ruby_opt]
185
+
186
+ FileUtils.rm_rf @temp
187
+ mkpath ENV['HOME']
188
+
189
+ # Get rid of all artifacts.
190
+ @_sandbox[:artifacts].tap { |artifacts| Artifact.class_eval { @artifacts = artifacts } }
191
+
192
+ Buildr.repositories.local = @_sandbox[:local_repository]
193
+
194
+ # Restore options.
195
+ Buildr.options.test = nil
196
+ (ENV.keys - @_sandbox[:env_keys]).each { |key| ENV.delete key }
197
+
198
+ Dir.chdir @_sandbox[:original_dir]
199
+ end
200
+
201
+ end
@@ -0,0 +1,376 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ # This file gets loaded twice when running 'spec spec/*' and not with pleasent results,
18
+ # so ignore the second attempt to load it.
19
+ unless defined?(SpecHelpers)
20
+
21
+ #require 'rubygems'
22
+
23
+ # For testing we use the gem requirements specified on the buildr.gemspec
24
+ #spec = Gem::Specification.load(File.expand_path('../buildr.gemspec', File.dirname(__FILE__)))
25
+ # Dependency.version_requirements deprecated in rubygems 1.3.6
26
+ #spec.dependencies.select {|dep| dep.type == :runtime }.each { |dep| gem dep.name, (dep.respond_to?(:requirement) ? dep.requirement.to_s : dep.version_requirements.to_s) }
27
+
28
+ # Make sure to load from these paths first, we don't want to load any
29
+ # code from Gem library.
30
+ #$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__)),
31
+ # File.expand_path('../addon', File.dirname(__FILE__))
32
+
33
+ require 'simplecov'
34
+ require 'simplecov-rcov'
35
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
36
+ SimpleCov.root( File.dirname( __FILE__) + '/..' )
37
+ SimpleCov.start
38
+
39
+ # Buildr uses autoload extensively, but autoload when running specs creates
40
+ # a problem -- we sandbox $LOADED_FEATURES, so we endup autoloading the same
41
+ # module twice. This turns autoload into a require, which is not the right
42
+ # thing, but will do for now.
43
+ def autoload(symbol, path)
44
+ require path
45
+ end
46
+ #require 'buildr'
47
+ require File.dirname( __FILE__) + '/../lib/buildr/as3'
48
+ # load ecj
49
+ #require 'buildr/java/ecj'
50
+ #Make ecj appear as a compiler that doesn't apply:
51
+ #class Buildr::Compiler::Ecj
52
+ # class << self
53
+ # def applies_to?(project, task)
54
+ # false
55
+ # end
56
+ # end
57
+ #end
58
+
59
+ # Give a chance for plugins to do a few things before requiring the sandbox.
60
+ include SandboxHook if defined?(SandboxHook)
61
+
62
+ require File.expand_path('sandbox', File.dirname(__FILE__))
63
+
64
+ module SpecHelpers
65
+
66
+ include Checks::Matchers
67
+
68
+ [:info, :warn, :error, :puts].each do |severity|
69
+ ::Object.class_eval do
70
+ define_method severity do |*args|
71
+ $messages ||= {}
72
+ $messages[severity] ||= []
73
+ $messages[severity].push(*args)
74
+ end
75
+ end
76
+ end
77
+
78
+ class << Buildr.application
79
+ alias :deprecated_without_capture :deprecated
80
+ def deprecated(message)
81
+ verbose(true) { deprecated_without_capture message }
82
+ end
83
+ end
84
+
85
+ class MessageWithSeverityMatcher
86
+ def initialize(severity, message)
87
+ @severity = severity
88
+ @expect = message
89
+ end
90
+
91
+ def matches?(target)
92
+ $messages = {@severity => []}
93
+ target.call
94
+ return Regexp === @expect ? $messages[@severity].join('\n') =~ @expect : $messages[@severity].include?(@expect.to_s)
95
+ end
96
+
97
+ def failure_message
98
+ "Expected #{@severity} #{@expect.inspect}, " +
99
+ ($messages[@severity].empty? ? "no #{@severity} issued" : "found #{$messages[@severity].inspect}")
100
+ end
101
+
102
+ def negative_failure_message
103
+ "Found unexpected #{$messages[@severity].inspect}"
104
+ end
105
+ end
106
+
107
+ # Test if an info message was shown. You can use a string or regular expression.
108
+ #
109
+ # For example:
110
+ # lambda { info 'ze test' }.should show_info(/ze test/)
111
+ def show_info(message)
112
+ MessageWithSeverityMatcher.new :info, message
113
+ end
114
+
115
+ # Test if a warning was shown. You can use a string or regular expression.
116
+ #
117
+ # For example:
118
+ # lambda { warn 'ze test' }.should show_warning(/ze test/)
119
+ def show_warning(message)
120
+ MessageWithSeverityMatcher.new :warn, message
121
+ end
122
+
123
+ # Test if an error message was shown. You can use a string or regular expression.
124
+ #
125
+ # For example:
126
+ # lambda { error 'ze test' }.should show_error(/ze test/)
127
+ def show_error(message)
128
+ MessageWithSeverityMatcher.new :error, message
129
+ end
130
+
131
+ # Test if any message was shown (puts). You can use a string or regular expression.
132
+ #
133
+ # For example:
134
+ # lambda { puts 'ze test' }.should show(/ze test/)
135
+ def show(message)
136
+ MessageWithSeverityMatcher.new :puts, message
137
+ end
138
+
139
+ # Yields a block that should try exiting the application.
140
+ # Accepts
141
+ #
142
+ # For example:
143
+ # test_exit(1) { puts "Hello" ; exit(1) }.should show("Hello")
144
+ #
145
+ def test_exit(status = nil)
146
+ return lambda {
147
+ begin
148
+ yield
149
+ raise "Exit was not called!"
150
+ rescue SystemExit => e
151
+ raise "Exit status incorrect! Expected: #{status}, got #{e.status}" if status && (e.status != status)
152
+ end
153
+ }
154
+ end
155
+
156
+ class ::Rake::Task
157
+ alias :execute_without_a_record :execute
158
+ def execute(args)
159
+ $executed ||= []
160
+ $executed << name
161
+ execute_without_a_record args
162
+ end
163
+ end
164
+
165
+ class InvokeMatcher
166
+ def initialize(*tasks)
167
+ @expecting = tasks.map { |task| [task].flatten.map(&:to_s) }
168
+ end
169
+
170
+ def matches?(target)
171
+ $executed = []
172
+ target.call
173
+ return false unless all_ran?
174
+ return !@but_not.any_ran? if @but_not
175
+ return true
176
+ end
177
+
178
+ def failure_message
179
+ return @but_not.negative_failure_message if all_ran? && @but_not
180
+ "Expected the tasks #{expected} to run, but #{remaining} did not run, or not in the order we expected them to." +
181
+ " Tasks that ran: #{$executed.inspect}"
182
+ end
183
+
184
+ def negative_failure_message
185
+ if all_ran?
186
+ "Expected the tasks #{expected} to not run, but they all ran."
187
+ else
188
+ "Expected the tasks #{expected} to not run, and all but #{remaining} ran."
189
+ end
190
+ end
191
+
192
+ def but_not(*tasks)
193
+ @but_not = InvokeMatcher.new(*tasks)
194
+ self
195
+ end
196
+
197
+ protected
198
+
199
+ def expected
200
+ @expecting.map { |tests| tests.join('=>') }.join(', ')
201
+ end
202
+
203
+ def remaining
204
+ @remaining.map { |tests| tests.join('=>') }.join(', ')
205
+ end
206
+
207
+ def all_ran?
208
+ @remaining ||= $executed.inject(@expecting) do |expecting, executed|
209
+ expecting.map { |tasks| tasks.first == executed ? tasks[1..-1] : tasks }.reject(&:empty?)
210
+ end
211
+ @remaining.empty?
212
+ end
213
+
214
+ def any_ran?
215
+ all_ran?
216
+ @remaining.size < @expecting.size
217
+ end
218
+
219
+ end
220
+
221
+ # Tests that all the tasks ran, in the order specified. Can also be used to test that some
222
+ # tasks and not others ran.
223
+ #
224
+ # Takes a list of arguments. Each argument can be a task name, matching only if that task ran.
225
+ # Each argument can be an array of task names, matching only if all these tasks ran in that order.
226
+ # So run_tasks('foo', 'bar') expects foo and bar to run in any order, but run_task(['foo', 'bar'])
227
+ # expects foo to run before bar.
228
+ #
229
+ # You can call but_not on the matchers to specify that certain tasks must not execute.
230
+ #
231
+ # For example:
232
+ # # Either task
233
+ # lambda { task('compile').invoke }.should run_tasks('compile', 'resources')
234
+ # # In that order
235
+ # lambda { task('build').invoke }.should run_tasks(['compile', 'test'])
236
+ # # With exclusion
237
+ # lambda { task('build').invoke }.should run_tasks('compile').but_not('install')
238
+ def run_tasks(*tasks)
239
+ InvokeMatcher.new *tasks
240
+ end
241
+
242
+ # Tests that a task ran. Similar to run_tasks, but accepts a single task name.
243
+ #
244
+ # For example:
245
+ # lambda { task('build').invoke }.should run_task('test')
246
+ def run_task(task)
247
+ InvokeMatcher.new [task]
248
+ end
249
+
250
+ class UriPathMatcher
251
+ def initialize(re)
252
+ @expression = re
253
+ end
254
+
255
+ def matches?(uri)
256
+ @uri = uri
257
+ uri.path =~ @expression
258
+ end
259
+
260
+ def description
261
+ "URI with path matching #{@expression}"
262
+ end
263
+ end
264
+
265
+ # Matches a parsed URI's path against the given regular expression
266
+ def uri(re)
267
+ UriPathMatcher.new(re)
268
+ end
269
+
270
+
271
+ class AbsolutePathMatcher
272
+ def initialize(path)
273
+ @expected = File.expand_path(path.to_s)
274
+ end
275
+
276
+ def matches?(path)
277
+ @provided = File.expand_path(path.to_s)
278
+ @provided == @expected
279
+ end
280
+
281
+ def failure_message
282
+ "Expected path #{@expected}, but found path #{@provided}"
283
+ end
284
+
285
+ def negative_failure_message
286
+ "Expected a path other than #{@expected}"
287
+ end
288
+ end
289
+
290
+ def point_to_path(path)
291
+ AbsolutePathMatcher.new(path)
292
+ end
293
+
294
+
295
+ # Value covered by range. For example:
296
+ # (1..5).should cover(3)
297
+ RSpec::Matchers.define :cover do |actual|
298
+ match do |range|
299
+ actual >= range.min && actual <= range.max
300
+ end
301
+ end
302
+
303
+
304
+ def suppress_stdout
305
+ stdout = $stdout
306
+ $stdout = StringIO.new
307
+ begin
308
+ yield
309
+ ensure
310
+ $stdout = stdout
311
+ end
312
+ end
313
+
314
+ def dryrun
315
+ Buildr.application.options.dryrun = true
316
+ begin
317
+ suppress_stdout { yield }
318
+ ensure
319
+ Buildr.application.options.dryrun = false
320
+ end
321
+ end
322
+
323
+ # We run tests with tracing off. Then things break. And we need to figure out what went wrong.
324
+ # So just use trace() as you would use verbose() to find and squash the bug.
325
+ def trace(value = nil)
326
+ old_value = Buildr.application.options.trace
327
+ Buildr.application.options.trace = value unless value.nil?
328
+ if block_given?
329
+ begin
330
+ yield
331
+ ensure
332
+ Buildr.application.options.trace = old_value
333
+ end
334
+ end
335
+ Buildr.application.options.trace
336
+ end
337
+
338
+ # Change the Buildr original directory, faking invocation from a different directory.
339
+ def in_original_dir(dir)
340
+ begin
341
+ original_dir = Buildr.application.original_dir
342
+ Buildr.application.instance_eval { @original_dir = File.expand_path(dir) }
343
+ yield
344
+ ensure
345
+ Buildr.application.instance_eval { @original_dir = original_dir }
346
+ end
347
+ end
348
+
349
+
350
+ # Buildr's define method creates a project definition but does not evaluate it
351
+ # (that happens once the buildfile is loaded), and we include Buildr's define in
352
+ # the test context so we can use it without prefixing with Buildr. This just patches
353
+ # define to evaluate the project definition before returning it.
354
+ def define(name, properties = nil, &block) #:yields:project
355
+ Project.define(name, properties, &block).tap { |project| project.invoke }
356
+ end
357
+
358
+ end
359
+
360
+
361
+ # Allow using matchers within the project definition.
362
+ class Buildr::Project
363
+ include ::RSpec::Matchers, SpecHelpers
364
+ end
365
+
366
+
367
+ ::RSpec.configure do |config|
368
+ # Make all Buildr methods accessible from test cases, and add various helper methods.
369
+ config.include Buildr
370
+ config.include SpecHelpers
371
+
372
+ # Sanbdox Buildr for each test.
373
+ config.include Sandbox
374
+ end
375
+
376
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buildr-hx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Dominic Graefen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-17 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: buildr
16
+ requirement: &2157040520 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.4.6
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2157040520
25
+ - !ruby/object:Gem::Dependency
26
+ name: shoulda
27
+ requirement: &2157038460 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2157038460
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &2157037060 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2157037060
47
+ - !ruby/object:Gem::Dependency
48
+ name: jeweler
49
+ requirement: &2157035920 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.5.2
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2157035920
58
+ - !ruby/object:Gem::Dependency
59
+ name: simplecov
60
+ requirement: &2157034560 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2157034560
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov-rcov
71
+ requirement: &2157032920 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2157032920
80
+ - !ruby/object:Gem::Dependency
81
+ name: rspec
82
+ requirement: &2157006400 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 2.1.0
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *2157006400
91
+ - !ruby/object:Gem::Dependency
92
+ name: ci_reporter
93
+ requirement: &2157005540 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 1.6.5
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *2157005540
102
+ - !ruby/object:Gem::Dependency
103
+ name: buildr
104
+ requirement: &2157004480 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.4.6
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: *2157004480
113
+ description: Build like you code - now supporting haXe
114
+ email: dominic @nospam@ devboy.org
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files:
118
+ - LICENSE.txt
119
+ - README.rdoc
120
+ files:
121
+ - .document
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE.txt
125
+ - README.rdoc
126
+ - Rakefile
127
+ - VERSION
128
+ - buildr-hx.iml
129
+ - lib/buildr-hx.rb
130
+ - rake/jeweler.rb
131
+ - rake/jeweler_prerelease_tasks.rb
132
+ - rake/pre_release_gemspec.rb
133
+ - rake/pre_release_to_git.rb
134
+ - spec/sandbox.rb
135
+ - spec/spec_helper.rb
136
+ homepage: http://github.com/devboy/buildr-hx
137
+ licenses:
138
+ - MIT
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ segments:
150
+ - 0
151
+ hash: -1517817821423449022
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>'
156
+ - !ruby/object:Gem::Version
157
+ version: 1.3.1
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 1.8.11
161
+ signing_key:
162
+ specification_version: 3
163
+ summary: Buildr extension to allow haXe development.
164
+ test_files:
165
+ - spec/sandbox.rb
166
+ - spec/spec_helper.rb