high_five 0.0.3 → 0.0.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/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  .DS_Store
2
2
  *.gem
3
+ .sass-cache
data/bin/hi5 CHANGED
@@ -12,7 +12,6 @@ rescue LoadError
12
12
  require 'rubygems'
13
13
  require 'high_five'
14
14
  end
15
- HighFive::ROOT = Dir.pwd
16
15
  require 'high_five/cli'
17
16
 
18
17
  HighFive::Cli.start
@@ -6,7 +6,7 @@ module HighFive
6
6
  namespace "android"
7
7
  desc "android_debug", "build the debug apk via ant debug"
8
8
  def android_debug
9
- self.destination_root = HighFive::ROOT
9
+ self.destination_root = base_config.root
10
10
  puts "Debugy"
11
11
  end
12
12
 
data/lib/high_five/cli.rb CHANGED
@@ -11,12 +11,11 @@ module HighFive
11
11
  include HighFive::DeployTask
12
12
  include HighFive::AndroidTasks
13
13
  # source root path for Thor::Actions commands
14
- source_root(HighFive::ROOT)
14
+
15
15
 
16
16
  class_option :version, type: :boolean, desc: "Print version and ext", aliases: "-v"
17
17
  def initialize(*args)
18
18
  super
19
-
20
19
  if options[:version]
21
20
  puts "HighFive #{HighFive::VERSION}"
22
21
  Process.exit(0)
@@ -8,17 +8,22 @@ module HighFive
8
8
  :static_javascripts,
9
9
  :static_stylesheets,
10
10
  :sass_files,
11
- :asset_paths
11
+ :asset_paths,
12
+ :compass_dir
12
13
 
13
14
 
14
15
  def self.configure(&block)
15
16
  @@instance = HighFive::Config.new
16
17
  yield @@instance
18
+
19
+ if @@instance.root.nil?
20
+ raise "HighFive::Config.root is required"
21
+ end
17
22
  end
18
23
 
19
24
  def self.load
20
25
  begin
21
- require File.join(HighFive::ROOT, "config", "high_five.rb")
26
+ require File.join(Dir.pwd, "config", "high_five.rb")
22
27
  rescue LoadError
23
28
  raise "high_five configuration not found, forgot to run 'hi5 init'?"
24
29
  end
@@ -41,6 +46,7 @@ module HighFive
41
46
  new_config.static_stylesheets += self.static_stylesheets
42
47
  new_config.sass_files += self.sass_files
43
48
  new_config.asset_paths += self.asset_paths
49
+ new_config.compass_dir ||= self.compass_dir
44
50
  return new_config
45
51
  else
46
52
  return self
@@ -33,46 +33,34 @@ module HighFive
33
33
  say " -Weinre url: #{@weinre_url}" if @weinre_url
34
34
 
35
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
36
+
37
+ if @config.compass_dir
38
+ compass_dir = File.join(base_config.root, @config.compass_dir)
39
+ pwd = Dir.pwd
40
+ Dir.chdir compass_dir
41
+ # TODO make this invoke compass programatically
42
+ # Consider using sprockets for css too, although I kindof hate that
43
+ say "Precompiling compass styles from #{compass_dir}}"
44
+ success = false
45
+ if @environment == "production"
46
+ success = system("compass compile --force --no-debug-info -e production")
47
+ else
48
+ success = system("compass compile --force --no-debug-info")
49
+ end
50
+ unless success
51
+ raise "Error compiling CSS, aborting build"
52
+ end
53
+ Dir.chdir pwd
54
+ end
69
55
 
70
56
  # Bundle is based on the provided build platformx
71
57
  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
58
  bundle = builder.find_asset platform_file
59
+ if bundle.nil?
60
+ p source_paths
61
+ error "#{@platform} is not a valid target. Please create #{platform_file}" and Process.exit
62
+ end
63
+
76
64
 
77
65
  if (@environment == "production")
78
66
  appjs = File.join(self.destination_root, "app.js")
@@ -81,7 +69,8 @@ module HighFive
81
69
  bundle.write_to(appjs)
