Module: RoccoRails

Includes:
Rake::DSL
Defined in:
lib/rocco_rails.rb,
lib/rocco_rails/railtie.rb,
lib/rocco_rails/version.rb

Defined Under Namespace

Classes: Railtie

Constant Summary collapse

VERSION =
"0.9"

Class Method Summary collapse

Class Method Details

.generate_file_list(excuded_items = []) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/rocco_rails.rb', line 24

def generate_file_list(excuded_items = [])
  rails_files = Dir.glob(File.join("**", "*.rb"))
  excuded_items.each do |excluded|
    rails_files.delete_if{|x| x.include?(excluded)}
  end
  rails_files
end

.generate_menu(path) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rocco_rails.rb', line 33

def generate_menu(path)

  old_pwd = Dir.pwd
  Dir.chdir(path)
  dirs = Dir["**/*.html"]
  Dir.chdir(old_pwd)

  tree = {}
  menu = ""

  dirs.each do |path|
    current  = tree
    path.split("/").inject("") do |sub_path,dir|
      sub_path = sub_path[0] == ("/") ? sub_path[1..-1] : sub_path
      sub_path = File.join(sub_path, dir)
      current[sub_path] ||= {}
      current  = current[sub_path]
      sub_path
    end
  end
  return print_tree(tree)
end

.generate_resources(path, rocco_out) ⇒ Object

Rocco only use a var named stylesheet supposed to be the path for the stylesheet. This is a little hack to use it to  inject a complete directory. Default is /resources



13
14
15
16
17
18
19
20
21
22
# File 'lib/rocco_rails.rb', line 13

def generate_resources(path, rocco_out)
  files = Dir.entries(path) - [".", ".."]
  out = ""
  files.each do |file|
      out += "<link rel='stylesheet' href='#{[rocco_out, file].join('/')}'>\n" if file.end_with?(".css")
      out += "<script src='#{[rocco_out, file].join('/')}'></script>\n" if file.end_with?(".js")
    end
  out

end