Class: HighFive::Config
- Inherits:
-
Object
- Object
- HighFive::Config
- Defined in:
- lib/high_five/config.rb
Instance Attribute Summary collapse
-
#asset_paths ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }.
-
#is_environment ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }.
-
#js_settings ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }.
-
#meta ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }.
-
#platform_configs ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }.
-
#sass_files ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }.
-
#static_assets ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }.
-
#static_javascripts ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }.
-
#static_stylesheets ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }.
Class Method Summary collapse
-
.config_setting(*settings) ⇒ Object
shorthand for me to define lots and lots of config settings that need to be handled as attr_accessible, settable via setting(blah) instead of settings=blah, and also persisted to derived platform configs.
-
.configure {|@@instance| ... } ⇒ Object
ios target to be used by dist tasks.
- .instance ⇒ Object
- .load ⇒ Object
Instance Method Summary collapse
- #assets(path, options = {}) ⇒ Object
- #build_platform_config(platform) ⇒ Object
- #environment(name, &block) ⇒ Object
- #high_five_javascript ⇒ Object
-
#initialize(config = nil) ⇒ Config
constructor
A new instance of Config.
- #javascripts(path) ⇒ Object
- #platform(name) {|| ... } ⇒ Object
- #sass(path) ⇒ Object
- #setting(hash) ⇒ Object (also: #settings)
- #stylesheets(path) ⇒ Object
- #windows! ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ Config
Returns a new instance of Config.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/high_five/config.rb', line 97 def initialize(config=nil) if config @static_assets = config.static_assets.dup @static_javascripts = config.static_javascripts.dup @static_stylesheets = config.static_stylesheets.dup @sass_files = config.sass_files.dup @meta = config..dup @asset_paths = config.asset_paths.dup @js_settings = config.js_settings.dup self.root = config.root self.destination = config.destination self.dev_index = config.dev_index self.page_title = config.page_title self. = config. self.minify = config.minify self.manifest = config.manifest @@config_variables.each do |svar| if (self.instance_variable_get(svar).nil?) self.instance_variable_set(svar, config.instance_variable_get(svar)) end end else @static_assets = [] @static_javascripts = [] @static_stylesheets = [] @sass_files = [] @meta = {} @platform_configs = {} @asset_paths = [] @js_settings = {} end @is_environment = false end |
Instance Attribute Details
#asset_paths ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }
4 5 6 |
# File 'lib/high_five/config.rb', line 4 def asset_paths @asset_paths end |
#is_environment ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }
4 5 6 |
# File 'lib/high_five/config.rb', line 4 def is_environment @is_environment end |
#js_settings ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }
4 5 6 |
# File 'lib/high_five/config.rb', line 4 def js_settings @js_settings end |
#meta ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }
4 5 6 |
# File 'lib/high_five/config.rb', line 4 def @meta end |
#platform_configs ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }
4 5 6 |
# File 'lib/high_five/config.rb', line 4 def platform_configs @platform_configs end |
#sass_files ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }
4 5 6 |
# File 'lib/high_five/config.rb', line 4 def sass_files @sass_files end |
#static_assets ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }
4 5 6 |
# File 'lib/high_five/config.rb', line 4 def static_assets @static_assets end |
#static_javascripts ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }
4 5 6 |
# File 'lib/high_five/config.rb', line 4 def static_javascripts @static_javascripts end |
#static_stylesheets ⇒ Object
config.meta << { http-equiv: “Content-Type” content: “text/html; charset=utf-8” }
4 5 6 |
# File 'lib/high_five/config.rb', line 4 def static_stylesheets @static_stylesheets end |
Class Method Details
.config_setting(*settings) ⇒ Object
shorthand for me to define lots and lots of config settings that need to be handled as attr_accessible, settable via setting(blah) instead of settings=blah, and also persisted to derived platform configs
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/high_five/config.rb', line 18 def self.config_setting(*settings) config_variables = [] settings.each do |setting| attr_accessor setting var = "@#{setting}".to_sym config_variables << var define_method setting do |*args| instance_variable_set(var, args[0]) if args.length == 1 instance_variable_get(var) end end @@config_variables = config_variables end |
.configure {|@@instance| ... } ⇒ Object
ios target to be used by dist tasks
46 47 48 49 50 51 52 53 |
# File 'lib/high_five/config.rb', line 46 def self.configure(&block) @@instance = HighFive::Config.new yield @@instance if @@instance.root.nil? raise "HighFive::Config.root is required" end end |
.instance ⇒ Object
64 65 66 |
# File 'lib/high_five/config.rb', line 64 def self.instance @@instance end |
.load ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/high_five/config.rb', line 55 def self.load begin require File.join(Dir.pwd, "config", "high_five.rb") rescue LoadError raise "high_five configuration not found, forgot to run 'hi5 init'?" end return @@instance end |
Instance Method Details
#assets(path, options = {}) ⇒ Object
131 132 133 |
# File 'lib/high_five/config.rb', line 131 def assets(path, ={}) @static_assets << [path.dup, .dup] end |
#build_platform_config(platform) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/high_five/config.rb', line 68 def build_platform_config(platform) if @platform_configs[platform.to_s] new_config = HighFive::Config.new(@platform_configs[platform.to_s]) new_config.root ||= self.root new_config.destination ||= self.destination new_config. ||= self. new_config.page_title ||= self.page_title new_config.static_assets += self.static_assets new_config.static_javascripts += self.static_javascripts new_config.static_stylesheets += self.static_stylesheets new_config.sass_files += self.sass_files new_config.asset_paths += self.asset_paths @@config_variables.each do |svar| if (new_config.instance_variable_get(svar).nil?) new_config.instance_variable_set(svar, self.instance_variable_get(svar)) end end new_config.js_settings.merge! self.js_settings do |key, new_setting, old_setting| new_setting || old_setting #don't clobber settings from the parent end new_config.platform_configs = @platform_configs.reject do |key, platform_config| key == platform end return new_config else return self end end |
#environment(name, &block) ⇒ Object
152 153 154 155 156 157 158 159 |
# File 'lib/high_five/config.rb', line 152 def environment(name, &block) platform(name, &block) platform_config = @platform_configs[name.to_s] platform_config.is_environment = true if (name.to_s == 'production') platform_config.minify = :uglifier if platform_config.minify.nil? end end |
#high_five_javascript ⇒ Object
166 167 168 169 170 171 |
# File 'lib/high_five/config.rb', line 166 def high_five_javascript js = '<script type="text/javascript">' js += "if(typeof(window.HighFive)==='undefined'){window.HighFive={};}window.HighFive.Settings=#{MultiJson.dump(js_settings)};" js += '</script>' js end |
#javascripts(path) ⇒ Object
135 136 137 |
# File 'lib/high_five/config.rb', line 135 def javascripts(path) @static_javascripts << path.dup end |
#platform(name) {|| ... } ⇒ Object
147 148 149 150 |
# File 'lib/high_five/config.rb', line 147 def platform(name, &block) @platform_configs[name.to_s] = HighFive::Config.new yield @platform_configs[name.to_s] end |
#sass(path) ⇒ Object
139 140 141 |
# File 'lib/high_five/config.rb', line 139 def sass(path) @sass_files << path.dup end |
#setting(hash) ⇒ Object Also known as: settings
161 162 163 |
# File 'lib/high_five/config.rb', line 161 def setting(hash) @js_settings.merge!(hash) end |
#stylesheets(path) ⇒ Object
143 144 145 |
# File 'lib/high_five/config.rb', line 143 def stylesheets(path) @static_stylesheets << path.dup end |
#windows! ⇒ Object
173 174 175 176 177 |
# File 'lib/high_five/config.rb', line 173 def windows! ExecJS::Runtimes::JScript.instance_variable_set(:"@encoding", "UTF-8") ExecJS::Runtimes::JScript.instance_variable_set(:"@command", "cscript //E:jscript //Nologo") ExecJS::Runtimes::JScript.instance_variable_set(:"@binary", "cscript //E:jscript //Nologo") end |