oncall 0.2.2 → 0.2.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/lib/oncall/cli.rb +3 -3
- data/lib/oncall/core/config.rb +15 -2
- data/lib/oncall/core/runner.rb +16 -5
- data/lib/oncall/core.rb +1 -1
- data/lib/oncall/dsl/call.rb +11 -1
- data/lib/oncall/dsl/group.rb +1 -1
- data/lib/oncall/http.rb +16 -0
- data/lib/oncall/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97c624adba4e2e68cd74e7f5211d9118b61e5d790d634486699f68555d5b6665
|
4
|
+
data.tar.gz: b024f0d793c08c9effd162a07aff1da4ee073489d0ae184e0389f08ebcde6515
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52eb1ea9450b1769ec6a2e2aeca4f44fb2b797fa73c31b36d52e2009d6a9937e8475ce466727d46540cf357562559891c5b121aef4747d842f7ba93a090976b2
|
7
|
+
data.tar.gz: 132efe00a5dc72ac7fc43ceabf92258de9abd3eb0a3918e6185f860a6eace498239e92efcb14d3b44880a8e5282a2d15d5f3c052986e1ba8fd21d8f4b831649a
|
data/lib/oncall/cli.rb
CHANGED
@@ -12,11 +12,11 @@ module Oncall
|
|
12
12
|
def self.run
|
13
13
|
case ARGV[0].to_s.downcase
|
14
14
|
when 'init'
|
15
|
-
Oncall::Commands::InitCommand.invoke(ARGV
|
15
|
+
Oncall::Commands::InitCommand.invoke(ARGV)
|
16
16
|
when 'run'
|
17
|
-
Oncall::Commands::RunCommand.invoke(ARGV
|
17
|
+
Oncall::Commands::RunCommand.invoke(ARGV)
|
18
18
|
when 'shell'
|
19
|
-
Oncall::Commands::ShellCommand.invoke(ARGV
|
19
|
+
Oncall::Commands::ShellCommand.invoke(ARGV)
|
20
20
|
else
|
21
21
|
Oncall::Commands::BaseCommand.invoke(ARGV)
|
22
22
|
end
|
data/lib/oncall/core/config.rb
CHANGED
@@ -3,6 +3,19 @@ module Oncall
|
|
3
3
|
class Config
|
4
4
|
DEFAULT_PATTERN = '**{,/*/**}/*_oncall.rb'.freeze
|
5
5
|
|
6
|
+
def initialize
|
7
|
+
@config = []
|
8
|
+
@env = 'develop'
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_config(config)
|
12
|
+
@config = config
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_env(env)
|
16
|
+
@env = env
|
17
|
+
end
|
18
|
+
|
6
19
|
def pattern
|
7
20
|
DEFAULT_PATTERN
|
8
21
|
end
|
@@ -12,11 +25,11 @@ module Oncall
|
|
12
25
|
end
|
13
26
|
|
14
27
|
def domain
|
15
|
-
'localhost'
|
28
|
+
@config[@env]['domain'] || 'localhost'
|
16
29
|
end
|
17
30
|
|
18
31
|
def port
|
19
|
-
4567
|
32
|
+
@config[@env]['port'] || 4567
|
20
33
|
end
|
21
34
|
|
22
35
|
def test_files
|
data/lib/oncall/core/runner.rb
CHANGED
@@ -13,16 +13,27 @@ module Oncall
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.run(args, err=$stderr, out=$stdout)
|
16
|
-
|
17
|
-
new.run(err, out)
|
16
|
+
new.run(args, err, out)
|
18
17
|
end
|
19
18
|
|
20
|
-
def run(err, out)
|
21
|
-
setup(err, out)
|
19
|
+
def run(args, err, out)
|
20
|
+
setup(args, err, out)
|
22
21
|
run_tests(@world.suite)
|
23
22
|
end
|
24
23
|
|
25
|
-
def setup(err, out)
|
24
|
+
def setup(args, err, out)
|
25
|
+
begin
|
26
|
+
config = YAML.load_file('oncall.yml')
|
27
|
+
rescue StandardError
|
28
|
+
puts 'Cannot load oncall.yml'
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
|
32
|
+
env = args[1] || config['default']
|
33
|
+
|
34
|
+
@config.set_config(config)
|
35
|
+
@config.set_env(env)
|
36
|
+
|
26
37
|
files = @config.test_files
|
27
38
|
@world.register_suite(files)
|
28
39
|
end
|
data/lib/oncall/core.rb
CHANGED
data/lib/oncall/dsl/call.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative '../http'
|
2
|
+
|
1
3
|
module Oncall
|
2
4
|
module DSL
|
3
5
|
class Call
|
@@ -5,6 +7,7 @@ module Oncall
|
|
5
7
|
@config = Oncall::Core.config
|
6
8
|
@http = Net::HTTP.new(@config.domain, @config.port)
|
7
9
|
@headers = { 'User-Agent' => "oncall/#{Oncall::VERSION}" }
|
10
|
+
@params = {}
|
8
11
|
end
|
9
12
|
|
10
13
|
def header(hash)
|
@@ -13,8 +16,15 @@ module Oncall
|
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
19
|
+
def param(hash)
|
20
|
+
hash.each do |key, value|
|
21
|
+
@params[key] = value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
16
25
|
def get(path, &block)
|
17
|
-
|
26
|
+
uri = Oncall::HTTP.uri(path, @params)
|
27
|
+
request = Net::HTTP::Get.new(uri)
|
18
28
|
|
19
29
|
@headers.each do |key, value|
|
20
30
|
request[key] = value
|
data/lib/oncall/dsl/group.rb
CHANGED
data/lib/oncall/http.rb
CHANGED
@@ -1,4 +1,20 @@
|
|
1
1
|
module Oncall
|
2
2
|
module HTTP
|
3
|
+
def self.uri(path, params)
|
4
|
+
parts = path.split('/')
|
5
|
+
|
6
|
+
if parts.empty?
|
7
|
+
return '/'
|
8
|
+
end
|
9
|
+
|
10
|
+
parts.each_with_index do |part, index|
|
11
|
+
if part.start_with?(':')
|
12
|
+
part[0] = ''
|
13
|
+
parts[index] = params[part.to_sym]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
parts.join('/')
|
18
|
+
end
|
3
19
|
end
|
4
20
|
end
|
data/lib/oncall/version.rb
CHANGED