moneypools-sprouts-extensions 0.1.4

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.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ moneypools-sprouts-extensions.gemspec
data/README.markdown ADDED
@@ -0,0 +1,45 @@
1
+ sprouts-extensions
2
+ =============
3
+
4
+ Purpose
5
+ ========
6
+ Sprout-extensions is a set of little extensions monkey-patched into Sprout. It adds:
7
+
8
+ * the ability to use gems/tools on github
9
+
10
+ mxmlc "app.swf" do |t|
11
+ t.gem_name = 'jerryvos-sprout-flexsystemsdk-tool'
12
+ end
13
+
14
+ * the ability to easily alias your sprout task to a simpler, namespaced version
15
+
16
+ namespace :build do
17
+ desc "Compile the main swf"
18
+ mxmlc "app.swf" do |t|
19
+ t.task_alias = 'main' # the alias
20
+ end
21
+ end
22
+
23
+ # rake -T
24
+ rake app.swf # Compile the main swf
25
+ rake build:main # Compile the main swf
26
+
27
+ * smarter tracking of when a rebuild actually has to happen when your task isn't named the same as your output file
28
+ * For the following task, sprout/rake will always rebuild the file, even if it already exists and the dependencies are up-to-date. With sprout-extension this doesn't happen
29
+
30
+ mxmlc "my_task_name" do |t|
31
+ t.output = "my_app.swf"
32
+ end
33
+ 
34
+ Usage
35
+ ========
36
+ Install with gem install jerryvos-sprouts-extensions --source=http://gems.github.com
37
+
38
+ Update your Rakefile
39
+ require 'sprout'
40
+ #...
41
+
42
+ # Add this line
43
+ require 'sprouts-extensions'
44
+
45
+ # continue on
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "moneypools-sprouts-extensions"
8
+ gem.summary = %Q{Some extensions to sprout}
9
+ gem.email = "jerry.vos@gmail.com"
10
+ gem.homepage = "http://github.com/moneypools/sprout-extensions"
11
+ gem.authors = ["Richie Vos"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'rake/rdoctask'
20
+ Rake::RDocTask.new do |rdoc|
21
+ if File.exist?('VERSION.yml')
22
+ config = YAML.load(File.read('VERSION.yml'))
23
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
24
+ else
25
+ version = ""
26
+ end
27
+
28
+ rdoc.rdoc_dir = 'rdoc'
29
+ rdoc.title = "sprout-extensions #{version}"
30
+ rdoc.rdoc_files.include('README*')
31
+ rdoc.rdoc_files.include('lib/**/*.rb')
32
+ end
33
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.4
@@ -0,0 +1,66 @@
1
+ require 'sprout'
2
+ sprout 'as3'
3
+
4
+ # enable github as a source
5
+ Sprout::Sprout.gem_sources += ['http://gems.github.com']
6
+
7
+ Sprout::ToolTask.class_eval do
8
+ # namespace respecting alias for this task.
9
+ # ToolTask is a file_task which generally doesn't respect namespacing.
10
+ # Since we DO want to namespace these commands, we're going to create the non-namespaced version
11
+ # and then build a task which is namespaced that just invokes the real one.
12
+ # Feels shady, but less shady than other solutions.
13
+ def task_alias=(task_alias)
14
+ desc name
15
+ task task_alias => name
16
+ end
17
+ end
18
+
19
+ Sprout::ToolTask.class_eval do
20
+ def switch_param_type(name, type)
21
+ original_param = param_hash[name]
22
+ params.delete original_param
23
+
24
+ new_param = create_param(type)
25
+ new_param.init do |p|
26
+ p.belongs_to = self
27
+ p.name = name
28
+ p.type = type
29
+ yield p if block_given?
30
+ end
31
+
32
+ param_hash[name] = new_param
33
+ params << new_param
34
+ end
35
+ end
36
+
37
+ Sprout::MXMLCTask.class_eval do
38
+ def initialize_task_with_fixed_rsls(*args)
39
+ value = initialize_task_without_fixed_rsls(*args)
40
+ switch_param_type('runtime_shared_library_path', 'strings')
41
+ value
42
+ end
43
+
44
+ alias_method :initialize_task_without_fixed_rsls, :initialize_task
45
+ alias_method :initialize_task, :initialize_task_with_fixed_rsls
46
+ end
47
+
48
+
49
+ # make the task a little smarter about how it determines when it needs to rebuild. Normally it bases
50
+ # this on the name of the task, but since these sprout tasks explicitly have an output file, use that
51
+ # instead.
52
+ [Sprout::COMPCTask, Sprout::MXMLCTask].each do |task_class|
53
+ task_class.class_eval do
54
+ def self.needed?()
55
+ ! File.exist?(output) || out_of_date?(timestamp)
56
+ end
57
+
58
+ def timestamp
59
+ if File.exist?(output)
60
+ File.mtime(output.to_s)
61
+ else
62
+ Rake::EARLY
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,44 @@
1
+ require 'fileutils'
2
+
3
+ class RSLManager
4
+ include Singleton
5
+
6
+ attr_reader :source_dir, :output_dir
7
+
8
+ def load_params(params)
9
+ @source_dir, @output_dir = params.values_at(:source_dir, :output_dir)
10
+ @rsls, @trust_file_name = params.values_at(:rsls, :trust_file_name)
11
+ end
12
+
13
+ def copy_files
14
+ FileUtils.mkdir_p output_dir
15
+ @rsls.each do |rsl|
16
+ FileUtils.cp File.join(source_dir, 'frameworks/rsls', rsl), output_dir
17
+ end
18
+ end
19
+
20
+ def add_output_to_trust_dirs
21
+ File.open(File.join(trust_dir, @trust_file_name), 'w') do |file|
22
+ file.puts(File.expand_path(output_dir))
23
+ end
24
+ end
25
+
26
+ private
27
+ # based on http://www.adobe.com/devnet/flashplayer/articles/flash_player_admin_guide/flash_player_admin_guide.pdf
28
+ # around page 83
29
+ def trust_dir
30
+ if PLATFORM =~ /(mswin)|(mingw)/
31
+ # vista
32
+ # "C:\Users\username\AppData\Roaming\Macromedia\Flash Player\#Security\FlashPlayerTrust"
33
+
34
+ # windows 2000 & XP
35
+ File.join(ENV['HOME'], 'Application Data\Macromedia\Flash Player\#Security\FlashPlayerTrust')
36
+ elsif PLATFORM =~ /darwin/
37
+ File.join(ENV['HOME'], 'Library/Preferences/Macromedia/Flash Player/#Security/FlashPlayerTrust')
38
+ elsif PLATFORM =~ /linux/
39
+ File.join(ENV['HOME'], '.macromedia/#Security/FlashPlayerTrust')
40
+ else
41
+ raise "Unsupported platform #{PLATFORM}"
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,16 @@
1
+ require 'sprouts-extensions/rsl_manager'
2
+
3
+ namespace :rsl do
4
+ desc "Copies the specified framework rsls into the output directory"
5
+ task :copy do
6
+ RSLManager.instance.copy_files
7
+ end
8
+
9
+ desc "Sets up the output directory of the rsls to be a trusted dir for running in the flash stand-alone"
10
+ task :configure_trust do
11
+ RSLManager.instance.add_output_to_trust_dirs
12
+ end
13
+
14
+ desc "Sets up the rsls"
15
+ task :setup => ['copy', 'configure_trust']
16
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: moneypools-sprouts-extensions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Richie Vos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-23 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: jerry.vos@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.markdown
24
+ files:
25
+ - .document
26
+ - .gitignore
27
+ - README.markdown
28
+ - Rakefile
29
+ - VERSION
30
+ - lib/sprouts-extensions.rb
31
+ - lib/sprouts-extensions/rsl_manager.rb
32
+ - lib/sprouts-extensions/tasks.rb
33
+ has_rdoc: true
34
+ homepage: http://github.com/moneypools/sprout-extensions
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options:
39
+ - --charset=UTF-8
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project:
57
+ rubygems_version: 1.3.5
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: Some extensions to sprout
61
+ test_files: []
62
+