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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/snowman-io.rb +10 -2
- data/lib/snowman-io/api.rb +5 -1
- data/lib/snowman-io/options.rb +49 -0
- data/lib/snowman-io/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5915df4c6484d2e704368dbfc81c02e7ea0caed5
|
4
|
+
data.tar.gz: d48e211c6ccf678bebb1d8abecb30883c12cb7f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfe7424e13941763a5402f96099f6bbb3513a92b6fefbd7fe9bd09644b70a4d174636c97a8fbc6e2da05e00325cceceda4c60164934db8f8b40fad15fa26dd60
|
7
|
+
data.tar.gz: fb2d1e439c3d2ed9373b06f7aae780b18bf6ea3a4c182be4c4e7d36095734b0f869937863e671fb594a884447421cb6cf1db10712ca8f27cbe74f9c510648c9a
|
data/CHANGELOG.md
CHANGED
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
|
-
#
|
7
|
-
|
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
|
data/lib/snowman-io/api.rb
CHANGED
@@ -2,7 +2,11 @@ require 'sinatra'
|
|
2
2
|
|
3
3
|
module SnowmanIO
|
4
4
|
class API < Sinatra::Base
|
5
|
-
|
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
|
data/lib/snowman-io/version.rb
CHANGED
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.
|
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-
|
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
|