high_five 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- high_five (0.0.7)
4
+ high_five (0.0.8)
5
5
  compass (~> 0.12.2)
6
+ json (~> 1.7.7)
6
7
  sprockets (~> 2.9.0)
7
8
  thor (~> 0.17.0)
8
9
  uglifier (~> 2.1.1)
@@ -25,6 +26,7 @@ GEM
25
26
  multi_json (~> 1.0)
26
27
  fssm (0.2.10)
27
28
  hike (1.2.2)
29
+ json (1.7.7)
28
30
  multi_json (1.7.2)
29
31
  open4 (1.3.0)
30
32
  rack (1.5.2)
data/README.md CHANGED
@@ -1,7 +1,14 @@
1
1
  High Five
2
2
  =========
3
3
 
4
- HTML5 build/deploy tool, usually used with PhoneGap.
4
+ HTML5 build/deploy tool, usually used with PhoneGap but also for standalone web-based apps
5
+
6
+ Ruby
7
+ ====
8
+
9
+ If you're on Windows, you need both Ruby and the Dev tools. There is a great tutorial here:
10
+
11
+ https://github.com/oneclick/rubyinstaller/wiki/development-kit
5
12
 
6
13
  Installation
7
14
  ============
@@ -16,6 +23,8 @@ and also creating a few important files inside, most importantly high_five.rb.
16
23
  Configuration
17
24
  =============
18
25
 
26
+ ```hi5 init``` will create all the directories you need, and almost all of your configuration will happen inside of ```config/high_five.rb```. It is reasonably well documented and contains a lot of sensible defaults. I hope to improve the documentation here over time, but for now go read ```high_five.rb```
27
+
19
28
 
20
29
  Usage
21
30
  =====
data/high_five.gemspec CHANGED
@@ -20,8 +20,10 @@ Gem::Specification.new do |s|
20
20
  s.add_runtime_dependency "yui-compressor", "~>0.9.6"
21
21
  s.add_runtime_dependency "uglifier", "~>2.1.1"
22
22
  s.add_runtime_dependency "sprockets", "~>2.9.0"
23
+ s.add_runtime_dependency "json", '~> 1.7.7'
23
24
  s.add_development_dependency "rspec", "~>2.13.0"
24
25
 
26
+
25
27
  s.files = `git ls-files`.split("\n")
26
28
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
29
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -1,21 +1,41 @@
1
1
  require 'json'
2
2
  module HighFive
3
3
  class Config
4
- attr_accessor :root, # Root of the project
5
- :destination, # generated folder for project('www')
6
- :page_title, # <title>#{page_title}</title>
7
- :meta, # config.meta << { http-equiv: "Content-Type" content: "text/html; charset=utf-8" }
8
- :static_assets,
9
- :static_javascripts,
10
- :static_stylesheets,
11
- :sass_files,
12
- :asset_paths,
13
- :platform_configs,
14
- :compass_dir,
15
- :js_settings, #serialized out to HighFive.Settings in index.html
16
- :is_environment, #boolean for if this config is an environment platform
17
- :dev_index, #copy generated index.html to here on build for use in development
18
- :minify #defaults to true in production mode and false otherwise, overridable
4
+ attr_accessor :meta, # config.meta << { http-equiv: "Content-Type" content: "text/html; charset=utf-8" }
5
+ :static_assets,
6
+ :static_javascripts,
7
+ :static_stylesheets,
8
+ :sass_files,
9
+ :asset_paths,
10
+ :platform_configs,
11
+ :js_settings, #serialized out to HighFive.Settings in index.html
12
+ :is_environment #boolean for if this config is an environment platform
13
+
14
+
15
+ # shorthand for me to define lots and lots of config settings that need to be handled
16
+ # as attr_accessible, settable via setting(blah) instead of settings=blah, and also
17
+ # persisted to derived platform configs
18
+ def self.config_setting(*settings)
19
+ config_variables = []
20
+ settings.each do |setting|
21
+ attr_accessor setting
22
+ define_method setting do |*args|
23
+ var = "@#{setting}".to_sym
24
+ config_variables << var
25
+ instance_variable_set(var, args[0]) if args.length == 1
26
+ instance_variable_get(var)
27
+ end
28
+ end
29
+ @@config_variables = config_variables
30
+ end
31
+
32
+ config_setting :root, # Root of the project
33
+ :destination, # generated folder for project('www')
34
+ :page_title, # <title>#{page_title}</title>
35
+ :compass_dir, # directory that contaings compass' config.rb
36
+ :dev_index, # copy generated index.html to here on build for use in development
37
+ :minify, # defaults to true in production mode and false otherwise, overridable
38
+ :manifest # generate html5 manifest
19
39
 
20
40
 
21
41
  def self.configure(&block)
@@ -52,9 +72,11 @@ module HighFive
52
72
  new_config.static_stylesheets += self.static_stylesheets
53
73
  new_config.sass_files += self.sass_files
54
74
  new_config.asset_paths += self.asset_paths
55
- new_config.compass_dir ||= self.compass_dir
56
- new_config.dev_index ||= self.dev_index
57
- new_config.minify ||= self.minify
75
+ @@config_variables.each do |svar|
76
+ if (new_config.instance_variable_get(svar).nil?)
77
+ new_config.instance_variable_set(svar, self.instance_variable_get(svar))
78
+ end
79
+ end
58
80
  new_config.js_settings.merge! self.js_settings do |key, new_setting, old_setting|
59
81
  new_setting || old_setting #don't clobber settings from the parent
