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
- THEME_BASE_NAME =
"theme"
- 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
included
Constructor Details
#initialize(logger, theme_dir, name) ⇒ Entry
Returns a new instance of Entry.
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/rabbit/theme/entry.rb', line 69
def initialize(logger, theme_dir, name)
@logger = logger
@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.
65
66
67
|
# File 'lib/rabbit/theme/entry.rb', line 65
def abstract
@abstract
end
|
#dependencies ⇒ Object
Returns the value of attribute dependencies.
66
67
68
|
# File 'lib/rabbit/theme/entry.rb', line 66
def dependencies
@dependencies
end
|
#description ⇒ Object
Returns the value of attribute description.
64
65
66
|
# File 'lib/rabbit/theme/entry.rb', line 64
def description
@description
end
|
#logger ⇒ Object
Returns the value of attribute logger.
67
68
69
|
# File 'lib/rabbit/theme/entry.rb', line 67
def logger
@logger
end
|
#name ⇒ Object
Returns the value of attribute name.
64
65
66
|
# File 'lib/rabbit/theme/entry.rb', line 64
def name
@name
end
|
#parameters ⇒ Object
Returns the value of attribute parameters.
66
67
68
|
# File 'lib/rabbit/theme/entry.rb', line 66
def parameters
@parameters
end
|
#title ⇒ Object
Returns the value of attribute title.
64
65
66
|
# File 'lib/rabbit/theme/entry.rb', line 64
def title
@title
end
|
Class Method Details
.load_template(path = nil) ⇒ Object
47
48
49
50
51
|
# File 'lib/rabbit/theme/entry.rb', line 47
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
53
54
55
56
57
58
59
|
# File 'lib/rabbit/theme/entry.rb', line 53
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
38
39
40
41
42
43
44
45
|
# File 'lib/rabbit/theme/entry.rb', line 38
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
90
91
92
|
# File 'lib/rabbit/theme/entry.rb', line 90
def <=>(other)
@name <=> other.name
end
|
#available? ⇒ Boolean
82
83
84
|
# File 'lib/rabbit/theme/entry.rb', line 82
def available?
File.readable?(theme_file)
end
|
#category ⇒ Object
107
108
109
|
# File 'lib/rabbit/theme/entry.rb', line 107
def category
@category || N_("Etc")
end
|
#data_dir ⇒ Object
115
116
117
|
# File 'lib/rabbit/theme/entry.rb', line 115
def data_dir
File.join(@theme_dir, "data")
end
|
#files ⇒ Object
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/rabbit/theme/entry.rb', line 119
def files
if have_data_dir?
Dir.glob(File.join(data_dir, "*")).sort
else
rejected_files = [theme_file, property_file]
Dir[File.join(@theme_dir, "*")].delete_if do |name|
rejected_files.include?(name)
end.sort
end
end
|
#full_path(target) ⇒ Object
98
99
100
101
102
103
104
105
|
# File 'lib/rabbit/theme/entry.rb', line 98
def full_path(target)
if have_data_dir?
File.join(data_dir, target)
else
File.join(@theme_dir, target)
end
end
|
#have_file?(target) ⇒ Boolean
94
95
96
|
# File 'lib/rabbit/theme/entry.rb', line 94
def have_file?(target)
File.exist?(full_path(target))
end
|
#image_theme? ⇒ Boolean
111
112
113
|
# File 'lib/rabbit/theme/entry.rb', line 111
def image_theme?
have_data_dir?
end
|
#property_editable? ⇒ Boolean
86
87
88
|
# File 'lib/rabbit/theme/entry.rb', line 86
def property_editable?
File.writable?(property_file)
end
|