jive 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/test.yml +17 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +35 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/test +7 -0
- data/exe/jive +3 -0
- data/jive.gemspec +32 -0
- data/lib/jive.rb +144 -0
- data/lib/jive/version.rb +3 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6281244f3600328a55a9a4e197933273d53201e499c012d0f920a93f7ee1e4e3
|
4
|
+
data.tar.gz: 59651c78078fbb18dbcf078648fd0f661ce51386e64c93b885cd16d9d04a8bc6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0b953652bf6867534fff58d96996d652b11087f8830660d3b0ba1466cf3f950076e95168237087173638f5bd701ea46be21b235f3cef14167b16c2226168f55
|
7
|
+
data.tar.gz: 52446f569a68c88aa2a75685b32fe96d2532f3074a183ebc26ae2ceb0b7b17fec17da412f10208e938b743b4888a5d40f4f5c60dfd8c5c85207c8be4d6580cd8
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: Ruby
|
2
|
+
on: [push]
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
build:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- uses: actions/checkout@v1
|
9
|
+
- name: Set up Ruby 2.6
|
10
|
+
uses: actions/setup-ruby@v1
|
11
|
+
with:
|
12
|
+
ruby-version: 2.6.x
|
13
|
+
- name: Build and test with Rake
|
14
|
+
run: |
|
15
|
+
gem install bundler
|
16
|
+
bundle install --jobs 4 --retry 3
|
17
|
+
./bin/test
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jive (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.9.0)
|
12
|
+
rspec-core (~> 3.9.0)
|
13
|
+
rspec-expectations (~> 3.9.0)
|
14
|
+
rspec-mocks (~> 3.9.0)
|
15
|
+
rspec-core (3.9.0)
|
16
|
+
rspec-support (~> 3.9.0)
|
17
|
+
rspec-expectations (3.9.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.9.0)
|
20
|
+
rspec-mocks (3.9.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.9.0)
|
23
|
+
rspec-support (3.9.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 2.0)
|
30
|
+
jive!
|
31
|
+
rake (~> 10.0)
|
32
|
+
rspec (~> 3.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 mo khan
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Jive
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jive`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'jive'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install jive
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jive.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "jive"
|
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/bin/test
ADDED
data/exe/jive
ADDED
data/jive.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "jive/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "jive"
|
7
|
+
spec.version = Jive::VERSION
|
8
|
+
spec.authors = ["mo khan"]
|
9
|
+
spec.email = ["mo.khan@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{The art just comes.}
|
12
|
+
spec.description = %q{The art just comes.}
|
13
|
+
spec.homepage = "https://github.com/mokhan/jive"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/mokhan/jive"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/mokhan/jive"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
end
|
data/lib/jive.rb
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
require "jive/version"
|
5
|
+
require "open3"
|
6
|
+
|
7
|
+
module Jive
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
def self.run(tasks)
|
11
|
+
Jive::BatchRunner.new.run(tasks)
|
12
|
+
end
|
13
|
+
|
14
|
+
module Popen
|
15
|
+
Result = Struct.new(:command, :stdout, :stderr, :status, :duration)
|
16
|
+
|
17
|
+
def self.popen(command, path = nil, env = {}, &block)
|
18
|
+
result = popen_with_detail(command, path, env, &block)
|
19
|
+
|
20
|
+
["#{result.stdout}#{result.stderr}", result.status&.exitstatus]
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.popen_with_detail(command, path = Dir.pwd, env = {})
|
24
|
+
FileUtils.mkdir_p(path) unless File.directory?(path)
|
25
|
+
|
26
|
+
captured_stdout = ''
|
27
|
+
captured_stderr = ''
|
28
|
+
exit_status = nil
|
29
|
+
start = Time.now
|
30
|
+
|
31
|
+
Open3.popen3(env.merge('PWD' => path), *Array(command), { chdir: path }) do |stdin, stdout, stderr, wait_thr|
|
32
|
+
out_reader = Thread.new { stdout.read }
|
33
|
+
err_reader = Thread.new { stderr.read }
|
34
|
+
|
35
|
+
yield(stdin) if block_given?
|
36
|
+
|
37
|
+
stdin.close
|
38
|
+
captured_stdout = out_reader.value
|
39
|
+
captured_stderr = err_reader.value
|
40
|
+
exit_status = wait_thr.value
|
41
|
+
end
|
42
|
+
Result.new(command, captured_stdout, captured_stderr, exit_status, Time.now - start)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class BatchRunner
|
47
|
+
attr_reader :runner, :stdout
|
48
|
+
|
49
|
+
def initialize(runner: Runner.new, stdout: STDOUT)
|
50
|
+
@runner = runner
|
51
|
+
@stdout = stdout
|
52
|
+
end
|
53
|
+
|
54
|
+
def run(tasks, verbose: true)
|
55
|
+
runner.run(tasks) do |command, &run|
|
56
|
+
stdout.puts
|
57
|
+
stdout.puts "$ #{command.join(' ')}"
|
58
|
+
result = run.call
|
59
|
+
stdout.print result.stdout if verbose
|
60
|
+
stdout.print result.stderr if verbose
|
61
|
+
stdout.puts "==> Finished in #{result.duration} seconds"
|
62
|
+
stdout.puts
|
63
|
+
end
|
64
|
+
stdout.puts '==================================================='
|
65
|
+
if runner.all_success_and_clean?
|
66
|
+
stdout.puts 'Passed successfully.'
|
67
|
+
return 0
|
68
|
+
elsif runner.all_success?
|
69
|
+
stdout.puts 'Passed successfully, but we have warnings:'
|
70
|
+
stdout.puts
|
71
|
+
emit_warnings
|
72
|
+
return 2
|
73
|
+
else
|
74
|
+
stdout.puts 'Something failed:'
|
75
|
+
emit_warnings
|
76
|
+
emit_errors
|
77
|
+
return 1
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def emit_warnings
|
84
|
+
runner.warned_results.each do |result|
|
85
|
+
stdout.puts
|
86
|
+
stdout.puts "**** #{result.command.join(' ')} had the following warning(s):"
|
87
|
+
stdout.puts
|
88
|
+
stdout.puts result.stderr
|
89
|
+
stdout.puts
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def emit_errors
|
94
|
+
runner.failed_results.each do |result|
|
95
|
+
stdout.puts
|
96
|
+
stdout.puts "**** #{result.command.join(' ')} failed with the following error(s):"
|
97
|
+
stdout.puts
|
98
|
+
stdout.puts result.stdout
|
99
|
+
stdout.puts result.stderr
|
100
|
+
stdout.puts
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class Runner
|
106
|
+
attr_reader :results
|
107
|
+
|
108
|
+
def initialize
|
109
|
+
@results = []
|
110
|
+
end
|
111
|
+
|
112
|
+
def run(commands, &block)
|
113
|
+
commands.each do |command|
|
114
|
+
block.call(command) do
|
115
|
+
cmd_result = Popen.popen_with_detail(command)
|
116
|
+
results << cmd_result
|
117
|
+
cmd_result
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def all_success_and_clean?
|
123
|
+
all_success? && all_stderr_empty?
|
124
|
+
end
|
125
|
+
|
126
|
+
def all_success?
|
127
|
+
results.all? { |result| result.status.success? }
|
128
|
+
end
|
129
|
+
|
130
|
+
def all_stderr_empty?
|
131
|
+
results.all? { |result| result.stderr.empty? }
|
132
|
+
end
|
133
|
+
|
134
|
+
def failed_results
|
135
|
+
results.reject { |result| result.status.success? }
|
136
|
+
end
|
137
|
+
|
138
|
+
def warned_results
|
139
|
+
results.select do |result|
|
140
|
+
result.status.success? && !result.stderr.empty?
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
data/lib/jive/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mo khan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-19 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: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
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
|
+
description: The art just comes.
|
56
|
+
email:
|
57
|
+
- mo.khan@gmail.com
|
58
|
+
executables:
|
59
|
+
- jive
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".github/workflows/test.yml"
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".travis.yml"
|
67
|
+
- Gemfile
|
68
|
+
- Gemfile.lock
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- bin/test
|
75
|
+
- exe/jive
|
76
|
+
- jive.gemspec
|
77
|
+
- lib/jive.rb
|
78
|
+
- lib/jive/version.rb
|
79
|
+
homepage: https://github.com/mokhan/jive
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata:
|
83
|
+
homepage_uri: https://github.com/mokhan/jive
|
84
|
+
source_code_uri: https://github.com/mokhan/jive
|
85
|
+
changelog_uri: https://github.com/mokhan/jive
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubygems_version: 3.0.3
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: The art just comes.
|
105
|
+
test_files: []
|