Class: Mumuki::Domain::Store::Thesaurus::InfoConverter
- Inherits:
-
Object
- Object
- Mumuki::Domain::Store::Thesaurus::InfoConverter
- Defined in:
- lib/mumuki/domain/store/thesaurus.rb
Instance Method Summary collapse
- #absolutize(urls) ⇒ Object
- #call ⇒ Object
- #feature_present?(feature) ⇒ Boolean
- #get_asset_field(kind, field) ⇒ Object
- #get_assets_for(kind, content_type) ⇒ Object
-
#initialize(runner_url, info) ⇒ InfoConverter
constructor
A new instance of InfoConverter.
- #shows_loading_content_for?(kind) ⇒ Boolean
Constructor Details
#initialize(runner_url, info) ⇒ InfoConverter
Returns a new instance of InfoConverter.
28 29 30 31 |
# File 'lib/mumuki/domain/store/thesaurus.rb', line 28 def initialize(runner_url, info) @runner_url = runner_url @info = info end |
Instance Method Details
#absolutize(urls) ⇒ Object
76 77 78 |
# File 'lib/mumuki/domain/store/thesaurus.rb', line 76 def absolutize(urls) urls.map { |url| "#{@runner_url}/#{url}"} end |
#call ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mumuki/domain/store/thesaurus.rb', line 33 def call { name: @info['name'], comment_type: @info['comment_type'], runner_url: @runner_url, output_content_type: @info['output_content_type'], prompt: (@info.dig('language', 'prompt') || 'ム') + ' ', extension: @info.dig('language', 'extension'), highlight_mode: @info.dig('language', 'ace_mode'), visible_success_output: @info.dig('language', 'graphic').present?, devicon: @info.dig('language', 'icon', 'name'), expectations: feature_present?('expectations'), feedback: feature_present?('feedback'), multifile: feature_present?('multifile'), queriable: feature_present?('query'), settings: feature_present?('settings'), stateful_console: feature_present?('stateful'), triable: feature_present?('try'), test_extension: @info.dig('test_framework', 'test_extension'), test_template: @info.dig('test_framework', 'template'), layout_js_urls: get_assets_for(:layout, 'js'), layout_html_urls: get_assets_for(:layout, 'html'), layout_css_urls: get_assets_for(:layout, 'css'), editor_js_urls: get_assets_for(:editor, 'js'), editor_html_urls: get_assets_for(:editor, 'html'), editor_css_urls: get_assets_for(:editor, 'css'), layout_shows_loading_content: shows_loading_content_for?(:layout), editor_shows_loading_content: shows_loading_content_for?(:editor) } end |
#feature_present?(feature) ⇒ Boolean
64 65 66 |
# File 'lib/mumuki/domain/store/thesaurus.rb', line 64 def feature_present?(feature) @info.dig('features', feature).present? end |
#get_asset_field(kind, field) ⇒ Object
72 73 74 |
# File 'lib/mumuki/domain/store/thesaurus.rb', line 72 def get_asset_field(kind, field) @info.dig("#{kind}_assets_urls", field) end |
#get_assets_for(kind, content_type) ⇒ Object
68 69 70 |
# File 'lib/mumuki/domain/store/thesaurus.rb', line 68 def get_assets_for(kind, content_type) absolutize(get_asset_field(kind, content_type) || []) end |
#shows_loading_content_for?(kind) ⇒ Boolean
80 81 82 |
# File 'lib/mumuki/domain/store/thesaurus.rb', line 80 def shows_loading_content_for?(kind) get_asset_field(kind, 'shows_loading_content').present? end |