oncall 0.2.1 → 0.2.2

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: '07378ff6344fb59c22ac6927c7aeac9cfecabf1504e0bfcbb02871668c04c189'
4
- data.tar.gz: f2c98df8c24c08648db1dcff593b68c7bbd2517afae9e090a5728cbe5cca1b24
3
+ metadata.gz: cf6d8c043e6c45dbc145642e1e3c51668e0addb39027b85616a5bfe9fe0754c0
4
+ data.tar.gz: a0d8057d55beb01d63cb42368927a8b44c6b3145a3dda9fdccf6195fae5d459d
5
5
  SHA512:
6
- metadata.gz: ee21dc544043fed09ad3a1cb6f2e5f9a223aab9e8cddd685dbe95710cf5d04c06735654af782a9128bcff24c9f59010ef31834f26ae7b90134f1f7de0cb6368f
7
- data.tar.gz: e6290f30cbac7835eabae316ff9b82bb5a075d5d6cf7691cfb7be00840e1b89232896538f8d2f99b86482b3dbedcb25252e3c9932f17d5b649353fc19f4e988b
6
+ metadata.gz: f8b87c28d86ba180d209cc8af17a8c8703fee8100aae086c9c7385f5c525b11c76d9b2d29e853745b130753cc221b3270d39e6bc68c21cccee5d66c21003e182
7
+ data.tar.gz: b5bd98e87175f7400cefd1abdea81cc8042523b09300f7b5165fe945bc2bc225749c452dcf7a76ce1e9db29e0239f957dc382e9bf724d17d5509f70ebb569c0e
@@ -3,10 +3,6 @@ module Oncall
3
3
  class Config
4
4
  DEFAULT_PATTERN = '**{,/*/**}/*_oncall.rb'.freeze
5
5
 
6
- def initialize
7
- @files = []
8
- end
9
-
10
6
  def pattern
11
7
  DEFAULT_PATTERN
12
8
  end
@@ -1,3 +1,5 @@
1
+ require 'colorize'
2
+
1
3
  module Oncall
2
4
  module Core
3
5
  class Reporter
@@ -25,7 +27,14 @@ module Oncall
25
27
  def finish
26
28
  puts "\n\n"
27
29
  puts @messages
28
- puts "\n#{@results[:success]} passed, #{@results[:failure]} failed."
30
+
31
+ result = "\n#{@results[:success]} passed, #{@results[:failure]} failed.\n"
32
+
33
+ if success?
34
+ puts result.green
35
+ else
36
+ puts result.red
37
+ end
29
38
  end
30
39
 
31
40
  def success?
@@ -33,7 +42,7 @@ module Oncall
33
42
  end
34
43
 
35
44
  def report_empty_group
36
- print 'E'
45
+ print '*'
37
46
  @results[:empty] = @results[:empty] + 1
38
47
  end
39
48
 
@@ -1,3 +1,5 @@
1
+ require_relative '../dsl'
2
+
1
3
  module Oncall
2
4
  module Core
3
5
  class Wrapper
@@ -6,7 +8,7 @@ module Oncall
6
8
  end
7
9
 
8
10
  def run(reporter)
9
- Oncall::Core::Group.new.instance_eval File.read(@file)
11
+ Oncall::DSL::Group.new.instance_eval File.read(@file)
10
12
  end
11
13
  end
12
14
  end
data/lib/oncall/core.rb CHANGED
@@ -1,12 +1,8 @@
1
1
  module Oncall
2
2
  module Core
3
- require_relative 'core/assertion'
4
3
  require_relative 'core/config'
5
- require_relative 'core/group'
6
4
  require_relative 'core/reporter'
7
- require_relative 'core/request'
8
5
  require_relative 'core/runner'
9
- require_relative 'core/scenario'
10
6
  require_relative 'core/world'
11
7
  require_relative 'core/wrapper'
12
8
 
@@ -1,5 +1,5 @@
1
1
  module Oncall
2
- module Core
2
+ module DSL
3
3
  class Assertion
4
4
  def initialize(response, method, path)
5
5
  @reporter = Oncall::Core.reporter
@@ -0,0 +1,30 @@
1
+ module Oncall
2
+ module DSL
3
+ class Call
4
+ def initialize
5
+ @config = Oncall::Core.config
6
+ @http = Net::HTTP.new(@config.domain, @config.port)
7
+ @headers = { 'User-Agent' => "oncall/#{Oncall::VERSION}" }
8
+ end
9
+
10
+ def header(hash)
11
+ hash.each do |key, value|
12
+ @headers[key] = value
13
+ end
14
+ end
15
+
16
+ def get(path, &block)
17
+ request = Net::HTTP::Get.new(path)
18
+
19
+ @headers.each do |key, value|
20
+ request[key] = value
21
+ end
22
+
23
+ response = @http.request(request)
24
+
25
+ assertion = Oncall::DSL::Assertion.new(response, 'GET', path)
26
+ assertion.instance_exec(&block)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,13 +1,13 @@
1
1
  module Oncall
2
- module Core
2
+ module DSL
3
3
  class Group
4
4
  def initialize
5
5
  @reporter = Oncall::Core.reporter
6
6
  end
7
7
 
8
- def describe(&block)
8
+ def group(&block)
9
9
  if block_given?
10
- scenario = Oncall::Core::Scenario.new
10
+ scenario = Oncall::DSL::Call.new
11
11
  scenario.instance_exec &block
12
12
  else
13
13
  @reporter.report_empty_group
data/lib/oncall/dsl.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  module Oncall
2
2
  module DSL
3
+ require_relative 'dsl/assertion'
4
+ require_relative 'dsl/call'
5
+ require_relative 'dsl/group'
3
6
  end
4
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Oncall
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oncall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koen Woortman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-01 00:00:00.000000000 Z
11
+ date: 2019-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: json-schema
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -82,16 +96,15 @@ files:
82
96
  - lib/oncall/commands/run_command.rb
83
97
  - lib/oncall/commands/shell_command.rb
84
98
  - lib/oncall/core.rb
85
- - lib/oncall/core/assertion.rb
86
99
  - lib/oncall/core/config.rb
87
- - lib/oncall/core/group.rb
88
100
  - lib/oncall/core/reporter.rb
89
- - lib/oncall/core/request.rb
90
101
  - lib/oncall/core/runner.rb
91
- - lib/oncall/core/scenario.rb
92
102
  - lib/oncall/core/world.rb
93
103
  - lib/oncall/core/wrapper.rb
94
104
  - lib/oncall/dsl.rb
105
+ - lib/oncall/dsl/assertion.rb
106
+ - lib/oncall/dsl/call.rb
107
+ - lib/oncall/dsl/group.rb
95
108
  - lib/oncall/http.rb
96
109
  - lib/oncall/templates/oncall.yml.template
97
110
  - lib/oncall/version.rb
@@ -1,13 +0,0 @@
1
- module Oncall
2
- module Core
3
- class Request
4
- def initialize(&block)
5
- @proc = Proc.new &block
6
- end
7
-
8
- def call
9
- @proc.call
10
- end
11
- end
12
- end
13
- end
@@ -1,18 +0,0 @@
1
- module Oncall
2
- module Core
3
- class Scenario
4
- def initialize
5
- @config = Oncall::Core.config
6
- @http = Net::HTTP.new(@config.domain, @config.port)
7
- end
8
-
9
- def get(path, &block)
10
- request = Net::HTTP::Get.new(path)
11
- response = @http.request(request)
12
-
13
- assertion = Oncall::Core::Assertion.new(response, 'GET', path)
14
- assertion.instance_exec(&block)
15
- end
16
- end
17
- end
18
- end