Module: Lydown::CLI::Support
- Defined in:
- lib/lydown/cli/support.rb
Class Method Summary collapse
- .copy_options(options) ⇒ Object
- .detect_filename(options) ⇒ Object
-
.detect_work_directory(opts) ⇒ Object
determine if the specified path is actually a path to a single movement of a multi-movement work.
Class Method Details
.copy_options(options) ⇒ Object
2 3 4 5 6 7 |
# File 'lib/lydown/cli/support.rb', line 2 def self.() opts = {}.deep! .each {|k, v| opts[k.to_sym] = v} opts end |
.detect_filename(options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lydown/cli/support.rb', line 9 def self.detect_filename() source = '' if [:path] == '-' # read source from stdin [:source] = STDIN.read # the output defaults to a file named lydown expect if the format is ly. # In that case the output will be sent to STDOUT. [:output_filename] ||= 'lydown' unless [:format] == :ly else [:source_filename] = [:path] if ([:path] !~ /\.ld$/) and File.file?([:path] + ".ld") [:path] += ".ld" end unless [:output_filename] if [:path] == '.' [:output_filename] = File.basename(FileUtils.pwd) else [:output_filename] = ([:path] =~ /^(.+)\.ld$/) ? $1 : [:path] end end end end |
.detect_work_directory(opts) ⇒ Object
determine if the specified path is actually a path to a single movement of a multi-movement work. If so, return the path of the work directory, and add a movement parameter. This should also take care of running proof mode inside of a movement directory.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lydown/cli/support.rb', line 39 def self.detect_work_directory(opts) return if opts[:movements] parent_dir = File.(File.join(opts[:path], '..')) if !File.exists?(File.join(opts[:path], 'work.ld')) && File.exists?(File.(File.join(parent_dir, 'work.ld'))) movement = File.basename(File.(opts[:path])) opts[:movements] = [movement] unless opts[:mode] == :proof opts[:path] = parent_dir end end |