Class: Branston
- Inherits:
-
Object
- Object
- Branston
- Defined in:
- lib/branston/lib/branston.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
Instance Method Summary collapse
- #go ⇒ Object
-
#initialize(args) ⇒ Branston
constructor
A new instance of Branston.
Constructor Details
#initialize(args) ⇒ Branston
Returns a new instance of Branston.
12 13 14 15 |
# File 'lib/branston/lib/branston.rb', line 12 def initialize(args) self.args = args go() end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
10 11 12 |
# File 'lib/branston/lib/branston.rb', line 10 def args @args end |
Instance Method Details
#go ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/branston/lib/branston.rb', line 17 def go = { :Port => PORT, :Host => "0.0.0.0", :environment => (ENV['RAILS_ENV'] || "production").dup, :detach => true, :debugger => false, :path => nil, :directory => BRANSTON_HOME } actions = [] ARGV.clone. do |opts| opts.on("-i", "--init", String, "Initialise Branston") { opts.on("-w", "--working=directory", String, "Initialise branston in the given " + "directory", "Default: .branston") { |v| [:directory] =v } actions << 'init' } opts.on("-s", "--server", String, "Run a Branston Server") { opts.on("-p", "--port=port", Integer, "Runs Branston on the specified port.", "Default: #{PORT}") { |v| [:Port] = v } opts.on("-b", "--binding=ip", String, "Binds Branston to the specified ip.", "Default: 0.0.0.0") { |v| [:Host] = v } opts.on("-P", "--path=/path", String, "Runs Branston mounted at a " + "specific path.", "Default: /") { |v| [:path] = v } opts.on("-w", "--working=directory", String, "Run branston in the given " + "directory, the same directory that you branston --initialised into", "Default: .branston") { |v| [:directory] =v } opts.on("-fg", "--foreground", String) { |v| [:foreground] = true } actions << 'server' } opts.on("-g", "--generate", String, "Generate a feature from a Branston Server") { opts.on("-p", "--port=port", Integer, "Access a branston server on the specified port.", "Default: #{PORT}") { |v| [:Port] = v } opts.on("-b", "--binding=ip", String, "Access a branston server on the specified ip.", "Default: 0.0.0.0") { |v| [:Host] = v } opts.on("-f", "--feature=name", String, "Generate a feature for the given story regular expression.") { |v| [:feature] = v } actions << 'generator' } opts.separator "" opts.on("-h", "--help", "Show this help message.") { puts opts; exit } opts.parse! if ARGV.empty? or actions.size != 1 puts opts; exit end end if actions.first == 'server' launch_branston_server() elsif actions.first == 'generator' client = Client.new() client.generate_story_files client.errors.each do |error| puts error end elsif actions.first == 'init' initialise_branston() end end |