60
82
  end
@@ -82,6 +104,12 @@ module HighFive
82
104
  self.page_title = config.page_title
83
105
  self.meta = config.meta
84
106
  self.minify = config.minify
107
+ self.manifest = config.manifest
108
+ @@config_variables.each do |svar|
109
+ if (self.instance_variable_get(svar).nil?)
110
+ self.instance_variable_set(svar, config.instance_variable_get(svar))
111
+ end
112
+ end
85
113
  else
86
114
  @static_assets = []
87
115
  @static_javascripts = []
@@ -107,10 +135,6 @@ module HighFive
107
135
  @sass_files << path.dup
108
136
  end
109
137
 
110
- def compass(config_dir)
111
- @compass_dir = config_dir
112
- end
113
-
114
138
  def stylesheets(path)
115
139
  @static_stylesheets << path.dup
116
140
  end
@@ -141,18 +165,5 @@ module HighFive
141
165
  js
142
166
  end
143
167
 
144
- #easy setters
145
-
146
- def dev_index(*args)
147
- if args.length == 1
148
- @dev_index = args[0]
149
- end
150
- @dev_index
151
- end
152
-
153
- def destination(*args)
154
- @destination = args[0] if args.length == 1
155
- @destination
156
- end
157
168
  end
158
169
  end
@@ -24,6 +24,8 @@ module HighFive
24
24
 
25
25
  self.source_paths << File.join(base_config.root, @config_root)
26
26
  self.source_paths << File.join(base_config.root)
27
+ self.source_paths << File.join(File.dirname(__FILE__), 'generators')
28
+
27
29
 
28
30
  raise "Please set config.destination" if @config.destination.nil?
29
31
  self.destination_root = @config.destination
@@ -40,8 +42,6 @@ module HighFive
40
42
  say "Precompiling compass styles from #{compass_dir}}"
41
43
  pwd = Dir.pwd
42
44
  Dir.chdir compass_dir
43
- # TODO make this invoke compass programatically
44
- # Consider using sprockets for css too, although I kindof hate that
45
45
  success = false
46
46
  if @environment == "production"
47
47
  success = system("compass compile --force --no-debug-info -e production")
@@ -132,6 +132,23 @@ module HighFive
132
132
  end
133
133
  end
134
134
 
135
+ if (@config.manifest && @environment == 'production')
136
+ @manifest_attr = %Q(manifest="manifest.appcache") #for <html manifest=>
137
+ say " create manifest", :green
138
+ @manifest_cache = @config.static_assets.collect do |path|
139
+ if (File.directory?(path))
140
+ Dir.glob(path + "/**/*")
141
+ else
142
+ path
143
+ end
144
+ end.flatten
145
+
146
+ @manifest_cache += @javascripts
147
+ @manifest_cache += @stylesheets
148
+
149
+ template "manifest.erb", File.join(self.destination_root, "manifest.appcache")
150
+ end
151
+
135
152
  @high_five_javascript = @config.high_five_javascript
136
153
  # Build index.html
137
154
  say "Generating index.html"
@@ -0,0 +1,16 @@
1
+ CACHE MANIFEST
2
+ # Generated by high_five v<%= HighFive::VERSION %>
3
+ # <%= Time.now %>
4
+
5
+ # Explicitly cached 'master entries'.
6
+ CACHE:
7
+ <% @manifest_cache.each do |path| -%>
8
+ <%= path %>
9
+ <% end -%>
10
+
11
+
12
+ # Resources that require the user to be online.
13
+ NETWORK:
14
+
15
+ # offline.html will be served in place of all other .html files
16
+ FALLBACK:
@@ -1,3 +1,3 @@
1
1
  module HighFive
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.0"
3
3
  end
data/spec/deploy_spec.rb CHANGED
@@ -109,6 +109,7 @@ describe HighFive::DeployTask do
109
109
  config.assets "stylesheets"
110
110
  config.platform :web do |web|
111
111
  config.dev_index "index-debug.html"
112
+ config.manifest = true
112
113
  end
113
114
  config.environment :production do |prod|
114
115
 
@@ -126,6 +127,9 @@ describe HighFive::DeployTask do
126
127
  it "should not clone index.html to index-debug.html" do
127
128
  File.exist?(File.join(@project_root, "index-debug.html")).should be_false
128
129
  end
130
+ it "should generate an html manifest" do
131
+ expect(File.join(@project_root, "www", "manifest.appcache")).to exist
132
+ end
129
133
  end
130
134
 
131
135
  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.8
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
93
  version: 2.9.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: json
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.7.7
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.7.7
94
110
  - !ruby/object:Gem::Dependency
95
111
  name: rspec
96
112
  requirement: !ruby/object:Gem::Requirement
@@ -128,13 +144,12 @@ files:
128
144
  - Rakefile
129
145
  - bin/hi5
130
146
  - high_five.gemspec
131
- - lib/.DS_Store
132
147
  - lib/high_five.rb
133
148
  - lib/high_five/android_tasks.rb
134
149
  - lib/high_five/cli.rb
135
150
  - lib/high_five/config.rb
136
151
  - lib/high_five/deploy_task.rb
137
- - lib/high_five/html_includes.html.erb
152
+ - lib/high_five/generators/manifest.erb
138
153
  - lib/high_five/init_task.rb
139
154
  - lib/high_five/version.rb
140
155
  - spec/config_spec.rb
data/lib/.DS_Store DELETED
Binary file
@@ -1 +0,0 @@
1
- html_includes.html.erb