sproutpunk 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source :rubygems
2
2
 
3
- gem 'flashsdk'
3
+ gem 'flashsdk', :git => 'git://github.com/lukebayes/sprout-flashsdk.git'
4
4
  gem 'thor'
5
5
 
6
6
  # Add dependencies to develop your gem here.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/bin/sp CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'sproutpunk'
4
- require 'sproutpunk/runner'
4
+ require 'sproutpunk/cli'
5
5
 
6
- SproutPunk::Runner.start
6
+ SproutPunk::CLI.start
data/lib/sproutpunk.rb CHANGED
@@ -16,6 +16,8 @@ module SproutPunk
16
16
  end
17
17
 
18
18
 
19
+ require 'sproutpunk/config_file'
19
20
  require 'sproutpunk/config'
20
21
  require 'sproutpunk/helpers'
21
22
  require 'sproutpunk/assets'
23
+ require 'sproutpunk/builds'
@@ -0,0 +1,78 @@
1
+ require 'flashsdk'
2
+
3
+ module SproutPunk
4
+ module Builds
5
+ def self.config
6
+ _config = SproutPunk.config
7
+ config_path = File.join(_config.root_directory, _config.builds)
8
+ @_config ||= YAML.load_file(config_path)
9
+ end
10
+
11
+ class Build
12
+ def initialize(name)
13
+ super
14
+ @name = name
15
+ @config = Builds.config
16
+ Dir.chdir(SproutPunk.config.root_directory)
17
+ end
18
+
19
+ def execute
20
+ build_data = @config["packages"][@name]
21
+
22
+ pack_exe = package_executable(@name)
23
+ swf_exe = swf_executable(build_data["swf"])
24
+ cert_exe = cert_executable(build_data["cert"])
25
+
26
+ swf_exe.execute
27
+ cert_exe.execute
28
+ pack_exe.execute
29
+ end
30
+
31
+ def package_executable(name)
32
+ exe = FlashSDK::ADT.new
33
+
34
+ package = @config["packages"][@name].dup
35
+ cert = @config["certs"][package.delete("cert")]
36
+ swf = package.delete "swf"
37
+
38
+ package.each do |k, v|
39
+ exe.send("#{k}=", v)
40
+ end
41
+
42
+ exe.keystore = cert["file"]
43
+ exe.storepass = File.read(cert["password"]).to_s.strip
44
+ exe.included_files << "bin/#{swf}.swf"
45
+
46
+ exe
47
+ end
48
+
49
+ def swf_executable(name)
50
+ exe = FlashSDK::MXMLC.new
51
+
52
+ swf = @config["swfs"][name].dup
53
+
54
+ swf.each do |k, v|
55
+ exe.send("#{k}=", v)
56
+ end
57
+
58
+ exe.output = "bin/#{name}.swf"
59
+
60
+ exe
61
+ end
62
+
63
+ def cert_executable(name)
64
+ exe = FlashSDK::ADT.new
65
+
66
+ cert = @config["certs"][name].dup
67
+
68
+ exe.certificate = true
69
+ exe.cn = 'SelfCertificate'
70
+ exe.key_type = '2048-RSA'
71
+ exe.pfx_file = cert["file"]
72
+ exe.password = File.read(cert["password"]).to_s.strip
73
+
74
+ exe
75
+ end
76
+ end
77
+ end
78
+ end
@@ -4,10 +4,10 @@ require 'thor/group'
4
4
  require 'sproutpunk/commands/base'
5
5
 
6
6
  module SproutPunk
7
- class Runner < Commands::Base
7
+ class CLI < Commands::Base
8
8
  default_task :help
9
9
 
10
- desc "start [ENV, ...]", "start the specified environment"
10
+ desc "start [env, ...]", "start the specified environment"
11
11
  def start(*envs)
12
12
  envs.each do |name|
13
13
  src = _config.builds.send(name)
@@ -26,6 +26,10 @@ module SproutPunk
26
26
  end
27
27
  exit
28
28
  end
29
+
30
+ desc "setup [path]", "setup the SproutPunk gem (using an optional sproutpunk.yml file)"
31
+ def setup
32
+ end
29
33
  end
30
34
 
31
35
  end
@@ -0,0 +1,21 @@
1
+ module SproutPunk
2
+ module Commands
3
+ class Assets < Base
4
+ command_set "assets", "assets [task]", "execute various asset relatd commands"
5
+
6
+ default_task :help
7
+
8
+ desc "assets manifest", "crawl asset directory structure and generate a YAML manifest of each file"
9
+ def manifest
10
+ end
11
+
12
+ desc "assets update", "update asset manifest with new files in asset director"
13
+ def update
14
+ end
15
+
16
+ desc "assets import", "use manifest file (or create a new one) to build an Assets.as file"
17
+ def import
18
+ end
19
+ end
20
+ end
21
+ end
@@ -14,7 +14,7 @@ module SproutPunk
14
14
  end
