Class: Language
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Syncable
#platform_class_name
aggregate_of, all_except, defaults, numbered, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, #update_and_notify!, update_or_create!, whitelist_attributes
Class Method Details
.for_name(name) ⇒ Object
31
32
33
|
# File 'app/models/language.rb', line 31
def self.for_name(name)
find_by_ignore_case!(:name, name) if name
end
|
Instance Method Details
#assets_urls_for(kind, content_type) ⇒ Object
53
54
55
|
# File 'app/models/language.rb', line 53
def assets_urls_for(kind, content_type)
send "#{kind}_#{content_type}_urls"
end
|
#bridge ⇒ Object
15
16
17
|
# File 'app/models/language.rb', line 15
def bridge
Mumukit::Bridge::Runner.new(runner_url)
end
|
#devicon ⇒ Object
35
36
37
|
# File 'app/models/language.rb', line 35
def devicon
self[:devicon] || name.downcase
end
|
#directives_sections ⇒ Object
48
49
50
|
# File 'app/models/language.rb', line 48
def directives_sections
new_directive Mumukit::Directives::Sections
end
|
#highlight_mode ⇒ Object
19
20
21
|
# File 'app/models/language.rb', line 19
def highlight_mode
self[:highlight_mode] || name
end
|
#import_from_resource_h!(resource_h) ⇒ Object
43
44
45
46
|
# File 'app/models/language.rb', line 43
def import_from_resource_h!(resource_h)
assign_attributes resource_h.except(:runner_url)
save!
end
|
#interpolate_references_for(assignment, field) ⇒ Object
TODO this should be a Mumukit::Directives::Directive and be part of a pipeline
59
60
61
|
# File 'app/models/language.rb', line 59
def interpolate_references_for(assignment, field)
interpolate(field, assignment.submitter.interpolations, lambda { |content| replace_content_reference(assignment, content) })
end
|
#output_content_type ⇒ Object
23
24
25
|
# File 'app/models/language.rb', line 23
def output_content_type
Mumukit::ContentType.for(self[:output_content_type])
end
|
#sync_key ⇒ Object
39
40
41
|
# File 'app/models/language.rb', line 39
def sync_key
Mumukit::Sync.key :language, runner_url
end
|
#to_embedded_resource_h ⇒ Object
63
64
65
|
# File 'app/models/language.rb', line 63
def to_embedded_resource_h
as_json(only: [:name, :extension, :test_extension]).symbolize_keys
end
|
#to_resource_h ⇒ Object
67
68
69
70
71
72
|
# File 'app/models/language.rb', line 67
def to_resource_h
as_json(only: %i(comment_type devicon editor_css_urls editor_html_urls editor_js_urls
extension feedback highlight_mode layout_css_urls layout_html_urls
layout_js_urls name output_content_type prompt queriable runner_url
stateful_console test_extension test_template triable visible_success_output)).symbolize_keys
end
|
#to_s ⇒ Object
27
28
29
|
# File 'app/models/language.rb', line 27
def to_s
name
end
|