high_five 0.0.5 → 0.0.6

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/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --color
2
- --format progress
2
+ --format nested
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- high_five (0.0.4)
4
+ high_five (0.0.6)
5
5
  compass (~> 0.12.2)
6
+ json
6
7
  sprockets (~> 2.9.0)
7
8
  thor (~> 0.17.0)
8
9
  yui-compressor (~> 0.9.6)
@@ -14,14 +15,15 @@ GEM
14
15
  Platform (>= 0.4.0)
15
16
  open4
16
17
  Platform (0.4.0)
17
- chunky_png (1.2.7)
18
+ chunky_png (1.2.8)
18
19
  compass (0.12.2)
19
20
  chunky_png (~> 1.2)
20
21
  fssm (>= 0.2.7)
21
22
  sass (~> 3.1)
22
23
  diff-lcs (1.2.1)
23
24
  fssm (0.2.10)
24
- hike (1.2.1)
25
+ hike (1.2.2)
26
+ json (1.7.7)
25
27
  multi_json (1.7.2)
26
28
  open4 (1.3.0)
27
29
  rack (1.5.2)
@@ -34,13 +36,13 @@ GEM
34
36
  diff-lcs (>= 1.1.3, < 2.0)
35
37
  rspec-mocks (2.13.0)
36
38
  sass (3.2.7)
37
- sprockets (2.9.0)
39
+ sprockets (2.9.2)
38
40
  hike (~> 1.2)
39
41
  multi_json (~> 1.0)
40
42
  rack (~> 1.0)
41
43
  tilt (~> 1.1, != 1.3.0)
42
44
  thor (0.17.0)
43
- tilt (1.3.6)
45
+ tilt (1.3.7)
44
46
  yui-compressor (0.9.6)
45
47
  POpen4 (>= 0.1.4)
46
48
 
data/high_five.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency "compass", "~>0.12.2"
20
20
  s.add_runtime_dependency "yui-compressor", "~>0.9.6"
21
21
  s.add_runtime_dependency "sprockets", "~>2.9.0"
22
+ s.add_runtime_dependency "json"
22
23
  s.add_development_dependency "rspec", "~>2.13.0"
23
24
 
24
25
  s.files = `git ls-files`.split("\n")
@@ -1,3 +1,4 @@
1
+ require 'json'
1
2
  module HighFive
2
3
  class Config
3
4
  attr_accessor :root, # Root of the project
@@ -9,7 +10,10 @@ module HighFive
9
10
  :static_stylesheets,
10
11
  :sass_files,
11
12
  :asset_paths,
12
- :compass_dir
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
13
17
 
14
18
 
15
19
  def self.configure(&block)
@@ -47,6 +51,12 @@ module HighFive
47
51
  new_config.sass_files += self.sass_files
48
52
  new_config.asset_paths += self.asset_paths
49
53
  new_config.compass_dir ||= self.compass_dir
54
+ new_config.js_settings.merge! self.js_settings do |key, new_setting, old_setting|
55
+ new_setting || old_setting #don't clobber settings from the parent
56
+ end
57
+ new_config.platform_configs = @platform_configs.reject do |key, platform_config|
58
+ key == platform
59
+ end
50
60
  return new_config
51
61
  else
52
62
  return self
@@ -61,6 +71,7 @@ module HighFive
61
71
  @sass_files = config.sass_files.dup
62
72
  @meta = config.meta.dup
63
73
  @asset_paths = config.asset_paths.dup
74
+ @js_settings = config.js_settings.dup
64
75
  self.root = config.root
65
76
  self.destination = config.destination
66
77
  self.page_title = config.page_title
@@ -73,7 +84,9 @@ module HighFive
73
84
  @meta = {}
74
85
  @platform_configs = {}
75
86
  @asset_paths = []
87
+ @js_settings = {}
76
88
  end
89
+ @is_environment = false
77
90
  end
78
91
 
79
92
  def assets(path)
@@ -100,5 +113,22 @@ module HighFive
100
113
  @platform_configs[name.to_s] = HighFive::Config.new
101
114
  yield @platform_configs[name.to_s]
102
115
  end
116
+
117
+ def environment(name, &block)
118
+ platform(name, &block)
119
+ @platform_configs[name.to_s].is_environment = true
120
+ end
121
+
122
+ def setting(hash)
123
+ @js_settings.merge!(hash)
124
+ end
125
+ alias settings setting
126
+
127
+ def high_five_javascript
128
+ js = '<script type="text/javascript">'
129
+ js += "if(typeof(window.HighFive)==='undefined'){window.HighFive={};}window.HighFive.Settings=#{JSON.dump(js_settings)};"
130
+ js += '</script>'
131
+ js
132
+ end
103
133
  end
104
134
  end
@@ -17,7 +17,7 @@ module HighFive
17
17
  @weinre_url = options[:weinre_url]
18
18
  @copy_files = options[:"copy-files"]
19
19
  @meta = {}
20
- @config = base_config.build_platform_config(@platform)
20
+ @config = base_config.build_platform_config(@platform).build_platform_config(@environment)
21
21
  @config_root = File.join("config", "high_five")
