Class: Astromapper::Cli
- Inherits:
-
Thor
- Object
- Thor
- Astromapper::Cli
- Defined in:
- lib/astromapper/cli.rb
Constant Summary collapse
- FORMATS =
%w[pdf draft proof html epub mobi txt]
Class Method Summary collapse
Instance Method Summary collapse
- #about(volume_id) ⇒ Object
- #build(type = 'sector') ⇒ Object
- #create(path) ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ Cli
constructor
A new instance of Cli.
- #svg ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ Cli
Returns a new instance of Cli.
12 13 14 15 16 17 |
# File 'lib/astromapper/cli.rb', line 12 def initialize(args = [], = {}, config = {}) # if (config[:current_task] || config[:current_command]).name == "new" && args.empty? # raise Error, "The e-Book path is required. For details run: Astromapper help new" # end super end |
Class Method Details
.exit_on_failure? ⇒ Boolean
9 10 11 |
# File 'lib/astromapper/cli.rb', line 9 def self.exit_on_failure? true end |
Instance Method Details
#about(volume_id) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/astromapper/cli.rb', line 30 def about(volume_id) say "Searching database on #{volume_id}" source = Astromapper.output_file('sector') if File.exists?(source) # volume = Astromapper::Astro::Volume.new(source, volume_id) # puts volume.inspect @volumes = {} volume = [] id = nil File.open(source,'r').readlines.each do |line| if /^\d{4}/.match(line) @volumes[id.to_s] = volume unless volume.nil? or id.nil? volume = [] id = line[0..3] end volume << line #unless volume.nil? end @volume = Astromapper::Astro::Volume.new(@volumes[volume_id]) puts @volume.summary say @volume.ascii else say "Hey! You need to generate the sector first (try: astromapper build)." end end |
#build(type = 'sector') ⇒ Object
58 59 60 61 |
# File 'lib/astromapper/cli.rb', line 58 def build(type='sector') say "Building #{type}: #{config['name'].inspect}" Astromapper::Exporter.run(root_dir, ) end |
#create(path) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/astromapper/cli.rb', line 21 def create(path) say "Voices of billions cry out in terror at the creation of '#{path}'" generator = Generator.new generator.destination_root = path.squish.gsub(' ','-') generator.invoke_all end |
#svg ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/astromapper/cli.rb', line 65 def svg source = Astromapper.output_file('sector') say "Converting #{source} to SVG" s = Svg.new(source) s.convert say "SVG available at #{Astromapper.output_file('svg')}" end |
#version ⇒ Object
75 76 77 |
# File 'lib/astromapper/cli.rb', line 75 def version say "Astromapper version #{Astromapper::VERSION}" end |