high_five 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- high_five (0.0.1)
4
+ high_five (0.0.3)
5
5
  compass (~> 0.12.2)
6
6
  sprockets (~> 2.9.0)
7
7
  thor (~> 0.17.0)
data/bin/hi5 CHANGED
@@ -12,9 +12,7 @@ rescue LoadError
12
12
  require 'rubygems'
13
13
  require 'high_five'
14
14
  end
15
-
16
- require 'high_five/cli'
17
-
18
15
  HighFive::ROOT = Dir.pwd
16
+ require 'high_five/cli'
19
17
 
20
18
  HighFive::Cli.start
@@ -0,0 +1,17 @@
1
+ module HighFive
2
+ module AndroidTasks
3
+ def self.included(mod)
4
+ mod.class_eval do
5
+
6
+ namespace "android"
7
+ desc "android_debug", "build the debug apk via ant debug"
8
+ def android_debug
9
+ self.destination_root = HighFive::ROOT
10
+ puts "Debugy"
11
+ end
12
+
13
+
14
+ end #end class_eval
15
+ end
16
+ end
17
+ end
@@ -1,36 +1,28 @@
1
1
  require 'thor'
2
2
  require 'high_five/deploy_task'
3
3
  require 'high_five/init_task'
4
+ require 'high_five/android_tasks'
4
5
  require 'high_five/config'
5
6
 
6
7
  module HighFive
7
8
  class Cli < Thor
8
9
  include Thor::Actions
9
- include HighFive::DeployTask
10
10
  include HighFive::InitTask
11
-
11
+ include HighFive::DeployTask
12
+ include HighFive::AndroidTasks
12
13
  # source root path for Thor::Actions commands
13
- source_root(HighFive::TEMPLATE_PATH)
14
-
15
- desc "deploy", "Deploy the app for a specific platform in a specific environment"
16
- method_option :environment, :aliases => "-e", :desc => "Environemnt [production|development]", :default => "development"
17
- method_option :compress, :aliases => '-c', :desc => "Compress javascript [true]", :default => false
18
- method_option :weinre_url, :aliases => '-w', :desc => "Enter your Weinre server-url including port", :default => false
19
- method_option :"copy-files", :aliases => '-f', :desc => "Copy files to eclipse/xcode directory", :default => false
20
- def deploy(target)
21
- self.source_paths << File.join(base_config.root)
22
- deploy_task(target)
23
- end
24
-
25
- desc "init", "Initialize the high_five configuration in the current working directory"
26
- def init
27
- init_task
28
- end
14
+ source_root(HighFive::ROOT)
29
15
 
16
+ class_option :version, type: :boolean, desc: "Print version and ext", aliases: "-v"
30
17
  def initialize(*args)
31
- super(*args)
18
+ super
19
+
20
+ if options[:version]
21
+ puts "HighFive #{HighFive::VERSION}"
22
+ Process.exit(0)
23
+ end
32
24
  end
33
-
25
+
34
26
  private
35
27
  def base_config
36
28
  begin
@@ -41,4 +33,4 @@ module HighFive
41
33
  end
42
34
  end
43
35
  end
44
- end
36
+ end
@@ -7,7 +7,8 @@ module HighFive
7
7
  :static_assets,
8
8
  :static_javascripts,
9
9
  :static_stylesheets,
10
- :sass_files
10
+ :sass_files,
11
+ :asset_paths
11
12
 
12
13
 
13
14
  def self.configure(&block)
@@ -24,6 +25,10 @@ module HighFive
24
25
  return @@instance
25
26
  end
26
27
 
28
+ def self.instance
29
+ @@instance
30
+ end
31
+
27
32
  def build_platform_config(platform)
28
33
  if @platform_configs[platform.to_s]
29
34
  new_config = HighFive::Config.new(@platform_configs[platform.to_s])
@@ -35,6 +40,7 @@ module HighFive
35
40
  new_config.static_javascripts += self.static_javascripts
36
41
  new_config.static_stylesheets += self.static_stylesheets
37
42
  new_config.sass_files += self.sass_files
43
+ new_config.asset_paths += self.asset_paths
38
44
  return new_config
39
45
  else
40
46
  return self
@@ -48,6 +54,7 @@ module HighFive
48
54
  @static_stylesheets = config.static_stylesheets.dup
49
55
  @sass_files = config.sass_files.dup
50
56
  @meta = config.meta.dup
57
+ @asset_paths = config.asset_paths.dup
51
58
  self.root = config.root
