Class: Piedesaint::CLI
- Inherits:
-
Object
- Object
- Piedesaint::CLI
- Defined in:
- lib/piedesaint/cli.rb
Overview
The CLI class encapsulates the behavior of Piedesaint when it is invoked as a command-line utility. This allows other programs to embed Piedesaint and preserve its command-line semantics.
Instance Method Summary collapse
- #execute ⇒ Object
- #init(parameters = []) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #set_host(host = []) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
12 13 |
# File 'lib/piedesaint/cli.rb', line 12 def initialize end |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 20 |
# File 'lib/piedesaint/cli.rb', line 15 def execute load_config cert(@config[:host]) if @config[:refresh_cert] piedesanto = Piedesaint.new @config piedesanto.start end |
#init(parameters = []) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/piedesaint/cli.rb', line 22 def init ( parameters = [] ) if File.exist?(".piedesaint") abort "Configuration already exists at #{Dir.pwd}/.piedesaint" end config = { iface: "0.0.0.0", http_port: 8080, https_port: 9292, refresh_cert: true, host: "localhost", key: File.join(".", ".piedesaint", "ssl", "server.key" ), cert: File.join(".", ".piedesaint", "ssl", "server.crt" ), username: "user", password: "password", freshness: 3600, metastore: 'file:/tmp/rack/meta', entitystore: 'file:/tmp/rack/body', tar: true, folders: parameters } save_config config cert puts "Configuration created at #{Dir.pwd}/.piedesaint" end |
#set_host(host = []) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/piedesaint/cli.rb', line 46 def set_host ( host = [] ) load_config @config[:host] = host[0] save_config @config cert host[0] end |