Class: Rabbit::Theme::Entry
- Inherits:
-
Object
- Object
- Rabbit::Theme::Entry
show all
- Extended by:
- ERB::DefMethod
- Includes:
- ERB::Util, Enumerable, GetText
- Defined in:
- lib/rabbit/theme/entry.rb
Constant Summary
collapse
- PROPERTY_BASE_NAME =
"property"
- @@template_last_modified_time =
nil
Constants included
from GetText
GetText::DOMAIN
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from GetText
N_, _, bindtextdomain, locale=
Constructor Details
#initialize(theme_dir, name) ⇒ Entry
Returns a new instance of Entry.
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/rabbit/theme/entry.rb', line 50
def initialize(theme_dir, name)
@logger = nil
@theme_dir = theme_dir
@name = name
@title = @name
@category = nil
@abstract = nil
@description = nil
@dependencies = []
@parameters = {}
parse_property if available?
end
|
Instance Attribute Details
#abstract ⇒ Object
Returns the value of attribute abstract.
46
47
48
|
# File 'lib/rabbit/theme/entry.rb', line 46
def abstract
@abstract
end
|
#dependencies ⇒ Object
Returns the value of attribute dependencies.
47
48
49
|
# File 'lib/rabbit/theme/entry.rb', line 47
def dependencies
@dependencies
end
|
#description ⇒ Object
Returns the value of attribute description.
45
46
47
|
# File 'lib/rabbit/theme/entry.rb', line 45
def description
@description
end
|
#logger ⇒ Object
Returns the value of attribute logger.
48
49
50
|
# File 'lib/rabbit/theme/entry.rb', line 48
def logger
@logger
end
|
#name ⇒ Object
Returns the value of attribute name.
45
46
47
|
# File 'lib/rabbit/theme/entry.rb', line 45
def name
@name
end
|
#parameters ⇒ Object
Returns the value of attribute parameters.
47
48
49
|
# File 'lib/rabbit/theme/entry.rb', line 47
def parameters
@parameters
end
|
#title ⇒ Object
Returns the value of attribute title.
45
46
47
|
# File 'lib/rabbit/theme/entry.rb', line 45
def title
@title
end
|
Class Method Details
.load_template(path = nil) ⇒ Object
28
29
30
31
32
|
# File 'lib/rabbit/theme/entry.rb', line 28
def load_template(path=nil)
path ||= template_path
@@template_last_modified_time = File.mtime(path)
def_erb_method("to_rd", path)
end
|
.reload_template(path = nil) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/rabbit/theme/entry.rb', line 34
def reload_template(path=nil)
path ||= template_path
if @@template_last_modified_time < File.mtime(path)
remove_method("to_rd")
load_template(path)
end
end
|
.template_path ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/rabbit/theme/entry.rb', line 19
def template_path
path = ["rabbit", "theme", "document.erb"]
template_path = Utils.find_path_in_load_path(*path)
if template_path.nil?
raise CantFindThemeRDTemplate.new(File.join(*path))
end
template_path
end
|
Instance Method Details
#<=>(other) ⇒ Object
75
76
77
|
# File 'lib/rabbit/theme/entry.rb', line 75
def <=>(other)
@name <=> other.name
end
|
#available? ⇒ Boolean
63
64
65
|
# File 'lib/rabbit/theme/entry.rb', line 63
def available?
File.readable?(theme_file)
end
|
#category ⇒ Object
87
88
89
|
# File 'lib/rabbit/theme/entry.rb', line 87
def category
@category || N_("Etc")
end
|
#files ⇒ Object
95
96
97
98
99
100
|
# File 'lib/rabbit/theme/entry.rb', line 95
def files
rejected_files = [theme_file, property_file]
Dir[File.join(@theme_dir, "*")].delete_if do |name|
rejected_files.include?(name)
end.sort
end
|
#full_path(target) ⇒ Object
83
84
85
|
# File 'lib/rabbit/theme/entry.rb', line 83
def full_path(target)
File.join(@theme_dir, target)
end
|
#have_file?(target) ⇒ Boolean
79
80
81
|
# File 'lib/rabbit/theme/entry.rb', line 79
def have_file?(target)
File.exist?(full_path(target))
end
|
#image_theme? ⇒ Boolean
91
92
93
|
# File 'lib/rabbit/theme/entry.rb', line 91
def image_theme?
false
end
|
#property_editable? ⇒ Boolean
67
68
69
|
# File 'lib/rabbit/theme/entry.rb', line 67
def property_editable?
File.writable?(property_file)
end
|
#theme_file ⇒ Object
71
72
73
|
# File 'lib/rabbit/theme/entry.rb', line 71
def theme_file
File.join(@theme_dir, "#{@name}.rb")
end
|