Class: Rabbit::Theme::Entry

Inherits:
Object
  • Object
show all
Extended by:
ERB::DefMethod
Includes:
ERB::Util, Enumerable, GetText
Defined in:
lib/rabbit/theme/entry.rb

Direct Known Subclasses

DirectoryEntry, FileEntry, GemEntry

Constant Summary collapse

THEME_BASE_NAME =
"theme"
PROPERTY_BASE_NAME =
"property"

Constants included from GetText

GetText::DOMAIN

Instance Attribute 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.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rabbit/theme/entry.rb', line 40

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

#abstractObject (readonly)

Returns the value of attribute abstract.



36
37
38
# File 'lib/rabbit/theme/entry.rb', line 36

def abstract
  @abstract
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



37
38
39
# File 'lib/rabbit/theme/entry.rb', line 37

def dependencies
  @dependencies
end

#descriptionObject (readonly)

Returns the value of attribute description.



35
36
37
# File 'lib/rabbit/theme/entry.rb', line 35

def description
  @description
end

#loggerObject

Returns the value of attribute logger.



38
39
40
# File 'lib/rabbit/theme/entry.rb', line 38

def logger
  @logger
end

#nameObject (readonly)

Returns the value of attribute name.



35
36
37
# File 'lib/rabbit/theme/entry.rb', line 35

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



37
38
39
# File 'lib/rabbit/theme/entry.rb', line 37

def parameters
  @parameters
end

#titleObject (readonly)

Returns the value of attribute title.



35
36
37
# File 'lib/rabbit/theme/entry.rb', line 35

def title
  @title
end

Instance Method Details

#<=>(other) ⇒ Object



61
62
63
# File 'lib/rabbit/theme/entry.rb', line 61

def <=>(other)
  @name <=> other.name
end

#available?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/rabbit/theme/entry.rb', line 53

def available?
  File.readable?(theme_file)
end

#categoryObject



78
79
80
# File 'lib/rabbit/theme/entry.rb', line 78

def category
  @category || N_("Etc")
end

#data_dirObject



86
87
88
# File 'lib/rabbit/theme/entry.rb', line 86

def data_dir
  File.join(@theme_dir, "data")
end

#filesObject



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rabbit/theme/entry.rb', line 90

def files
  if have_data_dir?
    Dir.glob(File.join(data_dir, "*")).sort
  else
    # backward compatibility
    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



69
70
71
72
73
74
75
76
# File 'lib/rabbit/theme/entry.rb', line 69

def full_path(target)
  if have_data_dir?
    File.join(data_dir, target)
  else
    # backward compatibility
    File.join(@theme_dir, target)
  end
end

#have_file?(target) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/rabbit/theme/entry.rb', line 65

def have_file?(target)
  File.exist?(full_path(target))
end

#image_theme?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/rabbit/theme/entry.rb', line 82

def image_theme?
  have_data_dir?
end

#property_editable?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/rabbit/theme/entry.rb', line 57

def property_editable?
  File.writable?(property_file)
end