Class: Middleman::Cli::Release
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Middleman::Cli::Release
- Includes:
- Thor::Actions
- Defined in:
- lib/releases/commands/release.rb
Overview
This class provides an “release” command for the middleman CLI.
Class Method Summary collapse
-
.source_root ⇒ String
Template files are relative to this file.
Instance Method Summary collapse
Class Method Details
.source_root ⇒ String
Template files are relative to this file
22 23 24 |
# File 'lib/releases/commands/release.rb', line 22 def self.source_root File.dirname( __FILE__ ) end |
Instance Method Details
#release ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/releases/commands/release.rb', line 38 def release @tag = tag @date = [:date] ? ::Time.zone.parse([:date]) : Time.zone.now app = ::Middleman::Application.new do config[:mode] = :config config[:disable_sitemap] = true config[:watcher_disable] = true config[:exit_before_ready] = true end releases_manager = app.extensions[:releases] release_dir_name = @tag absolute_release_path = File.join( app.source_dir, releases_manager..releases_dir, release_dir_name, "index.html.markdown" ) template releases_manager..new_release_template, absolute_release_path # Edit option process if [ :edit ] editor = ENV.fetch('MM_EDITOR', ENV.fetch('EDITOR', nil )) if editor system( "#{ editor } #{ absolute_release_path }" ) else throw "Could not find a suitable editor. Try setting the environment variable MM_EDITOR." end end end |