buildr-as3 0.2.19 → 0.2.20.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
@@ -0,0 +1,160 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
2
+
3
+ describe Buildr::AS3::Compiler::AirCompc do
4
+
5
+ it 'should not identify itself from source directories' do
6
+ write 'src/main/java/com/example/Test.as', 'package com.example{ class Test {} }'
7
+ define('foo').compile.compiler.should_not eql(:aircompc)
8
+ end
9
+
10
+ it 'should report the language as :actionscript' do
11
+ define('foo').compile.using(:aircompc).language.should eql(:actionscript)
12
+ end
13
+
14
+ it 'should set the target directory to target/bin' do
15
+ define 'foo' do
16
+ lambda { compile.using(:aircompc) }.should change { compile.target.to_s }.to(File.expand_path('target/bin'))
17
+ end
18
+ end
19
+
20
+ it 'should not override existing target directory' do
21
+ define 'foo' do
22
+ compile.into('classes')
23
+ lambda { compile.using(:aircompc) }.should_not change { compile.target }
24
+ end
25
+ end
26
+
27
+ it 'should not change existing list of sources' do
28
+ define 'foo' do
29
+ compile.from('sources')
30
+ lambda { compile.using(:aircompc) }.should_not change { compile.sources }
31
+ end
32
+ end
33
+
34
+ after do
35
+ Buildr.options.debug = nil
36
+ ENV.delete "debug"
37
+ ENV.delete "DEBUG"
38
+ end
39
+ end
40
+
41
+
42
+
43
+ describe "Buildr::AS3::Compiler::AirCompc compiler options" do
44
+
45
+ def compile_task
46
+ @compile_task ||= define('foo').compile.using( :aircompc, :flexsdk => FlexSDK.new("4.5.0.20967") )
47
+ end
48
+
49
+ def flex_sdk
50
+ compile_task.options.flexsdk
51
+ end
52
+
53
+ def output
54
+ compile_task.options.output
55
+ end
56
+
57
+ def target
58
+ compile_task.target
59
+ end
60
+
61
+ def dependencies
62
+ compile_task.as3_dependencies
63
+ end
64
+
65
+ def sources
66
+ compile_task.sources
67
+ end
68
+
69
+ def aircompc_args
70
+ compiler.send(:compiler_args,dependencies,flex_sdk,output,sources)
71
+ end
72
+
73
+ def compiler
74
+ compile_task.instance_eval { @compiler }
75
+ end
76
+
77
+ it 'should set warnings option to true by default' do
78
+ compile_task.options.warnings.should be_true
79
+ end
80
+
81
+ it 'should set debug option to true by default' do
82
+ compile_task.options.debug.should be_true
83
+ end
84
+
85
+ it 'should set debug option to false based on Buildr.options' do
86
+ Buildr.options.debug = false
87
+ compile_task.options.debug.should be_false
88
+ end
89
+
90
+ it 'should set debug option to false based on debug environment variable' do
91
+ ENV['debug'] = 'no'
92
+ compile_task.options.debug.should be_false
93
+ end
94
+
95
+ it 'should set debug option to false based on DEBUG environment variable' do
96
+ ENV['DEBUG'] = 'no'
97
+ compile_task.options.debug.should be_false
98
+ end
99
+
100
+ it 'should use -debug=true argument when debug option is true' do
101
+ compile_task.using(:debug=>true)
102
+ aircompc_args.should include('-debug=true')
103
+ end
104
+
105
+ it 'should not use -debug=true argument when debug option is false' do
106
+ compile_task.using(:debug=>false)
107
+ aircompc_args.should_not include('-debug=true')
108
+ end
109
+
110
+ it 'should define CONFIG::debug,true when debug option is true' do
111
+ compile_task.using(:debug=>true)
112
+ aircompc_args.should include('-define+=CONFIG::debug,true')
113
+ end
114
+
115
+ it 'should define CONFIG::debug,false when debug option is false' do
116
+ compile_task.using(:debug=>false)
117
+ aircompc_args.should include('-define+=CONFIG::debug,false')
118
+ end
119
+
120
+ it 'should use -warnings=true argument when warnings option is true' do
121
+ compile_task.using(:warnings=>true)
122
+ aircompc_args.should_not include('-warnings=false')
123
+ end
124
+
125
+ it 'should not use -warnings=true argument when warnings option is false' do
126
+ compile_task.using(:warnings=>false)
127
+ aircompc_args.should include('-warnings=false')
128
+ end
129
+
130
+ it 'should point to the correct compiler jar' do
131
+ compiler.instance_eval{ compiler_jar }.should eql( flex_sdk.compc_jar )
132
+ end
133
+
134
+ it 'should identify itself as an air compiler' do
135
+ compiler.instance_eval{ air }.should eql( true )
136
+ end
137
+
138
+ it "should use +configname=air ever" do
139
+ aircompc_args.should include('+configname=air')
140
+ end
141
+
142
+ it "should use air config file by default" do
143
+ aircompc_args.should include(flex_sdk.air_config)
144
+ end
145
+
146
+ it "should not use flex config file by default" do
147
+ aircompc_args.should_not include(flex_sdk.flex_config)
148
+ end
149
+
150
+ it "should not identify itself as a test task when it's not" do
151
+ compiler.send(:is_test,sources,target,dependencies).should eql(false)
152
+ end
153
+
154
+ after do
155
+ Buildr.options.debug = nil
156
+ ENV.delete "debug"
157
+ ENV.delete "DEBUG"
158
+ end
159
+
160
+ end
@@ -0,0 +1,158 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
2
+
3
+ describe Buildr::AS3::Compiler::AirMxmlc do
4
+
5
+ it 'should not identify itself from source directories' do
6
+ write 'src/main/java/com/example/Test.as', 'package com.example{ class Test {} }'
7
+ define('foo').compile.compiler.should_not eql(:airmxmlc)
8
+ end
9
+
10
+ it 'should report the language as :actionscript' do
11
+ define('foo').compile.using(:airmxmlc).language.should eql(:actionscript)
12
+ end
13
+
14
+ it 'should set the target directory to target/bin' do
15
+ define 'foo' do
16
+ lambda { compile.using(:airmxmlc) }.should change { compile.target.to_s }.to(File.expand_path('target/bin'))
17
+ end
18
+ end
19
+
20
+ it 'should not override existing target directory' do
21
+ define 'foo' do
22
+ compile.into('classes')
23
+ lambda { compile.using(:airmxmlc) }.should_not change { compile.target }
24
+ end
25
+ end
26
+
27
+ it 'should not change existing list of sources' do
28
+ define 'foo' do
29
+ compile.from('sources')
30
+ lambda { compile.using(:airmxmlc) }.should_not change { compile.sources }
31
+ end
32
+ end
33
+
34
+ after do
35
+ Buildr.options.debug = nil
36
+ ENV.delete "debug"
37
+ ENV.delete "DEBUG"
38
+ end
39
+ end
40
+
41
+ describe "Buildr::AS3::Compiler::AirMxmlc compiler options" do
42
+
43
+ def compile_task
44
+ @compile_task ||= define('foo').compile.using( :airmxmlc, :flexsdk => FlexSDK.new("4.5.0.20967") )
45
+ end
46
+
47
+ def flex_sdk
48
+ compile_task.options.flexsdk
49
+ end
50
+
51
+ def output
52
+ compile_task.options.output
53
+ end
54
+
55
+ def target
56
+ compile_task.target
57
+ end
58
+
59
+ def dependencies
60
+ compile_task.as3_dependencies
61
+ end
62
+
63
+ def sources
64
+ compile_task.sources
65
+ end
66
+
67
+ def airmxmlc_args
68
+ compiler.send(:compiler_args,dependencies,flex_sdk,output,sources)
69
+ end
70
+
71
+ def compiler
72
+ compile_task.instance_eval { @compiler }
73
+ end
74
+
75
+ it 'should set warnings option to true by default' do
76
+ compile_task.options.warnings.should be_true
77
+ end
78
+
79
+ it 'should set debug option to true by default' do
80
+ compile_task.options.debug.should be_true
81
+ end
82
+
83
+ it 'should set debug option to false based on Buildr.options' do
84
+ Buildr.options.debug = false
85
+ compile_task.options.debug.should be_false
86
+ end
87
+
88
+ it 'should set debug option to false based on debug environment variable' do
89
+ ENV['debug'] = 'no'
90
+ compile_task.options.debug.should be_false
91
+ end
92
+
93
+ it 'should set debug option to false based on DEBUG environment variable' do
94
+ ENV['DEBUG'] = 'no'
95
+ compile_task.options.debug.should be_false
96
+ end
97
+
98
+ it 'should use -debug=true argument when debug option is true' do
99
+ compile_task.using(:debug=>true)
100
+ airmxmlc_args.should include('-debug=true')
101
+ end
102
+
103
+ it 'should not use -debug=true argument when debug option is false' do
104
+ compile_task.using(:debug=>false)
105
+ airmxmlc_args.should_not include('-debug=true')
106
+ end
107
+
108
+ it 'should define CONFIG::debug,true when debug option is true' do
109
+ compile_task.using(:debug=>true)
110
+ airmxmlc_args.should include('-define+=CONFIG::debug,true')
111
+ end
112
+
113
+ it 'should define CONFIG::debug,false when debug option is false' do
114
+ compile_task.using(:debug=>false)
115
+ airmxmlc_args.should include('-define+=CONFIG::debug,false')
116
+ end
117
+
118
+ it 'should use -warnings=true argument when warnings option is true' do
119
+ compile_task.using(:warnings=>true)
120
+ airmxmlc_args.should_not include('-warnings=false')
121
+ end
122
+
123
+ it 'should not use -warnings=true argument when warnings option is false' do
124
+ compile_task.using(:warnings=>false)
125
+ airmxmlc_args.should include('-warnings=false')
126
+ end
127
+
128
+ it 'should point to the correct compiler jar' do
129
+ compiler.instance_eval{ compiler_jar }.should eql( flex_sdk.mxmlc_jar )
130
+ end
131
+
132
+ it 'should identify itself as an air compiler' do
133
+ compiler.instance_eval{ air }.should eql( true )
134
+ end
135
+
136
+ it "should use +configname=air ever" do
137
+ airmxmlc_args.should include('+configname=air')
138
+ end
139
+
140
+ it "should use air config file by default" do
141
+ airmxmlc_args.should include(flex_sdk.air_config)
142
+ end
143
+
144
+ it "should not use flex config file by default" do
145
+ airmxmlc_args.should_not include(flex_sdk.flex_config)
146
+ end
147
+
148
+ it "should not identify itself as a test task when it's not" do
149
+ compiler.send(:is_test,sources,target,dependencies).should eql(false)
150
+ end
151
+
152
+ after do
153
+ Buildr.options.debug = nil
154
+ ENV.delete "debug"
155
+ ENV.delete "DEBUG"
156
+ end
157
+
158
+ end