82
70
  else
83
71
  # Add each of the javascript files to the generated folder
84
- @javascripts = bundle.dependencies.map do |asset|
72
+ @javascripts = bundle.dependencies.map do |asset|
73
+ next if asset.logical_path =~ /^config\/high_five/ #don't copy manifest files
85
74
  copy_file asset.logical_path
86
75
  asset.logical_path
87
76
  end
@@ -104,7 +93,8 @@ module HighFive
104
93
  css_file = File.join(self.destination_root, "stylesheets", "#{asset_name}.css")
105
94
  say "Compiling #{sass_file} -> #{css_file}"
106
95
  Sass.compile_file sass_file, css_file
107
- @stylesheets.push sass_file
96
+ @stylesheets.push css_file
97
+ copy_file css_file
108
98
  end
109
99
 
110
100
  @config.static_stylesheets.each do |stylesheet|
@@ -126,31 +116,9 @@ module HighFive
126
116
  end
127
117
  end
128
118
 
129
- # inside "stylesheets" do |dir|
130
- # # Copy generated css
131
- # copy_file "#{@platform}.css", "theme.css"
132
- # end
133
- # end
134
-
135
119
  # Build index.html
136
120
  say "Generating index.html"
137
121
  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
154
122
  end
155
123
 
156
124
  private
@@ -160,16 +128,14 @@ module HighFive
160
128
  end
161
129
 
162
130
  def get_builder
163
- builder = Sprockets::Environment.new(File.join(HighFive::ROOT))
164
- builder.append_path "."
131
+ builder = Sprockets::Environment.new(File.join(base_config.root))
165
132
  builder.append_path base_config.root
166
133
  builder.append_path File.join(base_config.root, @config_root)
167
134
  @config.asset_paths.each do |path|
168
135
  full_path = File.join(base_config.root, path)
169
- puts "adding path #{full_path}"
136
+ say "adding asset search path #{full_path}"
170
137
  builder.append_path full_path
171
138
  end
172
-
173
139
  builder
174
140
  end
175
141
 
@@ -6,7 +6,8 @@ module HighFive
6
6
 
7
7
  desc "init", "Initialize the high_five configuration in the current working directory"
8
8
  def init
9
- self.destination_root = HighFive::ROOT
9
+ self.destination_root = Dir.pwd
10
+ self.source_paths << HighFive::TEMPLATE_PATH
10
11
 
11
12
  inside "config" do
12
13
  template("high_five.rb")
@@ -1,3 +1,3 @@
1
1
  module HighFive
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/spec/config_spec.rb CHANGED
@@ -5,6 +5,7 @@ describe HighFive::Config do
5
5
  context "asset_paths" do
6
6
  before do
7
7
  HighFive::Config.configure do |config|
8
+ config.root = "/"
8
9
  config.asset_paths = ["assets"]
9
10
  config.platform :android do |android|
10
11
 
@@ -15,10 +16,7 @@ describe HighFive::Config do
15
16
  it "should keep track of asset_paths for platform configs" do
16
17
  platform_config = @config.build_platform_config('android')
17
18
  platform_config.asset_paths.should eq ["assets"]
18
-
19
-
20
19
  end
21
-
22
20
  end
23
21
 
24
22
  end
data/spec/deploy_spec.rb CHANGED
@@ -1,6 +1,79 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe HighFive::DeployTask do
4
+ def create_dummy_app!
5
+ @original_dir = Dir.pwd
6
+ @project_root = Dir.mktmpdir("hi5")
7
+ Dir.chdir @project_root
8
+ FileUtils.cp_r(Dir[File.join(File.dirname(__FILE__), "dummy", "*")], @project_root)
9
+ end
4
10
 
11
+ def cli
12
+ cli = HighFive::Cli.new
13
+ cli.instance_variable_set("@base_config", HighFive::Config.instance)
14
+ cli
15
+ end
5
16
 
