Class: Mumukit::Sync::Store::Thesaurus::InfoConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/mumuki/domain/stores/thesaurus_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(runner_url, info) ⇒ InfoConverter

Returns a new instance of InfoConverter.



28
29
30
31
# File 'lib/mumuki/domain/stores/thesaurus_store.rb', line 28

def initialize(runner_url, info)
  @runner_url = runner_url
  @info = info
end

Instance Method Details

#absolutize(urls) ⇒ Object



70
71
72
# File 'lib/mumuki/domain/stores/thesaurus_store.rb', line 70

def absolutize(urls)
  urls.map { |url| "#{@runner_url}/#{url}"}
end

#callObject



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
# File 'lib/mumuki/domain/stores/thesaurus_store.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'),
    triable:                      @info.dig('features', 'try').present?,
    feedback:                     @info.dig('features', 'feedback').present?,
    queriable:                    @info.dig('features', 'query').present?,
    stateful_console:             @info.dig('features', 'stateful').present?,
    multifile:                    @info.dig('features', 'multifile').present?,
    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

#get_asset_field(kind, field) ⇒ Object



66
67
68
# File 'lib/mumuki/domain/stores/thesaurus_store.rb', line 66

def get_asset_field(kind, field)
  @info.dig("#{kind}_assets_urls", field)
end

#get_assets_for(kind, content_type) ⇒ Object



62
63
64
# File 'lib/mumuki/domain/stores/thesaurus_store.rb', line 62

def get_assets_for(kind, content_type)
  absolutize(get_asset_field(kind, content_type) || [])
end

#shows_loading_content_for?(kind) ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/mumuki/domain/stores/thesaurus_store.rb', line 74

def shows_loading_content_for?(kind)
  get_asset_field(kind, 'shows_loading_content').present?
end