Class: InstallTheme
- Inherits:
-
Object
- Object
- InstallTheme
- Defined in:
- lib/install_theme.rb,
lib/install_theme/cli.rb
Defined Under Namespace
Classes: CLI, InstallThemeGenerator
Constant Summary collapse
- VERSION =
"0.5.1"
Instance Attribute Summary collapse
-
#content_id ⇒ Object
readonly
Returns the value of attribute content_id.
-
#image_dir ⇒ Object
readonly
Returns the value of attribute image_dir.
-
#index_path ⇒ Object
readonly
Returns the value of attribute index_path.
-
#inside_yields ⇒ Object
readonly
Returns the value of attribute inside_yields.
-
#inside_yields_originals ⇒ Object
readonly
Returns the value of attribute inside_yields_originals.
-
#javascript_dir ⇒ Object
readonly
Returns the value of attribute javascript_dir.
-
#rails_root ⇒ Object
readonly
Returns the value of attribute rails_root.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
-
#stylesheet_dir ⇒ Object
readonly
Returns the value of attribute stylesheet_dir.
-
#template_root ⇒ Object
readonly
Returns the value of attribute template_root.
-
#template_type ⇒ Object
readonly
Returns the value of attribute template_type.
Instance Method Summary collapse
- #apply_to_target(options = {}) ⇒ Object
- #erb? ⇒ Boolean
- #haml? ⇒ Boolean
-
#initialize(options = {}) ⇒ InstallTheme
constructor
A new instance of InstallTheme.
- #setup_template_temp_path ⇒ Object
-
#template_temp_path ⇒ Object
This generator’s templates folder is temporary and is accessed via source_root within the generator.
Constructor Details
#initialize(options = {}) ⇒ InstallTheme
Returns a new instance of InstallTheme.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/install_theme.rb', line 17 def initialize( = {}) @template_root = File.([:template_root] || File.dirname('.')) @rails_root = File.([:rails_root] || File.dirname('.')) @template_type = ([:template_type] || detect_template).to_s @index_path = [:index_path] || "index.html" @content_id = [:content_id] || "content" @inside_yields = [:inside_yields] || {} @stylesheet_dir = [:stylesheet_dir] || detect_stylesheet_dir @javascript_dir = [:javascript_dir] || detect_javascript_dir @image_dir = [:image_dir] || detect_image_dir @stdout = [:stdout] || $stdout setup_template_temp_path end |
Instance Attribute Details
#content_id ⇒ Object (readonly)
Returns the value of attribute content_id.
13 14 15 |
# File 'lib/install_theme.rb', line 13 def content_id @content_id end |
#image_dir ⇒ Object (readonly)
Returns the value of attribute image_dir.
12 13 14 |
# File 'lib/install_theme.rb', line 12 def image_dir @image_dir end |
#index_path ⇒ Object (readonly)
Returns the value of attribute index_path.
11 12 13 |
# File 'lib/install_theme.rb', line 11 def index_path @index_path end |
#inside_yields ⇒ Object (readonly)
Returns the value of attribute inside_yields.
13 14 15 |
# File 'lib/install_theme.rb', line 13 def inside_yields @inside_yields end |
#inside_yields_originals ⇒ Object (readonly)
Returns the value of attribute inside_yields_originals.
15 16 17 |
# File 'lib/install_theme.rb', line 15 def inside_yields_originals @inside_yields_originals end |
#javascript_dir ⇒ Object (readonly)
Returns the value of attribute javascript_dir.
12 13 14 |
# File 'lib/install_theme.rb', line 12 def javascript_dir @javascript_dir end |
#rails_root ⇒ Object (readonly)
Returns the value of attribute rails_root.
11 12 13 |
# File 'lib/install_theme.rb', line 11 def rails_root @rails_root end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
14 15 16 |
# File 'lib/install_theme.rb', line 14 def stdout @stdout end |
#stylesheet_dir ⇒ Object (readonly)
Returns the value of attribute stylesheet_dir.
12 13 14 |
# File 'lib/install_theme.rb', line 12 def stylesheet_dir @stylesheet_dir end |
#template_root ⇒ Object (readonly)
Returns the value of attribute template_root.
11 12 13 |
# File 'lib/install_theme.rb', line 11 def template_root @template_root end |
#template_type ⇒ Object (readonly)
Returns the value of attribute template_type.
11 12 13 |
# File 'lib/install_theme.rb', line 11 def template_type @template_type end |
Instance Method Details
#apply_to_target(options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/install_theme.rb', line 32 def apply_to_target( = {}) @stdout = [:stdout] || @stdout || $stdout @inside_yields_originals = {} convert_file_to_layout(index_path, 'app/views/layouts/application.html.erb') convert_to_haml('app/views/layouts/application.html.erb') if haml? prepare_assets run_generator() show_readme end |
#erb? ⇒ Boolean
62 63 64 |
# File 'lib/install_theme.rb', line 62 def erb? template_type == 'erb' end |
#haml? ⇒ Boolean
58 59 60 |
# File 'lib/install_theme.rb', line 58 def haml? template_type == 'haml' end |
#setup_template_temp_path ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/install_theme.rb', line 50 def setup_template_temp_path FileUtils.rm_rf(template_temp_path) FileUtils.mkdir_p(template_temp_path) %w[app/views/layouts public/images public/javascripts public/stylesheets].each do |app_path| FileUtils.mkdir_p(File.join(template_temp_path, app_path)) end end |
#template_temp_path ⇒ Object
This generator’s templates folder is temporary and is accessed via source_root within the generator.
44 45 46 47 48 |
# File 'lib/install_theme.rb', line 44 def template_temp_path @template_temp_path ||= begin template_path = File.join(tmp_dir, "install_theme", "templates") end end |