flex-sdk 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.6.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{flex-sdk}
8
- s.version = "0.5.1"
8
+ s.version = "0.6.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jonathan Hoskin", "Rasheed Abdul-Aziz"]
12
- s.date = %q{2010-11-09}
12
+ s.date = %q{2010-11-11}
13
13
  s.description = %q{Flex SDK Gem for redistribution to build servers and other developers. Also provides a simple DSL for calling Mxmlc and Compc from Thor tasks}
14
14
  s.email = %q{jonathan.hoskin@visfleet.com}
15
15
  s.executables = ["flex-sdk-copylocale", "flex-sdk-path", "flex-sdk-prime"]
@@ -31,11 +31,14 @@ module FlexCompiler
31
31
 
32
32
  def compc(opts="")
33
33
  command = "#{Shell.escape File.join(sdk_dir,"bin","compc")} #{opts.to_s}"
34
+ puts command
34
35
  `#{command}`
35
36
  end
36
37
 
37
- def mxmlc
38
- puts ("mxmlc")
38
+ def mxmlc(target,opts="")
39
+ command = "#{Shell.escape File.join(sdk_dir,"bin","mxmlc")} #{opts.to_s} -- #{target}"
40
+ puts command
41
+ `#{command}`
39
42
  end
40
43
 
41
44
  def sdk_dir
@@ -3,13 +3,39 @@ require 'shell'
3
3
 
4
4
  class OptBuilder
5
5
 
6
- @@single_opts = []
7
- @@collection_opts = []
8
-
6
+ class_attribute :single_opts
7
+ class_attribute :collection_opts
8
+ self.single_opts = []
9
+ self.collection_opts = []
10
+
11
+ def self.inherited(sub)
12
+ sub.single_opts = []
13
+ sub.collection_opts = []
14
+ end
15
+
16
+ def self.map_with_single_opts(&block)
17
+ result = self.single_opts.map do |config|
18
+ yield config
19
+ end
20
+
21
+ result += self.superclass.map_with_single_opts(&block) if (self.superclass.respond_to? :map_with_single_opts)
22
+ result
23
+ end
24
+
25
+ def self.map_with_collection_opts(&block)
26
+ result = self.collection_opts.map do |config|
27
+ yield config
28
+ end
29
+
30
+ result += self.superclass.map_with_collection_opts(&block) if (self.superclass.respond_to? :map_with_single_opts)
31
+ result
32
+ end
33
+
34
+
9
35
  def self.single(sym,opts={})
10
36
  attr_writer sym
11
-
12
- @@single_opts << {
37
+
38
+ self.single_opts << {
13
39
  :sym => sym,
14
40
  :alias_for => opts[:alias_for] || sym.to_s.dasherize
15
41
  }
@@ -18,14 +44,13 @@ class OptBuilder
18
44
  define_method sym do
19
45
  self.send(:instance_variable_get,"@#{sym.to_s}") || opts[:default]
20
46
  end
21
-
22
47
  end
23
48
  end
24
49
 
25
50
  def self.collection(sym,opts={})
26
51
  attr_writer sym
27
52
 
28
- @@collection_opts << {
53
+ self.collection_opts << {
29
54
  :sym => sym,
30
55
  :force_restart => opts[:force_restart],
31
56
  :alias_for => opts[:alias_for] || sym.to_s.dasherize
@@ -42,17 +67,8 @@ class OptBuilder
42
67
  end
43
68
 
44
69
  def value_as_option_value(value)
45
- # todo:
46
- # Escape strings for command line
47
- # leave numbers alone
48
- # booleans?
49
- #
50
- # arrays, treat each element as a value then join with spaces
51
-
52
-
53
- return value_array_as_option_value(value) if value.is_a? Array
54
-
55
- Shell.escape value
70
+ return value_array_as_option_value(value) if value.is_a? Array
71
+ Shell.escape value
56
72
  end
57
73
 
58
74
  def value_array_as_option_value(value_array)
@@ -64,23 +80,23 @@ class OptBuilder
64
80
  end
65
81
 
66
82
  def to_s
67
- opts = @@single_opts.map do |hash|
68
- sym = hash[:sym]
69
- "-#{hash[:alias_for]}=#{value_as_option_value(send(sym))}" unless send(sym).nil?
83
+ opts = self.class.map_with_single_opts do |config|
84
+ sym = config[:sym]
85
+ "-#{config[:alias_for]}=#{value_as_option_value(send(sym))}" unless send(sym).nil?
70
86
  end
71
87
 
72
- collections = @@collection_opts.each do |hash|
88
+ opts += self.class.map_with_collection_opts do |hash|
73
89
  sym = hash[:sym];
74
90
  restart = hash[:force_restart]
75
91
  add_char = ""
76
- opts += send(sym).map do |value|
92
+ send(sym).map do |value|
77
93
  add_char = "+" unless restart
78
94
  restart = false if restart
79
- "-#{hash[:alias_for]}#{add_char}=#{value_as_option_value(value)}"
95
+ "-#{hash[:alias_for]}#{add_char}=#{value_as_option_value(value)}" unless send(sym).nil?
80
96
  end
81
97
  end
82
98
 
83
- opts.reject{ |item| item.nil? }.join " "
99
+ opts.flatten.reject{ |item| item.nil? }.join " "
84
100
  end
85
101
 
86
102
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flex-sdk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 1
10
- version: 0.5.1
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonathan Hoskin
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-09 00:00:00 +13:00
19
+ date: 2010-11-11 00:00:00 +13:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency