tollgate 0.1.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 +7 -0
- data/.gitignore +11 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.md +24 -0
- data/README.md +127 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/tollgate +8 -0
- data/lib/tollgate.rb +18 -0
- data/lib/tollgate/cli.rb +19 -0
- data/lib/tollgate/errors.rb +6 -0
- data/lib/tollgate/errors/no_configuration.rb +23 -0
- data/lib/tollgate/reporter.rb +45 -0
- data/lib/tollgate/reporter/records.rb +15 -0
- data/lib/tollgate/runner.rb +50 -0
- data/lib/tollgate/runner/group.rb +40 -0
- data/lib/tollgate/version.rb +3 -0
- data/tollgate.gemspec +29 -0
- metadata +137 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 94d233fa9f7310bce51a6d0cf61154cdf049cc21
|
|
4
|
+
data.tar.gz: daea04c2bc3e1c9e3fa93a983f5bfe80fafaf16b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4d61be8dd37695e6663989f2f7a7b4ec2116ada5c8349b86853bb25941ed563cc2263cc00aa32ad5f4cbfcbc8c1efb955ea2af95b5b52dc7ea7a1656a6cf5eeb
|
|
7
|
+
data.tar.gz: 318b4e329bdd1619b6ad98a8b2867b3822465a941ba2106ddcbab9ba0945af09f493f138c974931e66a47c51183669b7dfafc90e38bfe36ea0d2965a079e3573
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.3.5
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at joe@joejames.io. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
tollgate (0.1.0)
|
|
5
|
+
dry-core (~> 0.4)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
byebug (10.0.0)
|
|
11
|
+
concurrent-ruby (1.0.5)
|
|
12
|
+
diff-lcs (1.3)
|
|
13
|
+
dry-core (0.4.4)
|
|
14
|
+
concurrent-ruby (~> 1.0)
|
|
15
|
+
rake (10.4.2)
|
|
16
|
+
rspec (3.7.0)
|
|
17
|
+
rspec-core (~> 3.7.0)
|
|
18
|
+
rspec-expectations (~> 3.7.0)
|
|
19
|
+
rspec-mocks (~> 3.7.0)
|
|
20
|
+
rspec-core (3.7.1)
|
|
21
|
+
rspec-support (~> 3.7.0)
|
|
22
|
+
rspec-expectations (3.7.0)
|
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
24
|
+
rspec-support (~> 3.7.0)
|
|
25
|
+
rspec-mocks (3.7.0)
|
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
27
|
+
rspec-support (~> 3.7.0)
|
|
28
|
+
rspec-support (3.7.1)
|
|
29
|
+
|
|
30
|
+
PLATFORMS
|
|
31
|
+
ruby
|
|
32
|
+
|
|
33
|
+
DEPENDENCIES
|
|
34
|
+
bundler (~> 1.16)
|
|
35
|
+
byebug (~> 10.0)
|
|
36
|
+
rake (~> 10.0)
|
|
37
|
+
rspec (~> 3.0)
|
|
38
|
+
tollgate!
|
|
39
|
+
|
|
40
|
+
BUNDLED WITH
|
|
41
|
+
1.16.1
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to http://unlicense.org/
|
data/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Tollgate
|
|
2
|
+
|
|
3
|
+
Have you paid your code toll? To get your code into the groomed and uniform metropolis
|
|
4
|
+
where the static analysers enforcers run the place then you need to put extra effort
|
|
5
|
+
and pay the code toll. Build a better future!
|
|
6
|
+
|
|
7
|
+
Making it easy to add static code analysers to your workflow.
|
|
8
|
+
Build a list of shell commands to execute and check your code locally and on your CI server.
|
|
9
|
+
|
|
10
|
+
For a successful tollgate check all the commands will return a zero exit code,
|
|
11
|
+
if any of the commands return a non-zero exit code then the tollgate will also
|
|
12
|
+
return a non-zero exit code, which when used on CI will fail the build.
|
|
13
|
+
|
|
14
|
+
## Quickstart
|
|
15
|
+
|
|
16
|
+
Add the gem to your project:
|
|
17
|
+
|
|
18
|
+
```rb
|
|
19
|
+
group :development do
|
|
20
|
+
gem "tollgate", require: false
|
|
21
|
+
end
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Define a configuration file at `config/tollgate_config.rb`
|
|
25
|
+
|
|
26
|
+
```rb
|
|
27
|
+
Tollgate.config do
|
|
28
|
+
check "rubocop"
|
|
29
|
+
check "brakeman"
|
|
30
|
+
check "rspec"
|
|
31
|
+
end
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Then use the `tollgate` command to run your tollgate:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
$ tollgate
|
|
38
|
+
# ... output from commands being check
|
|
39
|
+
|
|
40
|
+
PASS: rubocop
|
|
41
|
+
PASS: brakeman
|
|
42
|
+
FAIL rspec
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Grouping Commands
|
|
46
|
+
|
|
47
|
+
Sometimes you may want several checks to run regardless if one of them has failed,
|
|
48
|
+
so that you can make related changes before running the tollgate again.
|
|
49
|
+
|
|
50
|
+
For instance `rubocop` and `standard` check for Ruby and JavaScript
|
|
51
|
+
code styles and it makes sense for you to get the output of both of these at the same time.
|
|
52
|
+
Whereas `rubocop` and `rspec` are not related in their information, and running a test
|
|
53
|
+
suite takes longer, so you would probably like to get the tollgate to fail early so
|
|
54
|
+
that you can fix the style changes before running the tollgate again.
|
|
55
|
+
|
|
56
|
+
```rb
|
|
57
|
+
Tollgate.config do
|
|
58
|
+
group :styles do
|
|
59
|
+
check "rubocop"
|
|
60
|
+
check "standard | snazzy"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
check "rspec"
|
|
64
|
+
end
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
$ tollgate
|
|
69
|
+
# ... output from checks being run
|
|
70
|
+
|
|
71
|
+
PASS: rubocop
|
|
72
|
+
FAIL: standard | snazzy
|
|
73
|
+
NOT RUN: rspec
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
You do not need to specify a group name if you can't think of one, (naming things is hard!),
|
|
77
|
+
and you can specify as many as you like:
|
|
78
|
+
|
|
79
|
+
```rb
|
|
80
|
+
Tollgate.config do
|
|
81
|
+
group do
|
|
82
|
+
check "rubocop"
|
|
83
|
+
check "standard | snazzy"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
group do
|
|
87
|
+
check "brakeman"
|
|
88
|
+
check "rails_best_practices"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
check "rspec"
|
|
92
|
+
check "cucumber"
|
|
93
|
+
end
|
|
94
|
+
```
|
|
95
|
+
In the example above, if the first group fails then the second group will not be run, nor will
|
|
96
|
+
any checks that come later in the list, the output would look like:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
# ...
|
|
100
|
+
|
|
101
|
+
FAIL: rubocop
|
|
102
|
+
PASS: standard | snazzy
|
|
103
|
+
NOT RUN: brakeman
|
|
104
|
+
NOT RUN: rails_best_practices
|
|
105
|
+
NOT RUN: rspec
|
|
106
|
+
NOT RUN: cucumber
|
|
107
|
+
|
|
108
|
+
Tollgate failed.
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Development
|
|
112
|
+
|
|
113
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
114
|
+
|
|
115
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
116
|
+
|
|
117
|
+
## Contributing
|
|
118
|
+
|
|
119
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tollgate-ex. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
120
|
+
|
|
121
|
+
## Code of Conduct
|
|
122
|
+
|
|
123
|
+
Everyone interacting in the Tollgate::Ex project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tollgate-ex/blob/master/CODE_OF_CONDUCT.md).
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
This project uses an unlicense, all code is in the public domain, see LICENSE.md for more details.
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "tollgate"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/tollgate
ADDED
data/lib/tollgate.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "dry/core/constants"
|
|
2
|
+
require "tollgate/cli"
|
|
3
|
+
require "tollgate/runner"
|
|
4
|
+
require "tollgate/errors"
|
|
5
|
+
|
|
6
|
+
module Tollgate
|
|
7
|
+
class << self
|
|
8
|
+
attr_accessor :command_block
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.configure(&block)
|
|
12
|
+
self.command_block = block
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.reset!
|
|
16
|
+
self.command_block = nil
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/tollgate/cli.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Tollgate
|
|
2
|
+
module CLI
|
|
3
|
+
module_function
|
|
4
|
+
|
|
5
|
+
DEFAULT_CONFIG_PATH = "./config/tollgate_config.rb"
|
|
6
|
+
|
|
7
|
+
def call(config_path: DEFAULT_CONFIG_PATH)
|
|
8
|
+
load(config_path) if File.exist?(config_path)
|
|
9
|
+
|
|
10
|
+
reporter = Reporter.new
|
|
11
|
+
runner = Runner.new(reporter: reporter)
|
|
12
|
+
runner.(Tollgate.command_block || raise(Errors::NoConfiguration))
|
|
13
|
+
|
|
14
|
+
puts reporter.report(success: runner.success?)
|
|
15
|
+
|
|
16
|
+
runner.success?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Tollgate
|
|
2
|
+
module Errors
|
|
3
|
+
class NoConfiguration < StandardError
|
|
4
|
+
def message
|
|
5
|
+
<<~TEXT
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
ERROR: There is no configuration block defined for Tollgate
|
|
9
|
+
==========================================================
|
|
10
|
+
|
|
11
|
+
Create a file at `#{CLI::DEFAULT_CONFIG_PATH}` and define your tollgate using the `check` method:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Tollgate.configure do
|
|
15
|
+
check "an_executable_in_my_path"
|
|
16
|
+
check "another_executable_in_my_path"
|
|
17
|
+
end
|
|
18
|
+
```
|
|
19
|
+
TEXT
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require_relative "reporter/records"
|
|
2
|
+
|
|
3
|
+
module Tollgate
|
|
4
|
+
class Reporter
|
|
5
|
+
SUCCESS_OUTPUT = "Tollgate finished successfully"
|
|
6
|
+
FAILED_OUTPUT = "Tollgate failed"
|
|
7
|
+
|
|
8
|
+
Record = Struct.new(:command, :status)
|
|
9
|
+
|
|
10
|
+
attr_reader :records
|
|
11
|
+
def initialize
|
|
12
|
+
@records = Tollgate::Reporter::Records.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def record(command, status:)
|
|
16
|
+
@records << Record.new(command, status)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
STATUSES = {
|
|
20
|
+
success: "PASS",
|
|
21
|
+
failed: "FAIL",
|
|
22
|
+
not_run: "NOT RUN"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def report(success:)
|
|
26
|
+
run_result = success ? SUCCESS_OUTPUT : FAILED_OUTPUT
|
|
27
|
+
|
|
28
|
+
<<~OUTPUT
|
|
29
|
+
#{command_statuses.join}
|
|
30
|
+
#{run_result}
|
|
31
|
+
OUTPUT
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def command_statuses
|
|
37
|
+
@records.map do |record|
|
|
38
|
+
status = STATUSES.fetch(record.status)
|
|
39
|
+
<<~OUTPUT
|
|
40
|
+
#{status}: #{record.command}
|
|
41
|
+
OUTPUT
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require_relative "reporter"
|
|
2
|
+
require_relative "runner/group"
|
|
3
|
+
|
|
4
|
+
module Tollgate
|
|
5
|
+
class Runner
|
|
6
|
+
include Dry::Core::Constants
|
|
7
|
+
|
|
8
|
+
attr_reader :success
|
|
9
|
+
|
|
10
|
+
def initialize(reporter: Tollgate::Reporter.new)
|
|
11
|
+
@success = true
|
|
12
|
+
@reporter = reporter
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def success?
|
|
16
|
+
!!@success
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def failed?
|
|
20
|
+
!success?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def call(command_block)
|
|
24
|
+
instance_exec(&command_block)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def check(command_str)
|
|
28
|
+
return record_not_run(command_str) if failed?
|
|
29
|
+
@success = system(command_str)
|
|
30
|
+
|
|
31
|
+
if success?
|
|
32
|
+
@reporter.record(command_str, status: :success)
|
|
33
|
+
else
|
|
34
|
+
@reporter.record(command_str, status: :failed)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def group(group_name = Undefined, &command_block)
|
|
39
|
+
return if failed?
|
|
40
|
+
group_runner = Tollgate::Runner::Group.new(group_name, reporter: @reporter)
|
|
41
|
+
@success = group_runner.call(&command_block)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def record_not_run(command_str)
|
|
47
|
+
@reporter.record(command_str, status: :not_run)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Tollgate
|
|
2
|
+
class Runner
|
|
3
|
+
class Group
|
|
4
|
+
include Dry::Core::Constants
|
|
5
|
+
|
|
6
|
+
def initialize(name = Undefined, reporter: Tollgate::Reporter.new)
|
|
7
|
+
@name = name
|
|
8
|
+
@group_status = true
|
|
9
|
+
@reporter = reporter
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def group_success?
|
|
13
|
+
!!@group_status
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def group_failed?
|
|
17
|
+
!group_success?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def call(&command_block)
|
|
21
|
+
puts @name unless @name == Undefined
|
|
22
|
+
|
|
23
|
+
instance_exec(&command_block) if block_given?
|
|
24
|
+
|
|
25
|
+
@group_status
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def check(command_str)
|
|
29
|
+
result = system(command_str)
|
|
30
|
+
@group_status = result if group_success?
|
|
31
|
+
|
|
32
|
+
if result
|
|
33
|
+
@reporter.record(command_str, status: :success)
|
|
34
|
+
else
|
|
35
|
+
@reporter.record(command_str, status: :failed)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/tollgate.gemspec
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "tollgate/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "tollgate"
|
|
8
|
+
spec.version = Tollgate::VERSION
|
|
9
|
+
spec.authors = ["the-undefined"]
|
|
10
|
+
spec.email = ["joe@joejames.io"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Configure a pipeline of checks to run to pass / fail CI}
|
|
13
|
+
spec.description = %q{Easy way to integrate static analysers into your local and remote workflows.}
|
|
14
|
+
spec.homepage = "https://github.com/the-undefined/tollgate"
|
|
15
|
+
spec.license = 'Unlicense'
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
|
19
|
+
end
|
|
20
|
+
spec.bindir = "exe"
|
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
27
|
+
spec.add_development_dependency "byebug", "~> 10.0"
|
|
28
|
+
spec.add_runtime_dependency "dry-core", "~> 0.4"
|
|
29
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: tollgate
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- the-undefined
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-03-04 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: byebug
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '10.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '10.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: dry-core
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0.4'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0.4'
|
|
83
|
+
description: Easy way to integrate static analysers into your local and remote workflows.
|
|
84
|
+
email:
|
|
85
|
+
- joe@joejames.io
|
|
86
|
+
executables:
|
|
87
|
+
- tollgate
|
|
88
|
+
extensions: []
|
|
89
|
+
extra_rdoc_files: []
|
|
90
|
+
files:
|
|
91
|
+
- ".gitignore"
|
|
92
|
+
- ".ruby-version"
|
|
93
|
+
- ".travis.yml"
|
|
94
|
+
- CODE_OF_CONDUCT.md
|
|
95
|
+
- Gemfile
|
|
96
|
+
- Gemfile.lock
|
|
97
|
+
- LICENSE.md
|
|
98
|
+
- README.md
|
|
99
|
+
- Rakefile
|
|
100
|
+
- bin/console
|
|
101
|
+
- bin/setup
|
|
102
|
+
- exe/tollgate
|
|
103
|
+
- lib/tollgate.rb
|
|
104
|
+
- lib/tollgate/cli.rb
|
|
105
|
+
- lib/tollgate/errors.rb
|
|
106
|
+
- lib/tollgate/errors/no_configuration.rb
|
|
107
|
+
- lib/tollgate/reporter.rb
|
|
108
|
+
- lib/tollgate/reporter/records.rb
|
|
109
|
+
- lib/tollgate/runner.rb
|
|
110
|
+
- lib/tollgate/runner/group.rb
|
|
111
|
+
- lib/tollgate/version.rb
|
|
112
|
+
- tollgate.gemspec
|
|
113
|
+
homepage: https://github.com/the-undefined/tollgate
|
|
114
|
+
licenses:
|
|
115
|
+
- Unlicense
|
|
116
|
+
metadata: {}
|
|
117
|
+
post_install_message:
|
|
118
|
+
rdoc_options: []
|
|
119
|
+
require_paths:
|
|
120
|
+
- lib
|
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - ">="
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - ">="
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '0'
|
|
131
|
+
requirements: []
|
|
132
|
+
rubyforge_project:
|
|
133
|
+
rubygems_version: 2.5.2.1
|
|
134
|
+
signing_key:
|
|
135
|
+
specification_version: 4
|
|
136
|
+
summary: Configure a pipeline of checks to run to pass / fail CI
|
|
137
|
+
test_files: []
|