52
59
  self.destination = config.destination
53
60
  self.page_title = config.page_title
@@ -59,6 +66,7 @@ module HighFive
59
66
  @sass_files = []
60
67
  @meta = {}
61
68
  @platform_configs = {}
69
+ @asset_paths = []
62
70
  end
63
71
  end
64
72
 
@@ -3,181 +3,197 @@ require 'sass'
3
3
  module HighFive
4
4
  module DeployTask
5
5
 
6
- def deploy_task(target)
7
- @environment = options[:environment]
8
- @platform = target
9
- @weinre_url = options[:weinre_url]
10
- @copy_files = options[:"copy-files"]
11
- @meta = {}
12
- config = base_config.build_platform_config(@platform)
13
- @config_root = File.join("config", "high_five")
14
-
15
- self.source_paths << File.join(base_config.root, @config_root)
16
-
17
- raise "Please set config.destination" if config.destination.nil?
18
- self.destination_root = config.destination
19
- FileUtils.rm_rf(self.destination_root)
20
-
21
- #todo add to config
22
- say "Deploying app: <#{@platform}> <#{options[:environment]}>"
23
- say "\t#{self.destination_root}"
24
- say " -Weinre url: #{@weinre_url}" if @weinre_url
25
-
26
-
27
- #todo customize this
28
- # Dir.chdir File.join("assets", "sass")
29
- # success = false
30
- # if @environment == "production"
31
- # success = system("compass compile --force --no-debug-info -e production #{options[:platform]}.scss")
32
- # else
33
- # success = system("compass compile --force --no-debug-info #{options[:platform]}.scss")
34
- # end
35
- # unless success
36
- # raise "Error compiling CSS, aborting build"
37
- # end
38
- # Dir.chdir pwd
39
-
40
- # Build javascript
41
- # inside "assets" do |assets|
42
- # directory "images"
43
- # directory "stylesheets"
44
- # inside "javascripts" do |dir|
45
- # if @compress == true
46
- # build_javascript :from => "app-#{@platform}", :to => 'app-all.js'
47
- # compress_javascript "app-all.js"
48
- # else
49
- # bundle = builder.find_asset "app-#{@platform}"
50
- # @js_files = bundle.dependencies.map {|asset| File.join("assets", asset.logical_path) }
51
- # copy_file "app.js"
52
- # directory "app"
53
- # directory "config"
54
- # directory "lib"
55
- # directory "platform/phonegap" unless @platform == 'web'
56
- # directory "platform/#{@platform}"
57
- # end
58
-
59
- # end
60
-
61
- # Bundle is based on the provided build platformx
62
- platform_file = File.join(@config_root, "app-#{@platform}.js")
63
- unless File.exists? platform_file
64
- error "#{@platform} is not a valid target. Please create app-#{@platform}.js"
65
- end
66
- bundle = builder.find_asset platform_file
67
-
68
- if (@environment == "production")
69
- appjs = File.join(self.destination_root, "app.js")
70
- @javascripts = ["app.js"]
71
- say " create #{appjs}", :green
72
- bundle.write_to(appjs)
73
- else
74
- # Add each of the javascript files to the generated folder
75
- @javascripts = bundle.dependencies.map do |asset|
76
- copy_file asset.logical_path
77
- asset.logical_path
6
+ def self.included(mod)
7
+ mod.class_eval do
8
+
9
+ desc "deploy", "Deploy the app for a specific platform in a specific environment"
10
+ method_option :environment, :aliases => "-e", :desc => "Environemnt [production|development]", :default => "development"
11
+ method_option :compress, :aliases => '-c', :desc => "Compress javascript [true]", :default => false
12
+ method_option :weinre_url, :aliases => '-w', :desc => "Enter your Weinre server-url including port", :default => false
13
+ method_option :"copy-files", :aliases => '-f', :desc => "Copy files to eclipse/xcode directory", :default => false
14
+ def deploy(target)
15
+ @environment = options[:environment]
16
+ @platform = target
17
+ @weinre_url = options[:weinre_url]
18
+ @copy_files = options[:"copy-files"]
19
+ @meta = {}
20
+ @config = base_config.build_platform_config(@platform)
21
+ @config_root = File.join("config", "high_five")
22
+
23
+ self.source_paths << File.join(base_config.root, @config_root)
24
+ self.source_paths << File.join(base_config.root)
25
+
26
+ raise "Please set config.destination" if @config.destination.nil?
27
+ self.destination_root = @config.destination
28
+ FileUtils.rm_rf(self.destination_root)
29
+
30
+ #todo add to config
31
+ say "Deploying app: <#{@platform}> <#{options[:environment]}>"
32
+ say "\t#{self.destination_root}"
33
+ say " -Weinre url: #{@weinre_url}" if @weinre_url
34
+
35
+
36
+ #todo customize this
37
+ # Dir.chdir File.join("assets", "sass")
38
+ # success = false
39
+ # if @environment == "production"
40
+ # success = system("compass compile --force --no-debug-info -e production #{options[:platform]}.scss")
41
+ # else
42
+ # success = system("compass compile --force --no-debug-info #{options[:platform]}.scss")
43
+ # end
44
+ # unless success
45
+ # raise "Error compiling CSS, aborting build"
46
+ # end
47
+ # Dir.chdir pwd
48
+
49
+ # Build javascript
50
+ # inside "assets" do |assets|
51
+ # directory "images"
52
+ # directory "stylesheets"
53
+ # inside "javascripts" do |dir|
54
+ # if @compress == true
55
+ # build_javascript :from => "app-#{@platform}", :to => 'app-all.js'
56
+ # compress_javascript "app-all.js"
57
+ # else
58
+ # bundle = builder.find_asset "app-#{@platform}"
59
+ # @js_files = bundle.dependencies.map {|asset| File.join("assets", asset.logical_path) }
60
+ # copy_file "app.js"
61
+ # directory "app"
62
+ # directory "config"
63
+ # directory "lib"
64
+ # directory "platform/phonegap" unless @platform == 'web'
65
+ # directory "platform/#{@platform}"
66
+ # end
67
+
68
+ # end
69
+
70
+ # Bundle is based on the provided build platformx
71
+ platform_file = File.join(@config_root, "app-#{@platform}.js")
72
+ unless File.exists? platform_file
73
+ error "#{@platform} is not a valid target. Please create app-#{@platform}.js" and exit
74
+ end
75
+ bundle = builder.find_asset platform_file
76
+
77
+ if (@environment == "production")
78
+ appjs = File.join(self.destination_root, "app.js")
79
+ @javascripts = ["app.js"]
80
+ say " create #{appjs}", :green
81
+ bundle.write_to(appjs)
82
+ else
83
+ # Add each of the javascript files to the generated folder
84
+ @javascripts = bundle.dependencies.map do |asset|
85
+ copy_file asset.logical_path
86
+ asset.logical_path
87
+ end
88
+ end
89
+
90
+ # Adds each of the static javascripts
91
+ @config.static_javascripts.each do |javascript|
92
+ if File.directory? javascript
93
+ directory javascript
94
+ @javascripts.unshift(*Dir[File.join(javascript,'**','*.js')])
95
+ else
96
+ copy_file javascript unless javascript =~ /^https?:\/\//
97
+ @javascripts.unshift javascript
98
+ end
99
+ end
100
+
101
+ @stylesheets = []
102
+ @config.sass_files.each do |sass_file|
103
+ asset_name = File.basename(sass_file, File.extname(sass_file))
104
+ css_file = File.join(self.destination_root, "stylesheets", "#{asset_name}.css")
105
+ say "Compiling #{sass_file} -> #{css_file}"
106
+ Sass.compile_file sass_file, css_file
107
+ @stylesheets.push sass_file
108
+ end
109
+
110
+ @config.static_stylesheets.each do |stylesheet|
111
+ if File.directory? stylesheet
112
+ directory stylesheet
113
+ @stylesheets.unshift(*Dir[File.join(stylesheet,'**','*.css')])
114
+ else
115
+ copy_file stylesheet
116
+ @stylesheets.unshift stylesheet
117
+ end
118
+ end
119
+
120
+ # Adds each of the static assets to the generated folder (sylesheets etc)
121
+ @config.static_assets.each do |asset|
122
+ if File.directory? asset
123
+ directory asset
124
+ else
125
+ copy_file asset
126
+ end
127
+ end
128
+
129
+ # inside "stylesheets" do |dir|
130
+ # # Copy generated css
131
+ # copy_file "#{@platform}.css", "theme.css"
132
+ # end
133
+ # end
134
+
135
+ # Build index.html
136
+ say "Generating index.html"
137
+ template File.join(@config_root, "index.html.erb"), File.join(self.destination_root, "index.html")
138
+
139
+ # if (@copy_files)
140
+ # dest = nil
141
+ # # copy to platform build directories
142
+ # if (@platform == 'android')
143
+ # dest = File.join(HighFive::ROOT, "..", "account_assistant-android/assets/www")
144
+ # elsif (@platform == 'ios')
145
+ # dest = File.join(HighFive::ROOT, "..", "account_assistant-ios/www")
146
+ # end
147
+
148
+ # if (!dest.nil? && File.exists?(dest))
149
+ # say "Copying to #{@platform} native project: #{dest}"
150
+ # FileUtils.rm_rf(dest)
151
+ # directory self.destination_root, dest
152
+ # end
153
+ # end
78
154
  end
