Module: Brightguide::Parser
- Defined in:
- lib/brightguide/parser.rb
Class Method Summary collapse
Class Method Details
.all ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/brightguide/parser.rb', line 3 def self.all file_paths.map do |file_path| { name: File.basename(file_path, ".*"), sections: parse_file(file_path), folder_name: folder_name(file_path) } end end |
.file_paths ⇒ Object
13 14 15 16 17 |
# File 'lib/brightguide/parser.rb', line 13 def self.file_paths Dir.glob(Rails.root.join(Brightguide.stylesheets_path, "**", "*")).select do |path| File.file?(path) end end |
.folder_name(file_path) ⇒ Object
19 20 21 |
# File 'lib/brightguide/parser.rb', line 19 def self.folder_name(file_path) File.dirname(file_path).remove("#{Rails.root.join(Brightguide.stylesheets_path)}/") end |
.parse_file(file_path) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/brightguide/parser.rb', line 23 def self.parse_file(file_path) [].tap do |result| File.open(file_path, "r") do |file| documentation = false file.each_line do |line| documentation = false if line.starts_with?("*/") result.last << line if documentation if line.starts_with?("/* doc") documentation = true result << "" end end end end end |