6
- end
17
+ def destroy_dummy_app!
18
+ puts "Cleaning up deploy directory. Contents: "
19
+ system("find #{@project_root} -print | sed 's;[^/]*/;|___;g;s;___|; |;g'")
20
+ Dir.chdir @original_dir
21
+ FileUtils.rm_rf @project_root
22
+ end
23
+
24
+ context "Basic Deployment" do
25
+ before :all do
26
+ create_dummy_app!
27
+ HighFive::Config.configure do |config|
28
+ config.root = @project_root
29
+ config.destination = "www"
30
+ config.platform :android do |android|
31
+
32
+ end
33
+
34
+ cli.deploy("android")
35
+ end
36
+ end
37
+
38
+ after(:all) { destroy_dummy_app! }
39
+
40
+ it "should deploy" do
41
+ Dir.exists?(File.join(@project_root, "www")).should be_true
42
+ end
43
+
44
+ it "should copy all the javascript files" do
45
+ File.join(@project_root, "www", "javascripts", "app").should exist
46
+ File.join(@project_root, "www", "javascripts", "app", "component.js").should exist
47
+ end
48
+ end
49
+
50
+ context "SASS Deployment" do
51
+ before :all do
52
+ create_dummy_app!
53
+ HighFive::Config.configure do |config|
54
+ config.root = @project_root
55
+ config.destination = "www"
56
+ config.compass_dir = "."
57
+ config.assets "stylesheets"
58
+ config.platform :android do |android|
59
+
60
+ end
61
+
62
+ cli.deploy("android")
63
+ end
64
+ end
65
+
66
+ after(:all) { destroy_dummy_app! }
67
+
68
+ it "should invoke compass to compile stylesheets" do
69
+ expect(File.join(@project_root, "stylesheets", "screen.css")).to exist
70
+ end
71
+
72
+ it "should copy the css sheets to the deploy directory" do
73
+ pending "better compass integration"
74
+ expect(File.join(@project_root, "www", "stylesheets", "screen.css")).to exist
75
+ end
76
+
77
+ end
78
+
79
+ end
@@ -0,0 +1,2 @@
1
+ // This file can be used to customize the javascript includes for a sepcific platform
2
+ //= require app-common
@@ -0,0 +1,4 @@
1
+ //This is where you define the javascripts you include and their include order for your app.
2
+ //Only include app code that you want minified here, add library or remote scripts to config/high_five.rb
3
+ //= require javascripts/app.js
4
+ //= require_tree ../../javascripts/app
@@ -0,0 +1,2 @@
1
+ // This file can be used to customize the javascript includes for a sepcific platform
2
+ //= require app-common
@@ -0,0 +1,26 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title><%= @meta[:title] %></title>
6
+ <meta name="description" content="<%= @meta[:description] %>" />
7
+ <% @stylesheets.each do |ss| -%>
8
+ <link rel="stylesheet" href="<%= ss %>" type="text/css" />
9
+ <% end -%>
10
+ <% if @platform != 'web' -%>
11
+ <% if @environment == 'development' -%>
12
+ <script type="text/javascript">
13
+ window.onerror = function(e,u,l) {
14
+ alert("Error caught" + e + " " + u + ":" + l);
15
+ };
16
+ </script>
17
+ <% end -%>
18
+ <% end -%>
19
+ <%- @javascripts.each do |js| -%>
20
+ <script type="text/javascript" src="<%= js %>"></script>
21
+ <%- end -%>
22
+
23
+ </head>
24
+ <body></body>
25
+ </html>
26
+
@@ -0,0 +1,3 @@
1
+ #This isn't used, the tests stub this out to test specific configuration options
2
+ HighFive::Config.configure do |config|
3
+ end
@@ -0,0 +1,24 @@
1
+ # Require any additional compass plugins here.
2
+
3
+ # Set this to the root of your project when deployed:
4
+ http_path = "/"
5
+ css_dir = "stylesheets"
6
+ sass_dir = "sass"
7
+ images_dir = "images"
8
+ javascripts_dir = "javascripts"
9
+
10
+ # You can select your preferred output style here (can be overridden via the command line):
11
+ # output_style = :expanded or :nested or :compact or :compressed
12
+
13
+ # To enable relative paths to assets via compass helper functions. Uncomment:
14
+ # relative_assets = true
15
+
16
+ # To disable debugging comments that display the original location of your selectors. Uncomment:
17
+ # line_comments = false
18
+
19
+
20
+ # If you prefer the indented syntax, you might want to regenerate this
21
+ # project again passing --syntax sass, or you can uncomment this:
22
+ # preferred_syntax = :sass
23
+ # and then run:
24
+ # sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
@@ -0,0 +1,3 @@
1
+ var Component = {
2
+ field: "component_was_included"
3
+ };
@@ -0,0 +1 @@
1
+ alert("This application is awesome!");
@@ -0,0 +1,5 @@
1
+ /* Welcome to Compass. Use this file to write IE specific override styles.
2
+ * Import this file using the following HTML or equivalent:
3
+ * <!--[if IE]>
4
+ * <link href="/stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
5
+ * <![endif]--> */
@@ -0,0 +1,3 @@
1
+ /* Welcome to Compass. Use this file to define print styles.
2
+ * Import this file using the following HTML or equivalent:
3
+ * <link href="/stylesheets/print.css" media="print" rel="stylesheet" type="text/css" /> */
@@ -0,0 +1,9 @@
1
+ /* Welcome to Compass.
2
+ * In this file you should write your main styles. (or centralize your imports)
3
+ * Import this file using the following HTML or equivalent:
4
+ * <link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" /> */
5
+
6
+ @import "compass/reset";
7
+ .testClass {
8
+ background: red;
9
+ }
@@ -0,0 +1,5 @@
1
+ /* Welcome to Compass. Use this file to write IE specific override styles.
2
+ * Import this file using the following HTML or equivalent:
3
+ * <!--[if IE]>
4
+ * <link href="/stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
5
+ * <![endif]--> */
@@ -0,0 +1,3 @@
1
+ /* Welcome to Compass. Use this file to define print styles.
2
+ * Import this file using the following HTML or equivalent:
3
+ * <link href="/stylesheets/print.css" media="print" rel="stylesheet" type="text/css" /> */
@@ -0,0 +1,68 @@
1
+ /* Welcome to Compass.
2
+ * In this file you should write your main styles. (or centralize your imports)
3
+ * Import this file using the following HTML or equivalent:
4
+ * <link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" /> */
5
+ /* line 17, ../../../../.rvm/gems/ruby-1.9.3-p392@high_five/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
6
+ html, body, div, span, applet, object, iframe,
7
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8
+ a, abbr, acronym, address, big, cite, code,
9
+ del, dfn, em, img, ins, kbd, q, s, samp,
10
+ small, strike, strong, sub, sup, tt, var,
11
+ b, u, i, center,
12
+ dl, dt, dd, ol, ul, li,
13
+ fieldset, form, label, legend,
14
+ table, caption, tbody, tfoot, thead, tr, th, td,
15
+ article, aside, canvas, details, embed,
16
+ figure, figcaption, footer, header, hgroup,
17
+ menu, nav, output, ruby, section, summary,
18
+ time, mark, audio, video {
19
+ margin: 0;
20
+ padding: 0;
21
+ border: 0;
22
+ font: inherit;
23
+ font-size: 100%;
24
+ vertical-align: baseline;
25
+ }
26
+
27
+ /* line 22, ../../../../.rvm/gems/ruby-1.9.3-p392@high_five/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
28
+ html {
29
+ line-height: 1;
30
+ }
31
+
32
+ /* line 24, ../../../../.rvm/gems/ruby-1.9.3-p392@high_five/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
33
+ ol, ul {
34
+ list-style: none;
35
+ }
36
+
37
+ /* line 26, ../../../../.rvm/gems/ruby-1.9.3-p392@high_five/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
38
+ table {
39
+ border-collapse: collapse;
40
+ border-spacing: 0;
41
+ }
42
+
43
+ /* line 28, ../../../../.rvm/gems/ruby-1.9.3-p392@high_five/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
44
+ caption, th, td {
45
+ text-align: left;
46
+ font-weight: normal;
47
+ vertical-align: middle;
48
+ }
49
+
50
+ /* line 30, ../../../../.rvm/gems/ruby-1.9.3-p392@high_five/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
51
+ q, blockquote {
52
+ quotes: none;
53
+ }
54
+ /* line 103, ../../../../.rvm/gems/ruby-1.9.3-p392@high_five/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
55
+ q:before, q:after, blockquote:before, blockquote:after {
56
+ content: "";
57
+ content: none;
58
+ }
59
+
60
+ /* line 32, ../../../../.rvm/gems/ruby-1.9.3-p392@high_five/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
61
+ a img {
62
+ border: none;
63
+ }
64
+
65
+ /* line 116, ../../../../.rvm/gems/ruby-1.9.3-p392@high_five/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */
66
+ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary {
67
+ display: block;
68
+ }
data/spec/init_spec.rb CHANGED
@@ -7,7 +7,6 @@ describe "InitTask" do
7
7
  @original_dir = Dir.pwd
