Class: BiblioTech::CommandGenerator
- Inherits:
-
Object
- Object
- BiblioTech::CommandGenerator
- Includes:
- Caliph::CommandLineDSL
- Defined in:
- lib/bibliotech/command_generator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #export(options = nil) ⇒ Object
- #fetch(remote, filename, options = nil) ⇒ Object
- #import(options = nil) ⇒ Object
-
#initialize(config) ⇒ CommandGenerator
constructor
A new instance of CommandGenerator.
- #push(remote, filename, options = nil) ⇒ Object
- #remote_cli(remote, *command_options) ⇒ Object
- #wipe ⇒ Object
Constructor Details
#initialize(config) ⇒ CommandGenerator
Returns a new instance of CommandGenerator.
14 15 16 |
# File 'lib/bibliotech/command_generator.rb', line 14 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
12 13 14 |
# File 'lib/bibliotech/command_generator.rb', line 12 def config @config end |
Instance Method Details
#create ⇒ Object
82 83 84 |
# File 'lib/bibliotech/command_generator.rb', line 82 def create() raise NotImplementedError end |
#delete ⇒ Object
79 80 81 |
# File 'lib/bibliotech/command_generator.rb', line 79 def delete() raise NotImplementedError end |
#export(options = nil) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/bibliotech/command_generator.rb', line 18 def export( = nil) = config.merge( || {}) command = cmd command = Builders::Export.for().go(command) Builders::FileOutput.for().go(command) end |
#fetch(remote, filename, options = nil) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/bibliotech/command_generator.rb', line 32 def fetch(remote, filename, = nil) = config.merge( || {}) cmd("scp") do |cmd| .optionally{ cmd. << "-i #{.id_file(remote)}" } cmd. << .remote_file(remote, filename) cmd. << .local_file(filename) end end |
#import(options = nil) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/bibliotech/command_generator.rb', line 25 def import( = nil) = config.merge( || {}) command = cmd() command = Builders::Import.for().go(command) Builders::FileInput.for().go(command) end |
#push(remote, filename, options = nil) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/bibliotech/command_generator.rb', line 41 def push(remote, filename, = nil) = config.merge( || {}) cmd("scp") do |cmd| cmd. << .local_file(filename) cmd. << .remote_file(remote, filename) end end |
#remote_cli(remote, *command_options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/bibliotech/command_generator.rb', line 49 def remote_cli(remote, *) = {} if .last.is_a? Hash = .pop end = config.merge() command_on_remote = cmd("cd") do |cmd| cmd. << .root_dir_on(remote) end & cmd("bundle", "exec", "bibliotech", *) cmd("ssh") do |cmd| cmd. << "-n" #because we're not going to be doing any input .optionally{ cmd. << "-i #{.id_file(remote)}" } .optionally{ cmd. << "-l #{.remote_user(remote)}" } cmd. << .remote_host(remote) .optionally{ cmd. << "-p #{.remote_port(remote)}" } #ok .optionally do .(remote).each do |opt| cmd. << "-o #{opt}" end end end - escaped_command(command_on_remote) end |
#wipe ⇒ Object
76 77 78 |
# File 'lib/bibliotech/command_generator.rb', line 76 def wipe() raise NotImplementedError end |