circleci-parallel 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8f45e02994f05608bc9d43299f08a24fad83822
4
- data.tar.gz: 1eacbf5a19c69c374ef56114053428f98ed83601
3
+ metadata.gz: 8b025b1e5a1648148df644b1070c33d2844af168
4
+ data.tar.gz: ab393445cfc80555f2f95cd88407868222a750be
5
5
  SHA512:
6
- metadata.gz: b7b266accba3b7152ed128e07306bd04edf985819600951bf2c38437cd23d7d7e6e273d39850f86f0c3814247af35acfa83e8a3ac2876f8b975b74feb757166e
7
- data.tar.gz: 2e8d863583c3d3195690f413945a0495d4ab1cbc57b758ca5a9f79b6a741b6267458c5b82e3cb4a70a14f7e1f9a8a1994079bdc9c273197fe2b3ba0ac9132d1f
6
+ metadata.gz: dd88017b0b1f553fd96969023b733f2f9c3262f470eac801d898b5cce5d0c8b764abef3be045e20d4747e4112eb6fca9d62b47c28549bc383c5c8dd42a62ca5c
7
+ data.tar.gz: 1c8022cc15999fa26de1a2804dceba4cea460b22d6c515e2f2f36f2bf2040a8b1f25c4dd27085e7002a7adde9d84a0400ac5e9c49c9e07706c7dfc3d050eb034
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## Development
4
+
5
+ ## v0.2.0
6
+
7
+ * Add mock mode for easier testing in other libraries using circleci-parallel.
8
+
9
+ ## v0.1.0
10
+
11
+ * Initial release.
data/Gemfile CHANGED
@@ -9,3 +9,7 @@ group :development, :test do
9
9
  gem 'rubocop', '~> 0.42'
10
10
  gem 'yard', '~> 0.9'
11
11
  end
12
+
13
+ group :test do
14
+ gem 'codeclimate-test-reporter', '~> 0.6'
15
+ end
data/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ [![Gem Version](http://img.shields.io/gem/v/circleci-parallel.svg?style=flat)](http://badge.fury.io/rb/circleci-parallel)
2
+ [![Dependency Status](http://img.shields.io/gemnasium/increments/circleci-parallel.svg?style=flat)](https://gemnasium.com/increments/circleci-parallel)
3
+ [![CircleCI](https://circleci.com/gh/increments/circleci-parallel.svg?style=shield)](https://circleci.com/gh/increments/circleci-parallel)
4
+ [![Coverage Status](https://img.shields.io/codeclimate/coverage/github/increments/circleci-parallel.svg)](https://codeclimate.com/github/increments/circleci-parallel/coverage)
5
+ [![Code Climate](https://img.shields.io/codeclimate/github/increments/circleci-parallel.svg?style=flat)](https://codeclimate.com/github/increments/circleci-parallel)
6
+
1
7
  # CircleCI::Parallel
2
8
 
3
9
  **CircleCI::Parallel** provides simple APIs for joining [CircleCI parallel nodes](https://circleci.com/docs/parallelism/)
@@ -17,7 +23,7 @@ And then execute:
17
23
  $ bundle install
18
24
  ```
19
25
 
20
- ## Basic Usage
26
+ ## Usage
21
27
 
22
28
  Before using CircleCI::Parallel:
23
29
 
@@ -81,6 +87,8 @@ CircleCI::Parallel.join
81
87
  p merged_data
82
88
  ```
83
89
 
90
+ See [API docs](http://www.rubydoc.info/gems/circleci-parallel) for more details.
91
+
84
92
  ## License
85
93
 
86
94
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -6,11 +6,15 @@ module CircleCI
6
6
  # @return [Boolean] whether progress messages should be outputted to STDOUT (default: false)
7
7
  attr_accessor :silent
8
8
 
9
+ # @return [Boolean] whether mock mode is enabled (default: false)
10
+ attr_accessor :mock_mode
11
+
9
12
  # @api private
10
13
  attr_reader :before_join_hook, :after_join_hook, :after_download_hook
11
14
 
12
15
  def initialize
13
16
  @silent = false
17
+ @mock_mode = false
14
18
  @before_join_hook = @after_join_hook = @after_download_hook = Hook.new
15
19
  end
16
20
 
@@ -4,6 +4,8 @@ require 'circleci/parallel/configuration'
4
4
  require 'circleci/parallel/node'
5
5
  require 'circleci/parallel/task/master'
6
6
  require 'circleci/parallel/task/slave'
7
+ require 'circleci/parallel/task/mock_master'
8
+ require 'circleci/parallel/task/mock_slave'
7
9
 
8
10
  module CircleCI
9
11
  module Parallel
@@ -51,9 +53,14 @@ module CircleCI
51
53
  end
52
54
 
53
55
  def task
54
- @task ||= begin
55
- task_class = current_node.master? ? Task::Master : Task::Slave
56
- task_class.new(current_node, configuration)
56
+ @task ||= task_class.new(current_node, configuration)
57
+ end
58
+
59
+ def task_class
60
+ if configuration.mock_mode
61
+ current_node.master? ? Task::MockMaster : Task::MockSlave
62
+ else
63
+ current_node.master? ? Task::Master : Task::Slave
57
64
  end
58
65
  end
59
66
  end
@@ -0,0 +1,30 @@
1
+ require 'circleci/parallel/task/base'
2
+
3
+ module CircleCI
4
+ module Parallel
5
+ module Task
6
+ # @api private
7
+ class MockMaster < Master
8
+ private
9
+
10
+ def downloaders
11
+ @downloaders ||= node.other_nodes.map { |other_node| MockDownloader.new(other_node) }
12
+ end
13
+
14
+ class MockDownloader < Downloader
15
+ def ready_for_download?
16
+ true
17
+ end
18
+
19
+ def scp
20
+ true
21
+ end
22
+
23
+ def mark_as_downloaded
24
+ File.write(DOWNLOAD_MARKER_FILE, '')
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,16 @@
1
+ require 'circleci/parallel/task/base'
2
+
3
+ module CircleCI
4
+ module Parallel
5
+ module Task
6
+ # @api private
7
+ class MockSlave < Slave
8
+ private
9
+
10
+ def downloaded?
11
+ true
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -2,7 +2,7 @@ module CircleCI
2
2
  module Parallel
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 1
5
+ MINOR = 2
6
6
  PATCH = 0
7
7
 
8
8
  def self.to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circleci-parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Nakayama
@@ -36,6 +36,7 @@ files:
36
36
  - ".rspec"
37
37
  - ".rubocop.yml"
38
38
  - ".yardopts"
39
+ - CHANGELOG.md
39
40
  - Gemfile
40
41
  - LICENSE.txt
41
42
  - README.md
@@ -52,6 +53,8 @@ files:
52
53
  - lib/circleci/parallel/node.rb
53
54
  - lib/circleci/parallel/task/base.rb
54
55
  - lib/circleci/parallel/task/master.rb
56
+ - lib/circleci/parallel/task/mock_master.rb
57
+ - lib/circleci/parallel/task/mock_slave.rb
55
58
  - lib/circleci/parallel/task/slave.rb
56
59
  - lib/circleci/parallel/version.rb
57
60
  homepage: https://github.com/increments/circleci-parallel