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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf6d8c043e6c45dbc145642e1e3c51668e0addb39027b85616a5bfe9fe0754c0
4
- data.tar.gz: a0d8057d55beb01d63cb42368927a8b44c6b3145a3dda9fdccf6195fae5d459d
3
+ metadata.gz: 97c624adba4e2e68cd74e7f5211d9118b61e5d790d634486699f68555d5b6665
4
+ data.tar.gz: b024f0d793c08c9effd162a07aff1da4ee073489d0ae184e0389f08ebcde6515
5
5
  SHA512:
6
- metadata.gz: f8b87c28d86ba180d209cc8af17a8c8703fee8100aae086c9c7385f5c525b11c76d9b2d29e853745b130753cc221b3270d39e6bc68c21cccee5d66c21003e182
7
- data.tar.gz: b5bd98e87175f7400cefd1abdea81cc8042523b09300f7b5165fe945bc2bc225749c452dcf7a76ce1e9db29e0239f957dc382e9bf724d17d5509f70ebb569c0e
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.shift)
15
+ Oncall::Commands::InitCommand.invoke(ARGV)
16
16
  when 'run'
17
- Oncall::Commands::RunCommand.invoke(ARGV.shift)
17
+ Oncall::Commands::RunCommand.invoke(ARGV)
18
18
  when 'shell'
19
- Oncall::Commands::ShellCommand.invoke(ARGV.shift)
19
+ Oncall::Commands::ShellCommand.invoke(ARGV)
20
20
  else
21
21
  Oncall::Commands::BaseCommand.invoke(ARGV)
22
22
  end
@@ -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
@@ -13,16 +13,27 @@ module Oncall
13
13
  end
14
14
 
15
15
  def self.run(args, err=$stderr, out=$stdout)
16
- # TODO: init options class
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
@@ -9,7 +9,7 @@ module Oncall
9
9
  STATUS_EMPTY = :empty
10
10
 
11
11
  class << self
12
- attr_writer :config, :world
12
+ attr_writer :config, :world, :reporter
13
13
  end
14
14
 
15
15
  def self.config
@@ -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
- request = Net::HTTP::Get.new(path)
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
@@ -5,7 +5,7 @@ module Oncall
5
5
  @reporter = Oncall::Core.reporter
6
6
  end
7
7
 
8
- def group(&block)
8
+ def group(name=nil, &block)
9
9
  if block_given?
10
10
  scenario = Oncall::DSL::Call.new
11
11
  scenario.instance_exec &block
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Oncall
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oncall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koen Woortman