8
8
  @project_root = Dir.mktmpdir("hi5")
9
9
  Dir.chdir @project_root
10
- HighFive::ROOT = @project_root
11
10
  end
12
11
 
13
12
  after :each do
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,7 @@ require 'high_five/cli'
6
6
  # loaded once.
7
7
  #
8
8
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
9
+
9
10
  RSpec.configure do |config|
10
11
  config.treat_symbols_as_metadata_keys_with_true_values = true
11
12
  config.run_all_when_everything_filtered = true
@@ -17,3 +18,9 @@ RSpec.configure do |config|
17
18
  # --seed 1234
18
19
  config.order = 'random'
19
20
  end
21
+
22
+ RSpec::Matchers.define :exist do
23
+ match do |actual|
24
+ File.exists?(actual)
25
+ end
26
+ 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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -121,6 +121,20 @@ files:
121
121
  - lib/high_five/version.rb
122
122
  - spec/config_spec.rb
123
123
  - spec/deploy_spec.rb
124
+ - spec/dummy/config.rb
125
+ - spec/dummy/config/high_five.rb
126
+ - spec/dummy/config/high_five/app-android.js
127
+ - spec/dummy/config/high_five/app-common.js
128
+ - spec/dummy/config/high_five/app-ios.js
129
+ - spec/dummy/config/high_five/index.html.erb
130
+ - spec/dummy/javascripts/app.js
131
+ - spec/dummy/javascripts/app/component.js
132
+ - spec/dummy/sass/ie.scss
133
+ - spec/dummy/sass/print.scss
134
+ - spec/dummy/sass/screen.scss
135
+ - spec/dummy/stylesheets/ie.css
136
+ - spec/dummy/stylesheets/print.css
137
+ - spec/dummy/stylesheets/screen.css
124
138
  - spec/init_spec.rb
125
139
  - spec/spec_helper.rb
126
140
  - template/config/high_five.rb
@@ -155,5 +169,19 @@ summary: HighFive is a set of build scripts and tools for packing HTML5 apps bot
155
169
  test_files:
156
170
  - spec/config_spec.rb
157
171
  - spec/deploy_spec.rb
172
+ - spec/dummy/config.rb
173
+ - spec/dummy/config/high_five.rb
174
+ - spec/dummy/config/high_five/app-android.js
175
+ - spec/dummy/config/high_five/app-common.js
176
+ - spec/dummy/config/high_five/app-ios.js
177
+ - spec/dummy/config/high_five/index.html.erb
178
+ - spec/dummy/javascripts/app.js
179
+ - spec/dummy/javascripts/app/component.js
180
+ - spec/dummy/sass/ie.scss
181
+ - spec/dummy/sass/print.scss
182
+ - spec/dummy/sass/screen.scss
183
+ - spec/dummy/stylesheets/ie.css
184
+ - spec/dummy/stylesheets/print.css
185
+ - spec/dummy/stylesheets/screen.css
158
186
  - spec/init_spec.rb
159
187
  - spec/spec_helper.rb