pact-mock_service 2.10.1 → 2.11.0

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: 8f1f71217eb757b58cda16f0410ebbbd2b6de982380e05a1d6a40f556c29df38
4
- data.tar.gz: 652799963b66d0bb8b6371080f1a01c8f9bc98f047c3013479125c86dc0928fd
3
+ metadata.gz: 747c96bb4d050f110fcce31d689e1d618bfca4bbd4ffcd80cb4cbfe9d2a73169
4
+ data.tar.gz: 32383ee0cdb1aa0a91d631f12c9f666a44d931244aa31d55e53eb54657a0f0bb
5
5
  SHA512:
6
- metadata.gz: dfc6d897b48f6a5a2e8dfb5ac113e44ab1d8da309f1bd11fb5939a95ee8f80cea0dbe2e055591eaa2d3112b53fbf381f561cae33a6e12e8635235d207bb5111c
7
- data.tar.gz: 507de0001545aaba8a96f1e10d7c26772d80aa0c819368e818149b493cdcf5b640c37ad498336ab8def5fa230109a05ee269a9680b3f5bc421a5000613989b56
6
+ metadata.gz: 0b2df396720759af740955a36889fd8874d6a0bfa54e1f49a88c1d3d923399927847830476cc0e610701f4ec9a89f8bd1b67dc1a4f0ed1cc5b1185f2f6c16426
7
+ data.tar.gz: a42b7aeedbc4cd54d8546be463eefef1bf63137c3c3bbdd7d84da433144b99a43dd48a1aafe8bd1df42165efd38f525a467765e749fe9d673d0110906da66722
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ <a name="v2.11.0"></a>
2
+ ### v2.11.0 (2018-08-28)
3
+
4
+
5
+ #### Features
6
+
7
+ * **stub-server**
8
+ * allow pacts to be loaded from a directory ([c5babe7](/../../commit/c5babe7))
9
+
10
+
1
11
  <a name="v2.10.1"></a>
2
12
  ### v2.10.1 (2018-08-21)
3
13
 
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module MockService
3
- VERSION = "2.10.1"
3
+ VERSION = "2.11.0"
4
4
  end
5
5
  end
@@ -10,16 +10,17 @@ module Pact
10
10
  module StubService
11
11
  class CLI < Pact::MockService::CLI::CustomThor
12
12
 
13
- desc 'PACT_URI ...', "Start a stub service with the given pact file(s)."
13
+ desc 'PACT_URI ...', "Start a stub service with the given pact file(s) or directory."
14
14
  long_desc <<-DOC
15
- Start a stub service with the given pact file(s). Pact URIs may be local file paths or HTTP.
15
+ Start a stub service with the given pact file(s) or directories. Pact URIs may be local
16
+ file or directory paths, or HTTP.
16
17
  Include any basic auth details in the URL using the format https://USERNAME:PASSWORD@URI.
17
18
  Where multiple matching interactions are found, the interactions will be sorted by
18
19
  response status, and the first one will be returned. This may lead to some non-deterministic
19
20
  behaviour. If you are having problems with this, please raise it on the pact-dev google group,
20
21
  and we can discuss some potential enhancements.
21
22
  Note that only versions 1 and 2 of the pact specification are currently fully supported.
22
- Pacts using the v3 format may be used, however, any matching features added in v4 will
23
+ Pacts using the v3 format may be used, however, any matching features added in v3 will
23
24
  currently be ignored.
24
25
  DOC
25
26
 
@@ -33,13 +34,16 @@ module Pact
33
34
  method_option :stub_pactfile_paths, hide: true
34
35
  method_option :monkeypatch, hide: true
35
36
 
36
- def service(*pactfiles)
37
- raise Thor::Error.new("Please provide an existing pact file to load") if pactfiles.empty?
37
+ def service(*pact_files)
38
38
  require 'pact/mock_service/run'
39
- options.stub_pactfile_paths = pactfiles
39
+ require 'pact/support/expand_file_list'
40
+
41
+ expanded_pact_files = file_list(pact_files)
42
+ raise Thor::Error.new("Please provide at least one pact file to load") if expanded_pact_files.empty?
43
+
40
44
  opts = Thor::CoreExt::HashWithIndifferentAccess.new
41
45
  opts.merge!(options)
42
- opts[:stub_pactfile_paths] = pactfiles
46
+ opts[:stub_pactfile_paths] = expanded_pact_files
43
47
  opts[:pactfile_write_mode] = 'none'
44
48
  MockService::Run.(opts)
45
49
  end
@@ -52,6 +56,12 @@ module Pact
52
56
  end
53
57
 
54
58
  default_task :service
59
+
60
+ no_commands do
61
+ def file_list(pact_files)
62
+ Pact::Support::ExpandFileList.call(pact_files)
63
+ end
64
+ end
55
65
  end
56
66
  end
57
67
  end
@@ -0,0 +1,26 @@
1
+ module Pact
2
+ module Support
3
+ module ExpandFileList
4
+ def self.call pact_files
5
+ pact_files
6
+ .collect{ |path| unixify_path(path) }
7
+ .collect{ | path | expand_path(path) }
8
+ .flatten
9
+ end
10
+
11
+ def self.unixify_path(path)
12
+ path.gsub(/\\+/, '/')
13
+ end
14
+
15
+ def self.expand_path(path)
16
+ if File.directory?(path)
17
+ Dir.glob(File.join(path, "*.json"))
18
+ elsif Dir.glob(path).any?
19
+ Dir.glob(path)
20
+ else
21
+ path
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-mock_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.1
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-08-21 00:00:00.000000000 Z
15
+ date: 2018-08-28 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rack
@@ -379,6 +379,7 @@ files:
379
379
  - lib/pact/mock_service/spawn.rb
380
380
  - lib/pact/mock_service/version.rb
381
381
  - lib/pact/stub_service/cli.rb
382
+ - lib/pact/support/expand_file_list.rb
382
383
  homepage: https://github.com/bethesque/pact-mock_service
383
384
  licenses:
384
385
  - MIT