Class: JsDuck::Web::Data
- Inherits:
-
Object
- Object
- JsDuck::Web::Data
- Defined in:
- lib/jsduck/web/data.rb
Overview
Creates big JS file with data for Docs app.
Instance Method Summary collapse
-
#initialize(relations, assets, opts) ⇒ Data
constructor
A new instance of Data.
-
#write(filename) ⇒ Object
Writes classes, guides, videos, and search data to one big .js file.
Constructor Details
#initialize(relations, assets, opts) ⇒ Data
Returns a new instance of Data.
12 13 14 15 16 |
# File 'lib/jsduck/web/data.rb', line 12 def initialize(relations, assets, opts) @relations = relations @assets = assets @opts = opts end |
Instance Method Details
#write(filename) ⇒ Object
Writes classes, guides, videos, and search data to one big .js file. Then Renames the file so it contains an MD5 hash inside it, returning the resulting fingerprinted name.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/jsduck/web/data.rb', line 21 def write(filename) js = "Docs = " + Util::Json.generate({ :data => { :classes => Web::Icons.new.create(@relations.classes), :guides => @assets.guides.to_array, :videos => @assets.videos.to_array, :examples => @assets.examples.to_array, :search => Web::Search.new.create(@relations.classes, @assets, @opts), :guideSearch => @opts.search, :tests => @opts.tests, :signatures => TagRegistry.signatures, :memberTypes => TagRegistry.member_types, :localStorageDb => @opts.local_storage_db, :showPrintButton => @opts.seo, :touchExamplesUi => @opts.touch_examples_ui, :source => @opts.source, :commentsUrl => @opts.comments_url, :commentsDomain => @opts.comments_domain, :message => @opts., } }) + ";\n" File.open(filename, 'w') {|f| f.write(js) } Util::MD5.rename(filename) end |