79
- end
155
+
156
+ private
80
157
 
81
- # Adds each of the static javascripts
82
- config.static_javascripts.each do |javascript|
83
- if File.directory? javascript
84
- directory javascript
85
- @javascripts.unshift(*Dir[File.join(javascript,'**','*.js')])
86
- else
87
- copy_file javascript unless javascript =~ /^https?:\/\//
88
- @javascripts.unshift javascript
158
+ def builder
159
+ @builder ||= get_builder
89
160
  end
90
- end
91
-
92
- @stylesheets = []
93
- config.sass_files.each do |sass_file|
94
- asset_name = File.basename(sass_file, File.extname(sass_file))
95
- css_file = File.join(self.destination_root, "stylesheets", "#{asset_name}.css")
96
- say "Compiling #{sass_file} -> #{css_file}"
97
- Sass.compile_file sass_file, css_file
98
- @stylesheets.push sass_file
99
- end
100
161
 
101
- config.static_stylesheets.each do |stylesheet|
102
- if File.directory? stylesheet
103
- directory stylesheet
104
- @stylesheets.unshift(*Dir[File.join(stylesheet,'**','*.css')])
105
- else
106
- copy_file stylesheet
107
- @stylesheets.unshift stylesheet
162
+ def get_builder
163
+ builder = Sprockets::Environment.new(File.join(HighFive::ROOT))
164
+ builder.append_path "."
165
+ builder.append_path base_config.root
166
+ builder.append_path File.join(base_config.root, @config_root)
167
+ @config.asset_paths.each do |path|
168
+ full_path = File.join(base_config.root, path)
169
+ puts "adding path #{full_path}"
170
+ builder.append_path full_path
171
+ end
172
+
173
+ builder
108
174
  end
