Class: Rusic::ThemeFile

Inherits:
Object
  • Object
show all
Defined in:
lib/rusic/theme_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ ThemeFile

Returns a new instance of ThemeFile.



7
8
9
# File 'lib/rusic/theme_file.rb', line 7

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/rusic/theme_file.rb', line 5

def file
  @file
end

Instance Method Details

#descriptorObject



32
33
34
# File 'lib/rusic/theme_file.rb', line 32

def descriptor
  "#{dirname}/#{filename}"
end

#directoryObject



40
41
42
# File 'lib/rusic/theme_file.rb', line 40

def directory
  relative_path.to_s.chomp(filename.to_s)
end

#dirnameObject



52
53
54
# File 'lib/rusic/theme_file.rb', line 52

def dirname
  pathname.dirname
end

#extnameObject



60
61
62
# File 'lib/rusic/theme_file.rb', line 60

def extname
  pathname.extname
end

#filenameObject



56
57
58
# File 'lib/rusic/theme_file.rb', line 56

def filename
  pathname.basename
end

#pathnameObject



64
65
66
# File 'lib/rusic/theme_file.rb', line 64

def pathname
  Pathname.new(file)
end

#relative_pathObject



44
45
46
# File 'lib/rusic/theme_file.rb', line 44

def relative_path
  pathname.relative_path_from(working_directory)
end

#root_nameObject



36
37
38
# File 'lib/rusic/theme_file.rb', line 36

def root_name
  relative_path.each_filename.first
end

#uploaderObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rusic/theme_file.rb', line 11

def uploader
  case root_name
  when 'layouts', 'ideas', 'pages', 'participant', 'snippets', 'mailers', 'reports'
    uploader = Uploaders::Template.new(self, relative_path)
  when 'assets'
    case extname
    when '.css', '.js'
      uploader = Uploaders::EditableAsset.new(self)
    else
      uploader = Uploaders::Asset.new(self)
    end
  else
    case filename.to_s
    when /attributes\.ya?ml/
      uploader = Uploaders::CustomAttributes.new(self)
    end
  end

  uploader
end

#working_directoryObject



48
49
50
# File 'lib/rusic/theme_file.rb', line 48

def working_directory
  Pathname.new(Dir.pwd)
end