22
22
 
23
23
  self.source_paths << File.join(base_config.root, @config_root)
@@ -117,6 +117,7 @@ module HighFive
117
117
  end
118
118
  end
119
119
 
120
+ @high_five_javascript = @config.high_five_javascript
120
121
  # Build index.html
121
122
  say "Generating index.html"
122
123
  template File.join(@config_root, "index.html.erb"), File.join(self.destination_root, "index.html")
@@ -1,3 +1,3 @@
1
1
  module HighFive
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/spec/config_spec.rb CHANGED
@@ -19,4 +19,63 @@ describe HighFive::Config do
19
19
  end
20
20
  end
21
21
 
22
+ context "settings" do
23
+ before do
24
+ HighFive::Config.configure do |config|
25
+ config.root = "/"
26
+ config.setting base_url: "http://example.com/api"
27
+ config.environment :production do |production|
28
+ production.setting base_url: "http://production.example.com/api"
29
+ end
30
+ end
31
+ @config = HighFive::Config.instance
32
+ end
33
+
34
+ it "should serialize all the settings to json" do
35
+ @config.high_five_javascript.should eq %q(<script type="text/javascript">if(typeof(window.HighFive)==='undefined'){window.HighFive={};}window.HighFive.Settings={"base_url":"http://example.com/api"};</script>)
36
+ end
37
+
38
+ example "platform settings should take precedence" do
39
+ prod = @config.build_platform_config :production
40
+ prod.js_settings[:base_url].should eq "http://production.example.com/api"
41
+ end
42
+
43
+ end
44
+
45
+ context "environment configuration" do
46
+ before do
47
+ HighFive::Config.configure do |config|
48
+ config.root = "/"
49
+ config.setting base_url: "http://example.com/api"
50
+ config.platform :android do |android|
51
+ android.assets "android_asset"
52
+ android.setting android_flag: true
53
+ end
54
+ config.environment :production do |production|
55
+ production.assets "production_asset"
56
+ production.setting base_url: "http://production.example.com/api"
57
+ end
58
+ end
59
+ @config = HighFive::Config.instance
60
+ end
61
+
62
+ it "inherits from platforms" do
63
+ config = @config.build_platform_config(:android).build_platform_config(:production)
64
+ config.static_assets.should include "android_asset"
65
+ config.static_assets.should include "production_asset"
66
+ end
67
+
68
+ it "doesn't care about the inherit order" do
69
+ config = @config.build_platform_config(:production).build_platform_config(:android)
70
+ config.static_assets.should include "android_asset"
71
+ config.static_assets.should include "production_asset"
72
+ end
73
+
74
+ it "merges settings" do
75
+ config = @config.build_platform_config(:android).build_platform_config(:production)
76
+ config.js_settings.should be_has_key(:base_url)
77
+ config.js_settings.should be_has_key(:android_flag)
78
+ end
79
+ end
80
+
22
81
  end
@@ -16,6 +16,7 @@
16
16
  </script>
17
17
  <% end -%>
18
18
  <% end -%>
19
+ <%= @high_five_javascript %>
19
20
  <%- @javascripts.each do |js| -%>
20
21
  <script type="text/javascript" src="<%= js %>"></script>
21
22
  <%- end -%>
@@ -11,6 +11,16 @@ HighFive::Config.configure do |config|
11
11
  # config.javascripts "http://maps.google.com/maps/api/js?sensor=true"
12
12
  # config.javascripts "lib/jquery-min.js"
13
13
 
14
+ # Run `compass compile` in this directory before doing anything
15
+ # config.compass "resources/sass"
16
+
17
+ # copy and include these stylesheets in the html
18
+ # config.stylesheets "resources/css/app.css"
19
+ # config.stylesheets "resources/css/jquery-ui.css"
20
+
21
+ # Basic key/value settings that will be available to your javascript
22
+ # config.setting base_url: "http://dev.example.com/api" # HighFive.settings.base_url = "http://dev.example.com/api"
23
+
14
24
  # Configure plaform specific settings like this
15
25
  # config.platform :ios do |ios|
16
26
  # ios.assets "resources/ios"
@@ -18,6 +28,14 @@ HighFive::Config.configure do |config|
18
28
  # end
19
29
 
20
30
  # if you need platform-specific javascripts,
21
- # simply create app-<platform>.js next too app.js
31
+ # simply create app-<platform>.js
32
+ # these files are managed by sprockets, and are used to determine the javascript include order
33
+
34
+ # Environment support: production/development/etc
35
+ # Environments work just like platforms
36
+ # config.environment :production do |prod|
37
+ # production.javascripts "settings/production.js"
38
+ # production.setting base_url: "http://production.example.com/api/" #these take precedence over the platform overrides
39
+ # end
22
40
 
23
41
  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.5
4
+ version: 0.0.6
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-17 00:00:00.000000000 Z
12
+ date: 2013-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 2.9.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: json
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: rspec
80
96
  requirement: !ruby/object:Gem::Requirement