109
- end
110
175
 
111
- # Adds each of the static assets to the generated folder (sylesheets etc)
112
- config.static_assets.each do |asset|
113
- if File.directory? asset
114
- directory asset
115
- else
116
- copy_file asset
176
+ #TODO: this probably doesn't work on windows
177
+ def compress_javascript(file_name)
178
+ say " -Compressing #{file_name} with yuicompressor", :yellow
179
+
180
+ compressor = 'yuicompressor'
181
+ if `which yuicompressor`.empty?
182
+ compressor = 'yui-compressor'
183
+ if `which yui-compressor`.empty?
184
+ say "ERROR: you don't have a yuicompressor installed", :red
185
+ say " Are you sure yuicompressor is installed on your system? Mac users, run this in console:", :red
186
+ say " $ brew install yuicompressor", :red
187
+ say " Ubuntu users: $sudo apt-get -y install yui-compressor", :red
188
+ end
189
+ end
190
+ cmd = "#{compressor} #{file_name} -o #{file_name}"
191
+ system(cmd)
192
+ unless $?.exitstatus == 0
193
+ say " ERROR: #{cmd}", :red
194
+ end
117
195
  end
118
196
  end
119
-
120
- # inside "stylesheets" do |dir|
121
- # # Copy generated css
122
- # copy_file "#{@platform}.css", "theme.css"
123
- # end
124
- # end
125
-
126
- # Build index.html
127
- say "Generating index.html"
128
- template File.join(@config_root, "index.html.erb"), File.join(self.destination_root, "index.html")
129
-
130
- # if (@copy_files)
131
- # dest = nil
132
- # # copy to platform build directories
133
- # if (@platform == 'android')
134
- # dest = File.join(HighFive::ROOT, "..", "account_assistant-android/assets/www")
135
- # elsif (@platform == 'ios')
136
- # dest = File.join(HighFive::ROOT, "..", "account_assistant-ios/www")
137
- # end
138
-
139
- # if (!dest.nil? && File.exists?(dest))
140
- # say "Copying to #{@platform} native project: #{dest}"
141
- # FileUtils.rm_rf(dest)
142
- # directory self.destination_root, dest
143
- # end
144
- # end
145
- end
146
-
147
- private
148
-
149
- def builder
150
- @builder ||= get_builder
151
- end
152
-
153
- def get_builder
154
- builder = Sprockets::Environment.new(File.join(HighFive::ROOT))
155
- builder.append_path @config_root
156
- builder.append_path "."
157
- builder.append_path base_config.root
158
-
159
- builder
160
- end
161
-
162
- #TODO: this probably doesn't work on windows
163
- def compress_javascript(file_name)
164
- say " -Compressing #{file_name} with yuicompressor", :yellow
165
-
166
- compressor = 'yuicompressor'
167
- if `which yuicompressor`.empty?
168
- compressor = 'yui-compressor'
169
- if `which yui-compressor`.empty?
170
- say "ERROR: you don't have a yuicompressor installed", :red
171
- say " Are you sure yuicompressor is installed on your system? Mac users, run this in console:", :red
172
- say " $ brew install yuicompressor", :red
173
- say " Ubuntu users: $sudo apt-get -y install yui-compressor", :red
174
- end
175
- end
176
- cmd = "#{compressor} #{file_name} -o #{file_name}"
177
- system(cmd)
178
- unless $?.exitstatus == 0
179
- say " ERROR: #{cmd}", :red
180
- end
181
197
  end