15
15
 
16
16
  def self.command_set(name, usage, desc)
17
- SproutPunk::Runner.register(self, name, usage, desc)
17
+ SproutPunk::CLI.register(self, name, usage, desc)
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,42 @@
1
+ module SproutPunk
2
+ module Commands
3
+ class Builds < Base
4
+ command_set "builds", "builds [task]", "execute various build related commands"
5
+
6
+ default_task :help
7
+
8
+ desc "builds list", "show the current list of builds"
9
+ def list
10
+ if !_config.builds || !_config.builds.directory || !_config.builds.manifest
11
+ say "I don't know where to find your Actionscript files or the build manifest."
12
+ say "Please run `fp setup`."
13
+ exit
14
+ end
15
+
16
+ print_table _config.builds.to_hash, :ident => 2
17
+ end
18
+
19
+ desc "builds add [name] [source]", "add a new build"
20
+ def add(name, source)
21
+ _manifest.send("#{name}=", source)
22
+ end
23
+
24
+
25
+ desc "builds remove [name]", "remove a build"
26
+ def remove
27
+ _manifest.delete(name)
28
+ end
29
+
30
+ desc "builds compile [target]", "compile all of the build targets to SWF files / AIR applications"
31
+ def compile(target)
32
+ build = SproutPunk::Builds::Build.new(target)
33
+ build.execute
34
+ end
35
+
36
+ private
37
+ def _manifest
38
+ @_manifest ||= ConfigFile.load(_config.builds.manifest)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,40 +1,15 @@
1
1
  require 'yaml'
2
+ require 'sproutpunk/config_file'
2
3
 
3
4
  module SproutPunk
4
- class Config
5
+ class Config < ConfigFile
5
6
 
6
7
  def self.default_path
7
8
  File.expand_path(File.join('config', 'sproutpunk.yml'))
8
9
  end
9
10
 
10
- def self.load(path = self.default_path)
11
- new.load(path)
12
- end
13
-
14
- def load(path = Config.default_path)
15
- @options = YAML.load_file(path) || {}
16
- self.config_path = path
17
- self
18
- end
19
-
20
- def initialize(hash = {})
21
- @options = hash
22
- end
23
-
24
- def to_hash
25
- @options.dup
26
- end
27
-
28
- def method_missing(meth, *args)
29
- name = meth.to_s
30
- if name =~ /(.*)\=$/
31
- @options[$1] = args.first
32
- elsif @options.has_key?(name)
33
- val = @options[name]
34
- val.is_a?(Hash) ? @options[name] = self.class.new(val) : val
35
- else
36
- super
37
- end
11
+ def inspect
12
+ "#<SproutPunk::Config #{@table.inspect}>"
38
13
  end
39
14
  end
40
15
  end
@@ -0,0 +1,76 @@
1
+ require 'yaml'
2
+
3
+ module SproutPunk
4
+ class ConfigFile
5
+
6
+ def self.default_path
7
+ nil
8
+ end
9
+
10
+ def default_path
11
+ self.class.default_path
12
+ end
13
+
14
+ def self.load(path = self.default_path)
15
+ new.load(path)
16
+ end
17
+
18
+ def initialize(hash = {})
19
+ @table = hash
20
+ end
21
+
22
+ def load(path = self.default_path)
23
+ check_path(path)
24
+ @table = YAML.load_file(path) || {}
25
+ self.config_path = path
26
+ self
27
+ end
28
+
29
+ def write(path = self.default_path)
30
+ check_path(path)
31
+ File.open(path, 'w') {|f| f << YAML.dump(@table) }
32
+ path
33
+ end
34
+
35
+ def to_hash
36
+ @table.dup
37
+ end
38
+
39
+ def root_dir
40
+ File.expand_path(@table['root_dir'] || '')
41
+ end
42
+
43
+ def inspect
44
+ "#<SproutPunk::ConfigFile #{@table.inspect}>"
45
+ end
46
+
47
+ def config_dir
48
+ File.dirname(set?(:config_path) ? config_path : self.class.default_path)
49
+ end
50
+
51
+ def set?(key)
52
+ @table.has_key?(key.to_s)
53
+ end
54
+
55
+ def method_missing(meth, *args)
56
+ name = meth.to_s
57
+ if name =~ /(.*)\=$/
58
+ @table[$1] = args.first
59
+ elsif @table.has_key?(name)
60
+ val = @table[name]
61
+ val.is_a?(Hash) ? @table[name] = self.class.new(val) : val
62
+ else
63
+ super
64
+ end
65
+ end
66
+
67
+ private
68
+ def check_path(path)
69
+ if !File.readable?(path)
70
+ FileUtils.mkdir_p(File.dirname(path))
71
+ FileUtils.touch(path)
72
+ end
73
+ end
74
+
75
+ end
76
+ end
File without changes
data/sproutpunk.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "sproutpunk"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Hansen"]
12
- s.date = "2012-01-24"
12
+ s.date = "2012-02-02"
13
13
  s.description = "A gem with some common tasks and code generation tools for users of FlashPunk."
