Class: Staticpress::Theme
- Inherits:
-
Object
- Object
- Staticpress::Theme
- Extended by:
- Helpers
- Includes:
- Helpers
- Defined in:
- lib/staticpress/theme.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#trail ⇒ Object
readonly
Returns the value of attribute trail.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #assets ⇒ Object
- #copy_to(name) ⇒ Object
-
#initialize(name) ⇒ Theme
constructor
A new instance of Theme.
- #parent ⇒ Object
Methods included from Helpers
config, extensionless_basename, extensionless_path, hash_from_array, hash_from_match_data, paginate, settings, spider_map, titleize
Constructor Details
#initialize(name) ⇒ Theme
Returns a new instance of Theme.
10 11 12 13 14 15 16 17 18 |
# File 'lib/staticpress/theme.rb', line 10 def initialize(name) @name = name.to_sym custom = Staticpress.blog_path + 'themes' + @name.to_s @root = custom.directory? ? custom : Staticpress.root + 'themes' + @name.to_s @trail = Hike::Trail.new @trail.append_paths custom, Staticpress.root + 'themes' + @name.to_s @trail.append_extensions *Tilt.mappings.keys end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/staticpress/theme.rb', line 8 def name @name end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
8 9 10 |
# File 'lib/staticpress/theme.rb', line 8 def root @root end |
#trail ⇒ Object (readonly)
Returns the value of attribute trail.
8 9 10 |
# File 'lib/staticpress/theme.rb', line 8 def trail @trail end |
Class Method Details
.theme ⇒ Object
68 69 70 |
# File 'lib/staticpress/theme.rb', line 68 def self.theme new config.theme end |
Instance Method Details
#==(other) ⇒ Object
20 21 22 |
# File 'lib/staticpress/theme.rb', line 20 def ==(other) other.respond_to?(:name) ? (name == other.name) : super end |
#assets ⇒ Object
24 25 26 27 28 29 |
# File 'lib/staticpress/theme.rb', line 24 def assets reply = spider_map (root + 'assets').children do |file| file end.flatten parent ? (parent.assets + reply) : reply end |
#copy_to(name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/staticpress/theme.rb', line 31 def copy_to(name) destination = Staticpress.blog_path + 'themes' + name.to_s if destination.directory? raise Staticpress::Error, "Cannot copy theme. Destination (#{destination}) already exists." else FileUtils.mkdir_p destination FileUtils.cp_r root.children, destination end end |
#parent ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/staticpress/theme.rb', line 42 def parent @parent ||= lambda do if config.theme_parent reply = self.class.new(config.theme_parent) @parent = reply unless self == reply end end.call end |