182
198
  end
183
199
  end
@@ -1,23 +1,30 @@
1
1
  require 'fileutils'
2
2
  module HighFive
3
3
  module InitTask
4
+ def self.included(mod)
5
+ mod.class_eval do
4
6
 
5
- def init_task
6
- self.destination_root = HighFive::ROOT
7
+ desc "init", "Initialize the high_five configuration in the current working directory"
8
+ def init
9
+ self.destination_root = HighFive::ROOT
7
10
 
8
- inside "config" do
9
- template("high_five.rb")
10
- inside "high_five" do
11
- copy_file "index.html.erb", :skip => true
12
- copy_file "app-common.js", :skip => true
11
+ inside "config" do
12
+ template("high_five.rb")
13
+ inside "high_five" do
14
+ copy_file "index.html.erb", :skip => true
15
+ copy_file "app-common.js", :skip => true
13
16
 
14
- #TODO make this a CLI argument
15
- platforms = ["android", "ios"]
16
- platforms.each do |platform|
17
- copy_file "app-platform.js", "app-#{platform}.js", :skip => true
17
+ #TODO make this a CLI argument
18
+ platforms = ["android", "ios"]
19
+ platforms.each do |platform|
20
+ copy_file "app-platform.js", "app-#{platform}.js", :skip => true
21
+ end
22
+ end
18
23
  end
19
24
  end
20
- end
25
+
26
+
27
+ end #end class_eval
21
28
  end
22
29
  end
23
30
  end
@@ -1,3 +1,3 @@
1
1
  module HighFive
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe HighFive::Config do
4
+
5
+ context "asset_paths" do
6
+ before do
7
+ HighFive::Config.configure do |config|
8
+ config.asset_paths = ["assets"]
9
+ config.platform :android do |android|
10
+
11
+ end
12
+ end
13
+ @config = HighFive::Config.instance
14
+ end
15
+ it "should keep track of asset_paths for platform configs" do
16
+ platform_config = @config.build_platform_config('android')
17
+ platform_config.asset_paths.should eq ["assets"]
18
+
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe HighFive::DeployTask do
4
+
5
+
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: high_five
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-02 00:00:00.000000000 Z
12
+ date: 2013-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -113,11 +113,14 @@ files:
113
113
  - high_five.gemspec
114
114
  - lib/.DS_Store
115
115
  - lib/high_five.rb
116
+ - lib/high_five/android_tasks.rb
116
117
  - lib/high_five/cli.rb
117
118
  - lib/high_five/config.rb
118
119
  - lib/high_five/deploy_task.rb
119
120
  - lib/high_five/init_task.rb
120
121
  - lib/high_five/version.rb
122
+ - spec/config_spec.rb
123
+ - spec/deploy_spec.rb
121
124
  - spec/init_spec.rb
122
125
  - spec/spec_helper.rb
123
126
  - template/config/high_five.rb
@@ -150,5 +153,7 @@ specification_version: 3
150
153
  summary: HighFive is a set of build scripts and tools for packing HTML5 apps both
151
154
  for the web and for phonegap
152
155
  test_files:
156
+ - spec/config_spec.rb
157
+ - spec/deploy_spec.rb
153
158
  - spec/init_spec.rb
154
159
  - spec/spec_helper.rb