sp 0.0.1

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/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+ gem "OptionParser"
3
+
4
+ group :development do
5
+ gem "bundler"
6
+ gem "jeweler"
7
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ OptionParser (0.5.1)
5
+ git (1.2.5)
6
+ jeweler (1.8.3)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rdoc
11
+ json (1.6.5)
12
+ rake (0.9.2.2)
13
+ rdoc (3.12)
14
+ json (~> 1.4)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ OptionParser
21
+ bundler
22
+ jeweler
data/README ADDED
@@ -0,0 +1,8 @@
1
+ To install run these commands:
2
+ sudo gem install bundle
3
+ bundle install
4
+ rake build
5
+ sudo rake install
6
+
7
+ You can then run
8
+ spaceport bundle -c [path to .config file] -o [ path where you would like your bundle ] -m [ path to root of your server ]
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+
2
+ require 'rubygems'
3
+ require 'bundler'
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
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "sp"
16
+ gem.homepage = "http://github.com/sibblingz/spaceport-publisher"
17
+ gem.license = "ALL OF THEM"
18
+ gem.summary = %Q{Bundling tool for spaceport}
19
+ gem.description = %Q{Seriously, this thing is great}
20
+ gem.email = "daniel@sibblingz.com"
21
+ gem.authors = ["djacobs7"]
22
+ gem.version = "0.0.1"
23
+
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
data/bin/spaceport ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib_path = File.join( File.dirname(__FILE__), "../lib" )
4
+
5
+ require( File.join( lib_path, "lib.rb") )
6
+ Dir.glob( File.join( lib_path, "**/*.rb" ) ).each do | file |
7
+ require(file)
8
+ end
9
+
10
+ if (!ARGV[0])
11
+ puts 'ERROR: You need to enter in a valid command'
12
+ exit
13
+ end
14
+ command = ARGV[0].intern
15
+
16
+ puts spaceport_options
17
+ send( command )
data/lib/bundle.config ADDED
@@ -0,0 +1,19 @@
1
+ # The HTML file
2
+ daisy.html svn
3
+
4
+ # All the music
5
+ mp3s/**/*.mp3 svn
6
+ wavs/**/*.wav svn
7
+
8
+ # All the javascript files in the client directory (no Spaceport.swf needed for iPhone / Android)
9
+ client/**/*.js svn
10
+
11
+ # Use "-" to specify things that you want to EXCLUDE from bundling
12
+ -client/**/*.swf
13
+
14
+ # This un-necessary and obvious duplicate is here to test / prove that you don't have
15
+ # to worry about duplicates in your full_file_list or manifest.xml file
16
+ client/spaceport.js svn
17
+
18
+ # And last but not least all the SGF files
19
+ swfs/**/*.sgf svn
data/lib/bundle.rb ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+
5
+ def bundle
6
+ # bundlePath = ARGV[0]
7
+ # output_dir = ARGV[1]
8
+ options = {}
9
+ opts = OptionParser.new do |opts|
10
+ opts.banner ="Usage: "
11
+ opts.on( "-c", "--config CONFIG", "Path to your config file" ) do |path|
12
+ options[:bundle_config_path] = path
13
+ end
14
+
15
+ opts.on("-o", "--output BUNDLE_DIR", "Directory you would like bundle to go to") do |path|
16
+ options[:bundle_dir] = path
17
+ end
18
+
19
+ opts.on("-m", "--manifest MANIFEST_DIR", "Directory you would like the manifest to go to") do |path|
20
+ options[:manifest_output_dir] = path
21
+ end
22
+
23
+ opts.on("--no-manifest" "Do not generate a manifest or fuller_asset_list") do |value|
24
+ options[:no_manifest] = true
25
+ end
26
+ end
27
+
28
+ opts.parse!
29
+
30
+ bundle_config_path = options[:bundle_config_path] || spaceport_options[:bundle_config_path]
31
+ bundle_dir = options[:bundle_dir] || spaceport_options[:bundle_dir]
32
+ manifest_output_dir = options[:manifest_output_dir] || spaceport_options[:manifest_output_dir]
33
+
34
+ if ( !bundle_dir || !manifest_output_dir || !bundle_config_path)
35
+ bundle_config_path = ARGV[0]
36
+ manifest_output_dir = ARGV[1]
37
+ bundle_dir = ARGV[2]
38
+ puts "You are using this in the deprecated way! Please do not"
39
+ exit
40
+ end
41
+
42
+
43
+ current_dir = File.expand_path(File.dirname(__FILE__))
44
+ built_client_dir = File.join(bundle_dir, "built_client", "assets")
45
+ manifest_generating_script_path = File.join(current_dir, "generate_manifest.rb")
46
+ full_asset_list_path = File.join(manifest_output_dir, "full_asset_list.txt")
47
+ manifest_path = File.join(manifest_output_dir, "manifest.xml")
48
+
49
+ if ( !options[:no_manifest] )
50
+ puts `spaceport generate_manifest --config #{bundle_config_path} --output #{manifest_output_dir}`
51
+ end
52
+ `rm -rf #{built_client_dir}`
53
+ `mkdir -p #{built_client_dir}`
54
+
55
+ `rsync -rvmL --exclude='#{built_client_dir}/*' --include-from=#{full_asset_list_path} --include='*/' --exclude='*' #{manifest_output_dir}/ #{built_client_dir}`
56
+ `cp #{manifest_path} #{built_client_dir}`
57
+
58
+ # TODO:
59
+ # Zip stuff up for Android
60
+
61
+ #( cd built_client && zip -r built_client.zip *.js content *.html manifest.xml )
62
+ #cp built_client/built_client.zip $DESTINATION
63
+ #echo "copying built_client.zip to $DESTINATION"
64
+ end
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+
4
+ if `which md5`==""
5
+ MD5_COMMMAND = "md5sum"
6
+ else
7
+ MD5_COMMMAND = "md5"
8
+ end
9
+
10
+ def generate_manifest
11
+
12
+ # bundlePath = ARGV[0]
13
+ # output_dir = ARGV[1]
14
+ options = {}
15
+ opts = OptionParser.new do |opts|
16
+ opts.banner ="Usage: This will create two output files; a manifest.xml, and a full_asset_list.txt"
17
+ opts.on( "-c", "--config CONFIG", "Path to your config file" ) do |path|
18
+ options[:bundle_config_path] = path
19
+ end
20
+
21
+ opts.on("-o", "--output OUTPUT", "Directory you would like the two output files to go to") do |path|
22
+ options[:manifest_output_dir] = path
23
+ end
24
+
25
+ end
26
+
27
+ opts.parse!
28
+
29
+ bundlePath = options[:bundle_config_path] || spaceport_options[:bundle_config_path]
30
+ output_dir = options[:manifest_output_dir] || spaceport_options[:manifest_output_dir]
31
+
32
+ app_root_dir = output_dir
33
+
34
+ if ( !bundlePath || !output_dir )
35
+ puts opts
36
+ exit
37
+ end
38
+
39
+ wants = []
40
+ doNotWants = []
41
+ completeFileList = {}
42
+
43
+ File.open(bundlePath, "r") do |f|
44
+ while !f.eof?
45
+ line = f.readline
46
+ matchData = /^\s#(.*)$/.match(line)
47
+ if matchData
48
+ next
49
+ end
50
+
51
+ matchData = /^\s*$/.match(line)
52
+ if( matchData )
53
+ next
54
+ end
55
+
56
+ matchData = /^-([^\s]*)/.match(line)
57
+ if matchData
58
+ doNotWants.push( {:path => matchData[1]})
59
+ next;
60
+ end
61
+
62
+ matchData = /^([^\s]*)[\s]*([^\s]*)/.match(line)
63
+ if( matchData )
64
+ wants.push( {:path => matchData[1], :version => matchData[2]})
65
+ end
66
+
67
+ end
68
+ end
69
+
70
+ original_dir = Dir.pwd
71
+ Dir.chdir( app_root_dir )
72
+
73
+
74
+ wants.each do |w|
75
+ Dir.glob( w[:path] ) do |filename|
76
+ next if File.directory?(filename)
77
+
78
+ completeFileList[filename] = w[:version]
79
+ end
80
+ end
81
+
82
+ doNotWants.each do |d|
83
+ Dir.glob( d[:path] ) do |filename|
84
+ next if File.directory?(filename)
85
+
86
+ completeFileList.delete( filename )
87
+ end
88
+ end
89
+
90
+ file_list=completeFileList.keys.sort
91
+
92
+
93
+
94
+ def get_cksum( filename )
95
+ if MD5_COMMMAND=="md5"
96
+ `#{MD5_COMMMAND} #{filename} | awk '-F= ' '{ print $2 }'`.strip
97
+ elsif MD5_COMMMAND=="md5sum"
98
+ `#{MD5_COMMMAND} #{filename}`.split(" ")[0].strip
99
+ end
100
+ end
101
+
102
+ def get_svn_revision( filename )
103
+ `svn info -- '#{filename}' | grep "Last Changed Rev" | awk '-F: ' '{ print $2 }'`.strip
104
+ end
105
+
106
+ def get_git_revision( filename )
107
+ `git log --format=%h -1 -- #{filename}`.strip
108
+ end
109
+
110
+
111
+ def get_version(filename, version_type)
112
+
113
+
114
+ if ( version_type == 'svn')
115
+ get_svn_revision( filename )
116
+ elsif ( version_type == 'git')
117
+ get_git_revision( filename )
118
+ elsif( version_type=='md5')
119
+ get_cksum( filename )
120
+ else
121
+ raise "version scheme: \"#{version_type}\" specified for filename: \"#{filename}\" is invalid."
122
+ end
123
+ end
124
+
125
+ file_list = file_list.map do |filename|
126
+ version = get_version( filename, completeFileList[filename] )
127
+ if !version || version == ""
128
+ puts "#{filename} is unversioned"
129
+ nil
130
+ else
131
+ {:version => version, :name => filename, :filesize => File.size( filename ) }
132
+ end
133
+ end.compact
134
+
135
+ def get_total_size( file_list )
136
+
137
+ total_size = file_list.inject(0){|sum,x| sum + x[:filesize].to_i}
138
+ puts (total_size / 1024).to_s + " KB"
139
+ puts (total_size / (1024*1024)).to_s + " MB"
140
+ total_size
141
+ end
142
+
143
+ def print_size_information( file_list )
144
+
145
+
146
+ file_extensions ={}
147
+ file_list.each do |a|
148
+ ext = File.extname( a[:name] )
149
+ file_extensions[ ext ] = file_extensions[ ext ] || []
150
+ file_extensions[ext].push(a)
151
+ end
152
+
153
+ file_extensions.keys.each do |ext|
154
+ puts ext
155
+ get_total_size( file_extensions[ ext] )
156
+ puts ""
157
+ end
158
+ puts "Total"
159
+ total_file_size = get_total_size( file_list )/( 1024 * 1024 );
160
+ puts ""
161
+
162
+ file_sizes_hsh = {}
163
+
164
+ file_extensions.keys.each do |ext|
165
+ file_size = get_total_size( file_extensions[ ext] )/(1024*1024)
166
+ file_sizes_hsh[ ext + "(" + file_size.to_s + "MB)"] = file_size
167
+ end
168
+
169
+ puts "http://chart.apis.google.com/chart?chs=800x225&cht=p&chd=t:#{file_sizes_hsh.values.join(',')}&chdl=#{file_sizes_hsh.keys.join('|')}&chl=#{file_sizes_hsh.keys.join('|')}&chtt=Disk+Usage(#{total_file_size}+MB)"
170
+
171
+ end
172
+
173
+
174
+ print_size_information( file_list )
175
+
176
+ xml_file_list = file_list.map do |value|
177
+ "\t<file " + value.map {|k,v| k.to_s + "=\"#{v}\"" }.join(" ") + "/>"
178
+ end
179
+
180
+ prefix = <<-eos
181
+ <?xml version="1.0" encoding="utf-8"?>
182
+ <manifest version="3.02">
183
+ <files>
184
+ eos
185
+
186
+ suffix = <<-eos
187
+
188
+ </files>
189
+ </manifest>
190
+ eos
191
+
192
+ output = prefix + xml_file_list.join("\n") + suffix
193
+
194
+
195
+ Dir.chdir( original_dir )
196
+
197
+ File.open( File.join(output_dir, "manifest.xml"), 'w' ) do |file|
198
+ file.write( output )
199
+ end
200
+
201
+ asset_file_name = File.join( output_dir, "full_asset_list.txt" )
202
+ File.open( asset_file_name , 'w' ) do |file|
203
+ file.write( file_list.map{|k| k[:name] }.map do |k|
204
+ if k[0,2] == "./"
205
+ k[2, k.length - 1]
206
+ else
207
+ k
208
+ end
209
+ end.join("\n") )
210
+ end
211
+
212
+
213
+
214
+ end
215
+
data/lib/lib.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'json'
2
+
3
+ def get_spaceport_options
4
+ if File.exists?(".spaceport")
5
+ opts = JSON.parse( File.open( ".spaceport", "r" ).read )
6
+
7
+ out = {}
8
+ opts.each do |k,v|
9
+ out[k] = v
10
+ out[k.intern] = v
11
+ end
12
+ return out
13
+ else
14
+ return {}
15
+ end
16
+ end
17
+
18
+ def spaceport_options()
19
+ get_spaceport_options()
20
+ end
data/lib/server.rb ADDED
File without changes
data/spaceport.gemspec ADDED
@@ -0,0 +1,57 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{spaceport}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["djacobs7"]
12
+ s.date = %q{2012-02-14}
13
+ s.default_executable = %q{spaceport}
14
+ s.description = %q{Seriously, this thing is great}
15
+ s.email = %q{daniel@sibblingz.com}
16
+ s.executables = ["spaceport"]
17
+ s.extra_rdoc_files = [
18
+ "README"
19
+ ]
20
+ s.files = [
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "README",
24
+ "Rakefile",
25
+ "bin/spaceport",
26
+ "lib/bundle.config",
27
+ "lib/bundle.rb",
28
+ "lib/generate_manifest.rb",
29
+ "lib/lib.rb",
30
+ "lib/server.rb",
31
+ "spaceport.gemspec"
32
+ ]
33
+ s.homepage = %q{http://github.com/sibblingz/spaceport-publisher}
34
+ s.licenses = ["ALL OF THEM"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.6.2}
37
+ s.summary = %q{Bundling tool for spaceport}
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_runtime_dependency(%q<OptionParser>, [">= 0"])
44
+ s.add_development_dependency(%q<bundler>, [">= 0"])
45
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
46
+ else
47
+ s.add_dependency(%q<OptionParser>, [">= 0"])
48
+ s.add_dependency(%q<bundler>, [">= 0"])
49
+ s.add_dependency(%q<jeweler>, [">= 0"])
50
+ end
51
+ else
52
+ s.add_dependency(%q<OptionParser>, [">= 0"])
53
+ s.add_dependency(%q<bundler>, [">= 0"])
54
+ s.add_dependency(%q<jeweler>, [">= 0"])
55
+ end
56
+ end
57
+
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sp
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - djacobs7
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-02-14 00:00:00 -08:00
14
+ default_executable: spaceport
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: OptionParser
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: jeweler
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ description: Seriously, this thing is great
50
+ email: daniel@sibblingz.com
51
+ executables:
52
+ - spaceport
53
+ extensions: []
54
+
55
+ extra_rdoc_files:
56
+ - README
57
+ files:
58
+ - Gemfile
59
+ - Gemfile.lock
60
+ - README
61
+ - Rakefile
62
+ - bin/spaceport
63
+ - lib/bundle.config
64
+ - lib/bundle.rb
65
+ - lib/generate_manifest.rb
66
+ - lib/lib.rb
67
+ - lib/server.rb
68
+ - spaceport.gemspec
69
+ has_rdoc: true
70
+ homepage: http://github.com/sibblingz/spaceport-publisher
71
+ licenses:
72
+ - ALL OF THEM
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 400669750178125209
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ requirements: []
94
+
95
+ rubyforge_project:
96
+ rubygems_version: 1.6.2
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: Bundling tool for spaceport
100
+ test_files: []
101
+