snowman-io 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2a9421d22cc99d684211ce9e5c144562a5cdc70
4
- data.tar.gz: 23ab4919e522ea9db1902e789e8c3958a0d480c3
3
+ metadata.gz: 5915df4c6484d2e704368dbfc81c02e7ea0caed5
4
+ data.tar.gz: d48e211c6ccf678bebb1d8abecb30883c12cb7f8
5
5
  SHA512:
6
- metadata.gz: 1618a0d769762309100579e88c0f2578831780f2f0d855c80879572343c69ebdc9595e4886571d6dac8e0a93a756bf068629825814d74e41b6359b30f1552071
7
- data.tar.gz: 166870ff2ea6494e0ddda85ca31ca040bb79c9e56ec11f55ed62eae86e549c29694bb1ed99d414bae8dbb821e77380e72ed380b1ebf39a06c340bfef624f3d78
6
+ metadata.gz: cfe7424e13941763a5402f96099f6bbb3513a92b6fefbd7fe9bd09644b70a4d174636c97a8fbc6e2da05e00325cceceda4c60164934db8f8b40fad15fa26dd60
7
+ data.tar.gz: fb2d1e439c3d2ed9373b06f7aae780b18bf6ea3a4c182be4c4e7d36095734b0f869937863e671fb594a884447421cb6cf1db10712ca8f27cbe74f9c510648c9a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # SnowmanIO
2
2
 
3
+ Version 0.0.3 - 2014.11.30
4
+ - API changes: to run SnowManIO server fire command `snowman server`
5
+
3
6
  Version 0.0.2 - 2014.11.29
4
7
  - Add travis.ci support
5
8
  - Sinatra bases web UI scaffold
data/lib/snowman-io.rb CHANGED
@@ -1,9 +1,17 @@
1
1
  require "snowman-io/version"
2
2
  require "snowman-io/api"
3
+ require "snowman-io/options"
3
4
 
4
5
  module SnowmanIO
5
6
  def self.start
6
- # start Sinatra based Web UI
7
- API.run!
7
+ # parse options
8
+ options = Options.new.parse!(ARGV)
9
+
10
+ case options[:command]
11
+ when "server"
12
+ API.start(options)
13
+ else
14
+ abort "Unreacheable point. Please report the bug to https://github.com/snowman-io/snowman-io/issues"
15
+ end
8
16
  end
9
17
  end
@@ -2,7 +2,11 @@ require 'sinatra'
2
2
 
3
3
  module SnowmanIO
4
4
  class API < Sinatra::Base
5
- set :port, ENV['PORT'] || 4567
5
+ def self.start(options)
6
+ sinatra_options = {}
7
+ sinatra_options[:port] = options[:port]
8
+ run!(sinatra_options)
9
+ end
6
10
 
7
11
  get "/" do
8
12
  "SnowManIO Home Page"
@@ -0,0 +1,49 @@
1
+ require 'optparse'
2
+
3
+ module SnowmanIO
4
+ # Parse command line.
5
+ class Options
6
+ AVAILABLE_COMMANDS = %w[server]
7
+
8
+ def parse!(args)
9
+ options = default_options
10
+
11
+ opt_parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: snowman COMMAND [options]"
13
+
14
+ opts.separator ""
15
+ opts.separator "Commands"
16
+ opts.separator " server Run SnowManIO server"
17
+
18
+ opts.separator ""
19
+ opts.separator "Server options:"
20
+ opts.on("-p", "--port PORT", "use PORT (default: 4567)") do |port|
21
+ options[:port] = port.to_i
22
+ end
23
+
24
+ if args.empty?
25
+ puts opts
26
+ exit
27
+ end
28
+
29
+ options[:command] = args.shift
30
+ unless AVAILABLE_COMMANDS.include?(options[:command])
31
+ puts "Error: Command '#{options[:command]}' not recognized"
32
+ puts opts
33
+ exit
34
+ end
35
+ end
36
+
37
+ opt_parser.parse!(args)
38
+ options
39
+ end
40
+
41
+ private
42
+
43
+ def default_options
44
+ {
45
+ port: 4567
46
+ }
47
+ end
48
+ end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module SnowmanIO
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snowman-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Vakhov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-29 00:00:00.000000000 Z
12
+ date: 2014-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -81,6 +81,7 @@ files:
81
81
  - bin/snowman
82
82
  - lib/snowman-io.rb
83
83
  - lib/snowman-io/api.rb
84
+ - lib/snowman-io/options.rb
84
85
  - lib/snowman-io/version.rb
85
86
  - snowman-io.gemspec
86
87
  homepage: http://snowman.io