Class: Tonka::JS
- Inherits:
-
Object
- Object
- Tonka::JS
- Defined in:
- lib/tonka.rb
Instance Attribute Summary collapse
-
#layout ⇒ Object
CSS processing module.
-
#libraries ⇒ Object
CSS processing module.
-
#script_tag ⇒ Object
CSS processing module.
Class Method Summary collapse
Instance Method Summary collapse
- #generate_file(file_name) ⇒ Object
-
#initialize(file_name, options = []) ⇒ JS
constructor
A new instance of JS.
Constructor Details
#initialize(file_name, options = []) ⇒ JS
Returns a new instance of JS.
266 267 268 |
# File 'lib/tonka.rb', line 266 def initialize(file_name,=[]) @script_tag = generate_file(file_name) end |
Instance Attribute Details
#layout ⇒ Object
CSS processing module
251 252 253 |
# File 'lib/tonka.rb', line 251 def layout @layout end |
#libraries ⇒ Object
CSS processing module
251 252 253 |
# File 'lib/tonka.rb', line 251 def libraries @libraries end |
#script_tag ⇒ Object
CSS processing module
251 252 253 |
# File 'lib/tonka.rb', line 251 def script_tag @script_tag end |
Class Method Details
.libraries ⇒ Object
253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/tonka.rb', line 253 def self.libraries [ {"jquery" => "http://code.jquery.com/jquery-1.11.1.min.js"}, {"underscore" => "http://underscorejs.org/underscore-min.js"}, {"backbone" => "http://backbonejs.org/backbone-min.js"}, {"handlebars" => "http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"}, {"d3" => "http://d3js.org/d3.v3.min.js"}, {"raphael" => "http://cdn.rawgit.com/DmitryBaranovskiy/raphael/master/raphael-min.js"}, {"angular" => "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.13/angular.min.js"}, {"bootstrap" => "http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"} ] end |
Instance Method Details
#generate_file(file_name) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/tonka.rb', line 270 def generate_file(file_name) js_file = File.new("#{$SITE_NAME}/javascripts/#{file_name}.js","w") if file_name == "app" js_file_content = "console.log('feed me javascripts')" else uri = '' Tonka::JS.libraries.each do |library| uri = library[file_name] if library[file_name] end js_file_content = Net::HTTP.get(URI(uri)) end js_file.puts js_file_content js_file.close script_tag = "\t<script src='javascripts/#{file_name}.js'></script>\n" puts "\t\tbuilt ".green+"#{$SITE_NAME}/javascripts/#{file_name}.js" return script_tag end |