Class: ZendeskAppsSupport::Package
- Inherits:
-
Object
- Object
- ZendeskAppsSupport::Package
- Defined in:
- lib/zendesk_apps_support/package.rb
Constant Summary collapse
- DEFAULT_LAYOUT =
Erubis::Eruby.new( File.read(File.('../assets/default_template.html.erb', __FILE__)) )
- DEFAULT_SCSS =
File.read(File.('../assets/default_styles.scss', __FILE__))
- SRC_TEMPLATE =
Erubis::Eruby.new( File.read(File.('../assets/src.js.erb', __FILE__)) )
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
- #customer_css ⇒ Object
- #files ⇒ Object
-
#initialize(dir) ⇒ Package
constructor
A new instance of Package.
- #manifest_json ⇒ Object
- #readified_js(app_name, app_id, asset_url_prefix, settings = {}) ⇒ Object
- #template_files ⇒ Object
- #translation_files ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(dir) ⇒ Package
Returns a new instance of Package.
14 15 16 17 |
# File 'lib/zendesk_apps_support/package.rb', line 14 def initialize(dir) @root = Pathname.new(File.(dir)) @warnings = [] end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
12 13 14 |
# File 'lib/zendesk_apps_support/package.rb', line 12 def root @root end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
12 13 14 |
# File 'lib/zendesk_apps_support/package.rb', line 12 def warnings @warnings end |
Instance Method Details
#customer_css ⇒ Object
71 72 73 74 |
# File 'lib/zendesk_apps_support/package.rb', line 71 def customer_css css_file = File.join(root, 'app.css') customer_css = File.exist?(css_file) ? File.read(css_file) : "" end |
#files ⇒ Object
27 28 29 |
# File 'lib/zendesk_apps_support/package.rb', line 27 def files non_tmp_files end |
#manifest_json ⇒ Object
39 40 41 |
# File 'lib/zendesk_apps_support/package.rb', line 39 def manifest_json JSON.parse(File.read(File.join(root, "manifest.json")), :symbolize_names => true) end |
#readified_js(app_name, app_id, asset_url_prefix, settings = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/zendesk_apps_support/package.rb', line 43 def readified_js(app_name, app_id, asset_url_prefix, settings={}) manifest = manifest_json source = File.read(File.join(root, "app.js")) name = app_name || manifest[:name] || 'Local App' location = manifest[:location] app_class_name = "app-#{app_id}" = manifest[:author] translations = JSON.parse(File.read(File.join(root, "translations/en.json"))) framework_version = manifest[:frameworkVersion] templates = manifest[:noTemplate] ? {} : compiled_templates(app_id, asset_url_prefix) settings["title"] = name SRC_TEMPLATE.result( :name => name, :source => source, :location => location, :asset_url_prefix => asset_url_prefix, :app_class_name => app_class_name, :author => , :translations => translations, :framework_version => framework_version, :templates => templates, :settings => settings, :app_id => app_id ) end |
#template_files ⇒ Object
31 32 33 |
# File 'lib/zendesk_apps_support/package.rb', line 31 def template_files files.select { |f| f =~ /^templates\/.*\.hdbs$/ } end |
#translation_files ⇒ Object
35 36 37 |
# File 'lib/zendesk_apps_support/package.rb', line 35 def translation_files files.select { |f| f =~ /^translations\// } end |
#validate ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/zendesk_apps_support/package.rb', line 19 def validate Validations::Manifest.call(self) + Validations::Source.call(self) + Validations::Templates.call(self) + Validations::Translations.call(self) + Validations::Stylesheets.call(self) end |