14
14
  s.email = "michael@subtlefish.com"
15
15
  s.executables = ["sp"]
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
18
18
  "README.rdoc"
19
19
  ]
20
20
  s.files = [
21
- ".DS_Store",
22
21
  "Gemfile",
23
22
  "LICENSE.txt",
24
23
  "README.rdoc",
@@ -27,19 +26,28 @@ Gem::Specification.new do |s|
27
26
  "bin/sp",
28
27
  "lib/sproutpunk.rb",
29
28
  "lib/sproutpunk/assets.rb",
29
+ "lib/sproutpunk/builds.rb",
30
+ "lib/sproutpunk/cli.rb",
30
31
  "lib/sproutpunk/commands/assets.rb",
31
32
  "lib/sproutpunk/commands/base.rb",
32
- "lib/sproutpunk/commands/build.rb",
33
+ "lib/sproutpunk/commands/builds.rb",
33
34
  "lib/sproutpunk/commands/config.rb",
34
35
  "lib/sproutpunk/config.rb",
36
+ "lib/sproutpunk/config_file.rb",
35
37
  "lib/sproutpunk/helpers.rb",
36
- "lib/sproutpunk/runner.rb",
37
38
  "lib/sproutpunk/templates/FlashpunkAssetsClass.as",
39
+ "lib/sproutpunk/templates/descriptor.xml",
38
40
  "lib/sproutpunk/templates/sproutpunk.yml",
39
41
  "sproutpunk.gemspec",
42
+ "test/assets.yml",
43
+ "test/builds.yml",
44
+ "test/cert/.password",
45
+ "test/cert/test-cert.pfx",
40
46
  "test/helper.rb",
41
47
  "test/sp",
42
48
  "test/sproutpunk.yml",
49
+ "test/src/test-app.xml",
50
+ "test/src/test.as",
43
51
  "test/test_sproutpunk.rb"
44
52
  ]
45
53
  s.homepage = "http://github.com/modality/sproutpunk"
data/test/assets.yml ADDED
File without changes
data/test/builds.yml ADDED
@@ -0,0 +1,34 @@
1
+ certs:
2
+ test:
3
+ file: cert/test-cert.pfx
4
+ password: cert/.password
5
+
6
+ common: &common
7
+ package: true
8
+ package_input: src/test-app.xml
9
+ storetype: PKCS12
10
+
11
+ swfs:
12
+ test:
13
+ input: src/test.as
14
+ static_link_runtime_shared_libraries: true
15
+
16
+
17
+ packages:
18
+ air-test:
19
+ <<: *common
20
+ swf: test
21
+ cert: test
22
+ package_output: bin/test
23
+ mac-test:
24
+ <<: *common
25
+ swf: test
26
+ cert: test
27
+ target: bundle
28
+ package_output: bin/test.app
29
+ win-test:
30
+ <<: *common
31
+ swf: test
32
+ cert: test
33
+ target: bundle
34
+ package_output: bin/test
@@ -0,0 +1 @@
1
+ password
Binary file
data/test/sp CHANGED
@@ -3,7 +3,7 @@
3
3
  $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
4
4
 
5
5
  require 'sproutpunk'
6
- require 'sproutpunk/runner'
6
+ require 'sproutpunk/cli'
7
7
 
8
8
  SproutPunk.config_path = File.expand_path(File.join('test', 'sproutpunk.yml'))
