Class: Tay::Specification
- Inherits:
-
Object
- Object
- Tay::Specification
- Defined in:
- lib/tay/specification.rb,
lib/tay/specification/action.rb,
lib/tay/specification/web_intent.rb,
lib/tay/specification/nacl_module.rb,
lib/tay/specification/page_action.rb,
lib/tay/specification/packaged_app.rb,
lib/tay/specification/browser_action.rb,
lib/tay/specification/content_script.rb
Overview
A tay specification helps you define the functionality that the extension provides. It also serves as the data source that it used to generate the manifest.json file.
Defined Under Namespace
Classes: Action, BrowserAction, ContentScript, NaClModule, PackagedApp, PageAction, WebIntent
Instance Attribute Summary collapse
-
#background_page ⇒ Object
Path to an HTML file that will be used as the background page.
-
#background_scripts ⇒ Object
An array javascript file paths that will run in the background.
-
#browser_action ⇒ Object
readonly
A Tay::Specification::BrowserAction or nil.
-
#content_scripts ⇒ Object
An array of Tay::Specification::ContentScript objects.
- #content_security_policy ⇒ Object
- #default_locale ⇒ Object
- #description ⇒ Object
- #homepage ⇒ Object
-
#icons ⇒ Object
An map of icon sizes to paths.
- #incognito_mode ⇒ Object
-
#javascripts ⇒ Object
An array of javascript paths that will be copied to the build.
-
#key_path ⇒ Object
Get the path to the private key for this extension.
-
#manifest_data ⇒ Object
If you set this to a hash, it will be merged on top of the generated manifest.
- #minimum_chrome_version ⇒ Object
-
#nacl_modules ⇒ Object
An array of Tay::Specification::NaClModule.
- #name ⇒ Object
- #offline_enabled ⇒ Object
- #omnibox_keyword ⇒ Object
- #options_page ⇒ Object
-
#overriden_pages ⇒ Object
readonly
A map of Chrome page types to HTML files.
-
#packaged_app ⇒ Object
readonly
A Tay::Specification::PackagedApp or nil.
-
#page_action ⇒ Object
readonly
A Tay::Specification::PageAction or nil.
-
#permissions ⇒ Object
An array of permissions the extension requires.
-
#requires_3d_css_transitions ⇒ Object
Set this to true to mark the extension as requiring 3d css support.
-
#requires_webgl ⇒ Object
Set this to true to mark the extension as requiring webgl support.
-
#source_directories ⇒ Object
An array of directories that will be copied to the build directory.
-
#stylesheets ⇒ Object
An array of stylesheet paths that will be copied to the build.
- #update_url ⇒ Object
- #version ⇒ Object
-
#web_accessible_resources ⇒ Object
An array of paths considered “web accessible”.
-
#web_intents ⇒ Object
An array of Tay::Specification::WebIntent objects.
Instance Method Summary collapse
-
#add_browser_action {|@browser_action| ... } ⇒ Object
Create a new Tay::Specification::BrowserAction and pass it to the block for set up.
-
#add_content_script {|content_script| ... } ⇒ Object
Add a content script to this extension.
-
#add_icon(size, path) ⇒ Object
Provide the path of the icon to be used at a certain size.
-
#add_nacl_module {|nacl_module| ... } ⇒ Object
Add a native client module to this extension.
-
#add_packaged_app {|@packaged_app| ... } ⇒ Object
Create a new Tay::Specification::BrowserAction and pass it to the block for set up.
-
#add_page_action {|@page_action| ... } ⇒ Object
Create a new Tay::Specification::BrowserAction and pass it to the block for set up.
-
#add_web_intent {|web_intent| ... } ⇒ Object
Add a web intent to this extension.
-
#all_javascript_paths ⇒ Object
Return all the javascript paths in the spec, included those nested inside other objects.
-
#all_stylesheet_paths ⇒ Object
Return all the stylesheet paths in the spec, included those nested inside other objects.
-
#has_permission?(permission) ⇒ Boolean
Does the specification have a certain permission?.
-
#initialize {|_self| ... } ⇒ Specification
constructor
A new instance of Specification.
-
#override_page(page_type, path) ⇒ Object
Override a built in Chrome page with your own HTML file.
Constructor Details
#initialize {|_self| ... } ⇒ Specification
Returns a new instance of Specification.
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/tay/specification.rb', line 174 def initialize(&block) @nacl_modules = [] @overriden_pages = {} @web_accessible_resources = [] @permissions = [] @background_scripts = [] @content_scripts = [] @web_intents = [] @icons = {} @stylesheets = [] @javascripts = [] @source_directories = %w{img assets html} yield self end |
Instance Attribute Details
#background_page ⇒ Object
Path to an HTML file that will be used as the background page
37 38 39 |
# File 'lib/tay/specification.rb', line 37 def background_page @background_page end |
#background_scripts ⇒ Object
An array javascript file paths that will run in the background
96 97 98 |
# File 'lib/tay/specification.rb', line 96 def background_scripts @background_scripts end |
#browser_action ⇒ Object (readonly)
A Tay::Specification::BrowserAction or nil
130 131 132 |
# File 'lib/tay/specification.rb', line 130 def browser_action @browser_action end |
#content_scripts ⇒ Object
An array of Tay::Specification::ContentScript objects
86 87 88 |
# File 'lib/tay/specification.rb', line 86 def content_scripts @content_scripts end |
#content_security_policy ⇒ Object
49 50 51 |
# File 'lib/tay/specification.rb', line 49 def content_security_policy @content_security_policy end |
#default_locale ⇒ Object
33 34 35 |
# File 'lib/tay/specification.rb', line 33 def default_locale @default_locale end |
#description ⇒ Object
25 26 27 |
# File 'lib/tay/specification.rb', line 25 def description @description end |
#homepage ⇒ Object
29 30 31 |
# File 'lib/tay/specification.rb', line 29 def homepage @homepage end |
#icons ⇒ Object
An map of icon sizes to paths
122 123 124 |
# File 'lib/tay/specification.rb', line 122 def icons @icons end |
#incognito_mode ⇒ Object
57 58 59 |
# File 'lib/tay/specification.rb', line 57 def incognito_mode @incognito_mode end |
#javascripts ⇒ Object
An array of javascript paths that will be copied to the build
112 113 114 |
# File 'lib/tay/specification.rb', line 112 def javascripts @javascripts end |
#key_path ⇒ Object
Get the path to the private key for this extension
172 173 174 |
# File 'lib/tay/specification.rb', line 172 def key_path @key_path end |
#manifest_data ⇒ Object
If you set this to a hash, it will be merged on top of the generated manifest. This is useful to force override of specific values
78 79 80 |
# File 'lib/tay/specification.rb', line 78 def manifest_data @manifest_data end |
#minimum_chrome_version ⇒ Object
53 54 55 |
# File 'lib/tay/specification.rb', line 53 def minimum_chrome_version @minimum_chrome_version end |
#nacl_modules ⇒ Object
An array of Tay::Specification::NaClModule
82 83 84 |
# File 'lib/tay/specification.rb', line 82 def nacl_modules @nacl_modules end |
#name ⇒ Object
17 18 19 |
# File 'lib/tay/specification.rb', line 17 def name @name end |
#offline_enabled ⇒ Object
61 62 63 |
# File 'lib/tay/specification.rb', line 61 def offline_enabled @offline_enabled end |
#omnibox_keyword ⇒ Object
45 46 47 |
# File 'lib/tay/specification.rb', line 45 def omnibox_keyword @omnibox_keyword end |
#options_page ⇒ Object
41 42 43 |
# File 'lib/tay/specification.rb', line 41 def @options_page end |
#overriden_pages ⇒ Object (readonly)
A map of Chrome page types to HTML files
126 127 128 |
# File 'lib/tay/specification.rb', line 126 def overriden_pages @overriden_pages end |
#packaged_app ⇒ Object (readonly)
A Tay::Specification::PackagedApp or nil
138 139 140 |
# File 'lib/tay/specification.rb', line 138 def packaged_app @packaged_app end |
#page_action ⇒ Object (readonly)
A Tay::Specification::PageAction or nil
134 135 136 |
# File 'lib/tay/specification.rb', line 134 def page_action @page_action end |
#permissions ⇒ Object
An array of permissions the extension requires
108 109 110 |
# File 'lib/tay/specification.rb', line 108 def @permissions end |
#requires_3d_css_transitions ⇒ Object
Set this to true to mark the extension as requiring 3d css support
69 70 71 |
# File 'lib/tay/specification.rb', line 69 def requires_3d_css_transitions @requires_3d_css_transitions end |
#requires_webgl ⇒ Object
Set this to true to mark the extension as requiring webgl support
65 66 67 |
# File 'lib/tay/specification.rb', line 65 def requires_webgl @requires_webgl end |
#source_directories ⇒ Object
An array of directories that will be copied to the build directory. Defaults to “img”, “assets”, and “html”, all files are run through Tilt before being copied
If just a directory name is passed, it is assumed to be a sub-dir of src, and will be copied as the directory name, eg:
spec.source_directories << “extras”
# copies src/extras to build/extras
If you provide a path, it is relative to the root directory, and will be copied to the build directory under this full relative path, eg:
spec.source_directories << “non_code/fonts”
# copies non_code/fonts to build/non_code/fonts
If you need finer control over where files end up, you can also push an object on to this list detailing the source directory, and the directory it will be placed in under the build dir. You can optionally specify whether to run through Tilt or not (default: yes). eg:
spec.source_directories <<
:from => "vendor/bootstrap/img",
:as => "img",
:use_tilt => false
# copies vendor/bootstrap/img/* to build/img
167 168 169 |
# File 'lib/tay/specification.rb', line 167 def source_directories @source_directories end |
#stylesheets ⇒ Object
An array of stylesheet paths that will be copied to the build
116 117 118 |
# File 'lib/tay/specification.rb', line 116 def stylesheets @stylesheets end |
#update_url ⇒ Object
73 74 75 |
# File 'lib/tay/specification.rb', line 73 def update_url @update_url end |
#version ⇒ Object
21 22 23 |
# File 'lib/tay/specification.rb', line 21 def version @version end |
#web_accessible_resources ⇒ Object
An array of paths considered “web accessible”
code.google.com/chrome/extensions/manifest.html#web_accessible_resources
102 103 104 |
# File 'lib/tay/specification.rb', line 102 def web_accessible_resources @web_accessible_resources end |
#web_intents ⇒ Object
An array of Tay::Specification::WebIntent objects
90 91 92 |
# File 'lib/tay/specification.rb', line 90 def web_intents @web_intents end |
Instance Method Details
#add_browser_action {|@browser_action| ... } ⇒ Object
Create a new Tay::Specification::BrowserAction and pass it to the block for set up.
199 200 201 202 203 |
# File 'lib/tay/specification.rb', line 199 def add_browser_action(&block) raise Tay::InvalidSpecification.new('Browser action already set up') if @browser_action @browser_action = BrowserAction.new yield @browser_action end |
#add_content_script {|content_script| ... } ⇒ Object
Add a content script to this extension. It will be passed to the block for set up. See Tay::Specification::ContentScript
226 227 228 229 230 |
# File 'lib/tay/specification.rb', line 226 def add_content_script(&block) content_script = ContentScript.new yield content_script @content_scripts << content_script end |
#add_icon(size, path) ⇒ Object
Provide the path of the icon to be used at a certain size
192 193 194 |
# File 'lib/tay/specification.rb', line 192 def add_icon(size, path) @icons[size.to_i] = path end |
#add_nacl_module {|nacl_module| ... } ⇒ Object
Add a native client module to this extension. It will be passed to the block for set up. See Tay::Specification::NaClModule
244 245 246 247 248 |
# File 'lib/tay/specification.rb', line 244 def add_nacl_module(&block) nacl_module = NaClModule.new yield nacl_module @nacl_modules << nacl_module end |
#add_packaged_app {|@packaged_app| ... } ⇒ Object
Create a new Tay::Specification::BrowserAction and pass it to the block for set up.
217 218 219 220 221 |
# File 'lib/tay/specification.rb', line 217 def add_packaged_app(&block) raise Tay::InvalidSpecification.new('Packaged app already set up') if @packaged_app @packaged_app = PackagedApp.new yield @packaged_app end |
#add_page_action {|@page_action| ... } ⇒ Object
Create a new Tay::Specification::BrowserAction and pass it to the block for set up.
208 209 210 211 212 |
# File 'lib/tay/specification.rb', line 208 def add_page_action(&block) raise Tay::InvalidSpecification.new('Page action already set up') if @page_action @page_action = PageAction.new yield @page_action end |
#add_web_intent {|web_intent| ... } ⇒ Object
Add a web intent to this extension. It will be passed to the block for set up. See Tay::Specification::WebIntent
235 236 237 238 239 |
# File 'lib/tay/specification.rb', line 235 def add_web_intent(&block) web_intent = WebIntent.new yield web_intent @web_intents << web_intent end |
#all_javascript_paths ⇒ Object
Return all the javascript paths in the spec, included those nested inside other objects
261 262 263 264 265 266 267 |
# File 'lib/tay/specification.rb', line 261 def all_javascript_paths all_paths = [] all_paths += @javascripts all_paths += @background_scripts all_paths += @content_scripts.map { |cs| cs.javascripts }.compact all_paths.flatten.uniq end |
#all_stylesheet_paths ⇒ Object
Return all the stylesheet paths in the spec, included those nested inside other objects
272 273 274 275 276 277 |
# File 'lib/tay/specification.rb', line 272 def all_stylesheet_paths all_paths = [] all_paths += @stylesheets all_paths += @content_scripts.map { |cs| cs.stylesheets }.compact all_paths.flatten.uniq end |
#has_permission?(permission) ⇒ Boolean
Does the specification have a certain permission?
287 288 289 |
# File 'lib/tay/specification.rb', line 287 def () .include?() end |
#override_page(page_type, path) ⇒ Object
Override a built in Chrome page with your own HTML file
254 255 256 |
# File 'lib/tay/specification.rb', line 254 def override_page(page_type, path) @overriden_pages[page_type] = path end |