Class: Aspen::CLI::Commands::BuildSteps::CollectMainAspen
- Defined in:
- lib/aspen/cli/commands/build_steps.rb
Instance Method Summary collapse
Methods inherited from BuildStep
Instance Method Details
#call ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/aspen/cli/commands/build_steps.rb', line 113 def call(*) super # Grab all the grammars and Aspen source files, make into one main Aspen file. puts "----> Collecting main.aspen from src/ and src/grammars" # Clear the build/ folder Dir["build/main-*"].each { |path| @files.delete(path)} @grammars = "" # Main grammars IO @discourses = "" # Main discourses IO @aspens = "" # Main Aspen IO collect_discourses collect_grammars collect_aspen main_aspen = File.open("build/main-#{Time.now.to_i}.aspen", 'w') do |file| file << @discourses file << @grammars file << Aspen::SEPARATOR + "\n" file << @aspens end return main_aspen end |
#collect_aspen ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/aspen/cli/commands/build_steps.rb', line 154 def collect_aspen Dir['src/*.aspen'].map do |path| next if manifest.dig("ignore", "src") && manifest.dig("ignore", "src").any? do |ignore_path| Regexp.new(ignore_path) =~ path end File.read(path) end.compact.each do |file| if file.include?(SEPARATOR) env, _sep, code = file.partition(SEPARATOR) @discourses << env @aspens << code else @aspens << file end end end |
#collect_discourses ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/aspen/cli/commands/build_steps.rb', line 138 def collect_discourses Dir['src/discourses/*.aspen'].map do |path| # Skip if there's an ignore: src: in the manifest, and if it matches the file path next if manifest.dig("ignore", "discourses") && manifest.dig("ignore", "discourses").any? { |ignore_path| Regexp.new(ignore_path) =~ path } @discourses << File.read(path) end end |
#collect_grammars ⇒ Object
146 147 148 149 150 151 152 |
# File 'lib/aspen/cli/commands/build_steps.rb', line 146 def collect_grammars Dir['src/grammars/*.aspen'].map do |path| # Skip if there's an ignore: src: in the manifest, and if it matches the file path next if manifest.dig("ignore", "grammars") && manifest.dig("ignore", "grammars").any? { |ignore_path| Regexp.new(ignore_path) =~ path } @grammars << File.read(path) end end |