9
- SproutPunk::Runner.start
9
+ SproutPunk::CLI.start
data/test/sproutpunk.yml CHANGED
@@ -1,3 +1,3 @@
1
- builds:
2
- robo-debug: 'src/Main.as'
3
-
1
+ root_directory: test
2
+ builds: builds.yml
3
+ assets: assets.yml
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="utf-8" standalone="no"?>
2
+ <application xmlns="http://ns.adobe.com/air/application/3.1">
3
+ <id>test</id>
4
+ <filename>test</filename>
5
+ <name>test</name>
6
+ <versionNumber>0.0.0</versionNumber>
7
+ <initialWindow>
8
+ <content>bin/test.swf</content>
9
+ <autoOrients>false</autoOrients>
10
+ <fullScreen>false</fullScreen>
11
+ <visible>true</visible>
12
+ </initialWindow>
13
+ </application>
data/test/src/test.as ADDED
@@ -0,0 +1,12 @@
1
+ package
2
+ {
3
+ import flash.display.Sprite;
4
+
5
+ public class test extends Sprite
6
+ {
7
+ public function test()
8
+ {
9
+
10
+ }
11
+ }
12
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sproutpunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-24 00:00:00.000000000 Z
12
+ date: 2012-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: flashsdk
16
- requirement: &2160405640 !ruby/object:Gem::Requirement
16
+ requirement: &70265939083540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2160405640
24
+ version_requirements: *70265939083540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &2160404580 !ruby/object:Gem::Requirement
27
+ requirement: &70265939082800 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2160404580
35
+ version_requirements: *70265939082800
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shoulda
38
- requirement: &2160414320 !ruby/object:Gem::Requirement
38
+ requirement: &70265939098660 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2160414320
46
+ version_requirements: *70265939098660
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &2160423400 !ruby/object:Gem::Requirement
49
+ requirement: &70265939098040 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2160423400
57
+ version_requirements: *70265939098040
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &2160436740 !ruby/object:Gem::Requirement
60
+ requirement: &70265939097560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 1.7.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2160436740
68
+ version_requirements: *70265939097560
69
69
  description: A gem with some common tasks and code generation tools for users of FlashPunk.
70
70
  email: michael@subtlefish.com
71
71
  executables:
@@ -75,7 +75,6 @@ extra_rdoc_files:
75
75
  - LICENSE.txt
76
76
  - README.rdoc
77
77
  files:
78
- - .DS_Store
79
78
  - Gemfile
80
79
  - LICENSE.txt
81
80
  - README.rdoc
@@ -84,19 +83,28 @@ files:
84
83
  - bin/sp
85
84
  - lib/sproutpunk.rb
86
85
  - lib/sproutpunk/assets.rb
86
+ - lib/sproutpunk/builds.rb
87
+ - lib/sproutpunk/cli.rb
87
88
  - lib/sproutpunk/commands/assets.rb
88
89
  - lib/sproutpunk/commands/base.rb
89
- - lib/sproutpunk/commands/build.rb
90
+ - lib/sproutpunk/commands/builds.rb
90
91
  - lib/sproutpunk/commands/config.rb
91
92
  - lib/sproutpunk/config.rb
93
+ - lib/sproutpunk/config_file.rb
92
94
  - lib/sproutpunk/helpers.rb
93
- - lib/sproutpunk/runner.rb
94
95
  - lib/sproutpunk/templates/FlashpunkAssetsClass.as
96
+ - lib/sproutpunk/templates/descriptor.xml
95
97
  - lib/sproutpunk/templates/sproutpunk.yml
96
98
  - sproutpunk.gemspec
99
+ - test/assets.yml
100
+ - test/builds.yml
101
+ - test/cert/.password
102
+ - test/cert/test-cert.pfx
97
103
  - test/helper.rb
98
104
  - test/sp
99
105
  - test/sproutpunk.yml
106
+ - test/src/test-app.xml
107
+ - test/src/test.as
100
108
  - test/test_sproutpunk.rb
101
109
  homepage: http://github.com/modality/sproutpunk
102
110
  licenses:
@@ -113,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
121
  version: '0'
114
122
  segments:
115
123
  - 0
116
- hash: -2648259444543067997
124
+ hash: 314793355662728202
117
125
  required_rubygems_version: !ruby/object:Gem::Requirement
118
126
  none: false
119
127
  requirements:
data/.DS_Store DELETED
Binary file
@@ -1,19 +0,0 @@
1
- module SproutPunk
2
- module Commands
3
- class Build < Base
4
- command_set "build", "build [TASK]", "execute various commands related to builds"
5
-
6
- default_task :help
7
-
8
- desc "build list", "show the current list of builds"
9
- def list
10
- unless _config.builds
11
- say "No builds listed in configuration"
12
- exit
13
- end
14
-
15
- print_table _config.builds.to_hash, :ident => 2
16
- end
17
- end
18
- end
19
- end