webcmd 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/lib/webcmd/app.rb +4 -4
- data/lib/webcmd/command_runner.rb +7 -2
- data/lib/webcmd/options.rb +1 -1
- data/lib/webcmd/version.rb +1 -1
- data/test/app_test.rb +6 -0
- metadata +31 -47
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7bbe36a582b4e131b0ebe9c642c1da871e00ab57
|
4
|
+
data.tar.gz: 1b3b9e1faf9b7ef0a9d51520f2f5dc9df8609ad4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bf1f168133242212f858bd7a68d65a17e2fe467c3d41ab869292c9dc3f32f81c1982b6fb51c1901ae1493ad6e1dafdf2753b6d90bb0d62dc063f2c4a19eb5912
|
7
|
+
data.tar.gz: 0364a630a9d63f031dfda758a519dcc532e0039833248ea4bd2331c419bdd6a3535fe370dc9116bcdd1a9e2176dc25becbab78788d6e9c55540ff739fedd31b4
|
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
gemspec
|
data/Gemfile.lock
CHANGED
data/lib/webcmd/app.rb
CHANGED
@@ -8,8 +8,9 @@ module Webcmd
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(env)
|
11
|
-
|
12
|
-
|
11
|
+
req = Rack::Request.new(env)
|
12
|
+
if token_valid?(req)
|
13
|
+
[200, {'Content-Type' => 'text/plain'}, CommandRunner.new(@command, req.params)]
|
13
14
|
else
|
14
15
|
[403, {'Content-Type' => 'text/plain'}, ['Token invalid']]
|
15
16
|
end
|
@@ -17,8 +18,7 @@ module Webcmd
|
|
17
18
|
|
18
19
|
private
|
19
20
|
|
20
|
-
def token_valid?(
|
21
|
-
req = Rack::Request.new(env)
|
21
|
+
def token_valid?(req)
|
22
22
|
req.params['token'] == @token
|
23
23
|
end
|
24
24
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Webcmd
|
2
2
|
class CommandRunner
|
3
|
-
def initialize(command)
|
3
|
+
def initialize(command, params = {})
|
4
4
|
@command = command
|
5
|
+
@params = params
|
5
6
|
end
|
6
7
|
|
7
8
|
def each(&block)
|
@@ -15,7 +16,11 @@ module Webcmd
|
|
15
16
|
private
|
16
17
|
|
17
18
|
def shell_env
|
18
|
-
Hash[ENV.keys.grep(/^BUNDLE_/).map { |k| [k, nil] }]
|
19
|
+
Hash[ENV.keys.grep(/^BUNDLE_/).map { |k| [k, nil] }].tap do |env|
|
20
|
+
@params.each_pair do |name, value|
|
21
|
+
env["WEBCMD_#{name.upcase}"] = value
|
22
|
+
end
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
data/lib/webcmd/options.rb
CHANGED
@@ -10,7 +10,7 @@ module Webcmd
|
|
10
10
|
opts.banner = "Usage: webcmd [options]"
|
11
11
|
|
12
12
|
opts.on '-o', '--host HOST', 'listen on HOST (default: 0.0.0.0)' do |host|
|
13
|
-
options[:Host] = host
|
13
|
+
@options[:Host] = host
|
14
14
|
end
|
15
15
|
|
16
16
|
opts.on '-p', '--port PORT', 'use PORT (default: 9292)' do |port|
|
data/lib/webcmd/version.rb
CHANGED
data/test/app_test.rb
CHANGED
@@ -49,5 +49,11 @@ module Webcmd
|
|
49
49
|
get '/', token: '1234'
|
50
50
|
assert_equal 403, last_response.status
|
51
51
|
end
|
52
|
+
|
53
|
+
def test_pass_env_var
|
54
|
+
options[:command] = 'echo $WEBCMD_TEST_VAR'
|
55
|
+
get '/', test_var: 'test'
|
56
|
+
assert_equal 'test', last_response.body.strip
|
57
|
+
end
|
52
58
|
end
|
53
59
|
end
|
metadata
CHANGED
@@ -1,78 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webcmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sergey Nartimov
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
type: :runtime
|
16
|
-
version_requirements: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 1.4.1
|
22
|
-
prerelease: false
|
23
14
|
name: rack
|
24
15
|
requirement: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
16
|
requirements:
|
27
|
-
- - ~>
|
17
|
+
- - "~>"
|
28
18
|
- !ruby/object:Gem::Version
|
29
19
|
version: 1.4.1
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
20
|
type: :runtime
|
21
|
+
prerelease: false
|
32
22
|
version_requirements: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
23
|
requirements:
|
35
|
-
- - ~>
|
24
|
+
- - "~>"
|
36
25
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.
|
38
|
-
|
26
|
+
version: 1.4.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
39
28
|
name: puma
|
40
29
|
requirement: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
30
|
requirements:
|
43
|
-
- - ~>
|
31
|
+
- - "~>"
|
44
32
|
- !ruby/object:Gem::Version
|
45
33
|
version: 1.6.3
|
46
|
-
|
47
|
-
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
48
36
|
version_requirements: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
37
|
requirements:
|
51
|
-
- -
|
38
|
+
- - "~>"
|
52
39
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
54
|
-
|
40
|
+
version: 1.6.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
55
42
|
name: rake
|
56
43
|
requirement: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
44
|
requirements:
|
59
|
-
- -
|
45
|
+
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
47
|
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
48
|
type: :development
|
49
|
+
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
51
|
requirements:
|
67
|
-
- -
|
52
|
+
- - ">="
|
68
53
|
- !ruby/object:Gem::Version
|
69
54
|
version: '0'
|
70
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
71
56
|
name: rack-test
|
72
57
|
requirement: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
58
|
requirements:
|
75
|
-
- -
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
description: Run shell command through HTTP
|
@@ -83,7 +74,7 @@ executables:
|
|
83
74
|
extensions: []
|
84
75
|
extra_rdoc_files: []
|
85
76
|
files:
|
86
|
-
- .gitignore
|
77
|
+
- ".gitignore"
|
87
78
|
- Gemfile
|
88
79
|
- Gemfile.lock
|
89
80
|
- MIT-LICENSE
|
@@ -102,33 +93,26 @@ files:
|
|
102
93
|
- webcmd.gemspec
|
103
94
|
homepage: https://github.com/brainspec/webcmd
|
104
95
|
licenses: []
|
96
|
+
metadata: {}
|
105
97
|
post_install_message:
|
106
98
|
rdoc_options: []
|
107
99
|
require_paths:
|
108
100
|
- lib
|
109
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
102
|
requirements:
|
112
|
-
- -
|
103
|
+
- - ">="
|
113
104
|
- !ruby/object:Gem::Version
|
114
|
-
segments:
|
115
|
-
- 0
|
116
|
-
hash: 2381652511498473721
|
117
105
|
version: '0'
|
118
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
107
|
requirements:
|
121
|
-
- -
|
108
|
+
- - ">="
|
122
109
|
- !ruby/object:Gem::Version
|
123
|
-
segments:
|
124
|
-
- 0
|
125
|
-
hash: 2381652511498473721
|
126
110
|
version: '0'
|
127
111
|
requirements: []
|
128
112
|
rubyforge_project:
|
129
|
-
rubygems_version:
|
113
|
+
rubygems_version: 2.2.2
|
130
114
|
signing_key:
|
131
|
-
specification_version:
|
115
|
+
specification_version: 4
|
132
116
|
summary: Run shell command through HTTP
|
133
117
|
test_files:
|
134
118
|
- test/app_test.rb
|