huginn_agent 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/lib/huginn_agent/helper.rb +7 -5
- data/lib/huginn_agent/patches/gemfile_helper.rb +22 -0
- data/lib/huginn_agent/spec_runner.rb +14 -2
- data/lib/huginn_agent/version.rb +1 -1
- data/lib/tasks/spec.rake +1 -0
- data/spec/lib/huginn_agent/helper_spec.rb +16 -10
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b916efe568514474c9fd9aba9c80a809cf0fb12a
|
4
|
+
data.tar.gz: 56b4428e2fdd46c42387d169e78ee231288e467b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab3871b1d75cf6b96bf00f7126f19116f95bf058152dc6205736357c9aa7f35ba363b909bd41e7d70d2febbed2eafbdb847be59e0793c93fab3da476870021b8
|
7
|
+
data.tar.gz: ef5d58ea0fa7b36baa7d8afb128a64ac46cff0d03a2960c849a84772d141a07d3f863b6a92c7735f577b0a083b6a3bb5d3f9fa25ef3a017b037f3978306f0457
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,17 @@ All notable changes to this project will be documented in this file.
|
|
8
8
|
|
9
9
|
### Changed
|
10
10
|
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
## [0.6.0] - 2017-04-12
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
- Run the specs without redirecting STDOUT and STDIN which allows the usage of debuggers like `pry` (@dsander)
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
- Agent gem development dependencies are not available when running the specs (@mandrews)
|
20
|
+
- Nested spec files are not loaded when running the specs (@mandrews)
|
21
|
+
|
11
22
|
## [0.5.0] - 2017-02-04
|
12
23
|
|
13
24
|
### Added
|
@@ -60,7 +71,8 @@ All notable changes to this project will be documented in this file.
|
|
60
71
|
- First official and working release
|
61
72
|
|
62
73
|
|
63
|
-
[Unreleased]: https://github.com/cantino/huginn_agent/compare/v0.
|
74
|
+
[Unreleased]: https://github.com/cantino/huginn_agent/compare/v0.6.0...HEAD
|
75
|
+
[0.6.0]: https://github.com/cantino/huginn_agent/compare/v0.5.0...v0.6.0
|
64
76
|
[0.5.0]: https://github.com/cantino/huginn_agent/compare/v0.4.3...v0.5.0
|
65
77
|
[0.4.3]: https://github.com/cantino/huginn_agent/compare/v0.4.2...v0.4.3
|
66
78
|
[0.4.2]: https://github.com/cantino/huginn_agent/compare/v0.4.1...v0.4.2
|
data/lib/huginn_agent/helper.rb
CHANGED
@@ -2,18 +2,15 @@ require 'open3'
|
|
2
2
|
|
3
3
|
class HuginnAgent
|
4
4
|
class Helper
|
5
|
-
def self.open3(command
|
5
|
+
def self.open3(command)
|
6
6
|
output = ""
|
7
|
-
print "\n" if streaming_output
|
8
7
|
|
9
8
|
status = Open3.popen3(ENV, "#{command} 2>&1") do |stdin, stdout, _stderr, wait_thr|
|
10
9
|
stdin.close
|
11
10
|
|
12
11
|
until stdout.eof do
|
13
12
|
next unless IO.select([stdout])
|
14
|
-
|
15
|
-
print data if streaming_output
|
16
|
-
output << data
|
13
|
+
output << stdout.read_nonblock(1024)
|
17
14
|
end
|
18
15
|
wait_thr.value
|
19
16
|
end
|
@@ -21,5 +18,10 @@ class HuginnAgent
|
|
21
18
|
rescue IOError => e
|
22
19
|
return [1, "#{e} #{e.message}"]
|
23
20
|
end
|
21
|
+
|
22
|
+
def self.exec(command)
|
23
|
+
print "\n"
|
24
|
+
[system(ENV, command) == true ? 0 : 1, '']
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
# This Gemfile modification was generated by the `rake prepare` command
|
3
|
+
#
|
4
|
+
class GemfileHelper
|
5
|
+
def self.parse_huginn_agent_gems(dependencies)
|
6
|
+
base_path = File.expand_path('../../../', __FILE__)
|
7
|
+
gemspec = Dir["#{base_path}/*.gemspec"].first
|
8
|
+
previous_gems = Hash[dependencies.map { |dep| [dep.name, dep] }]
|
9
|
+
Gem::Specification.load(gemspec).development_dependencies.each do |args|
|
10
|
+
previous_gem = previous_gems[args.name]
|
11
|
+
if previous_gem
|
12
|
+
abort "Gem #{args.to_s} in #{gemspec} conflicts with huginn/Gemfile" unless previous_gem.match?(args.to_spec)
|
13
|
+
else
|
14
|
+
yield args.name, *args.requirements_list
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
GemfileHelper.parse_huginn_agent_gems(dependencies) do |args|
|
21
|
+
gem *args
|
22
|
+
end
|
@@ -21,6 +21,14 @@ class HuginnAgent
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def patch
|
25
|
+
Dir.chdir('spec/huginn') do
|
26
|
+
open('Gemfile', 'a') do |f|
|
27
|
+
f.puts File.read(File.join(__dir__, 'patches/gemfile_helper.rb'))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
24
32
|
def bundle
|
25
33
|
if File.exists?('.env')
|
26
34
|
shell_out "cp .env spec/huginn"
|
@@ -39,7 +47,7 @@ class HuginnAgent
|
|
39
47
|
|
40
48
|
def spec
|
41
49
|
Dir.chdir('spec/huginn') do
|
42
|
-
shell_out "bundle exec rspec -r #{File.join(__dir__, 'patches/coverage.rb')} --pattern
|
50
|
+
shell_out "bundle exec rspec -r #{File.join(__dir__, 'patches/coverage.rb')} --pattern '../**/*_spec.rb' --exclude-pattern './spec/**/*_spec.rb'", 'Running specs ...', true
|
43
51
|
end
|
44
52
|
end
|
45
53
|
|
@@ -49,7 +57,11 @@ class HuginnAgent
|
|
49
57
|
(status, output) = Bundler.with_clean_env do
|
50
58
|
ENV['ADDITIONAL_GEMS'] = "#{gem_name}(path: ../../)"
|
51
59
|
ENV['RAILS_ENV'] = 'test'
|
52
|
-
|
60
|
+
if streaming_output
|
61
|
+
HuginnAgent::Helper.exec(command)
|
62
|
+
else
|
63
|
+
HuginnAgent::Helper.open3(command)
|
64
|
+
end
|
53
65
|
end
|
54
66
|
|
55
67
|
if status == 0
|
data/lib/huginn_agent/version.rb
CHANGED
data/lib/tasks/spec.rake
CHANGED
@@ -4,28 +4,34 @@ describe HuginnAgent::Helper do
|
|
4
4
|
context '#open3' do
|
5
5
|
it "returns the exit status and output of the command" do
|
6
6
|
expect(HuginnAgent::Helper).not_to receive(:print)
|
7
|
-
(status, output) = HuginnAgent::Helper.open3("pwd"
|
8
|
-
expect(status).to eq(0)
|
9
|
-
expect(output).to eq("#{Dir.pwd}\n")
|
10
|
-
end
|
11
|
-
|
12
|
-
it "prints the output directly when specified" do
|
13
|
-
expect(HuginnAgent::Helper).to receive(:print).twice
|
14
|
-
(status, output) = HuginnAgent::Helper.open3("pwd", true)
|
7
|
+
(status, output) = HuginnAgent::Helper.open3("pwd")
|
15
8
|
expect(status).to eq(0)
|
16
9
|
expect(output).to eq("#{Dir.pwd}\n")
|
17
10
|
end
|
18
11
|
|
19
12
|
it "return 1 as the status for failing command" do
|
20
|
-
(status, output) = HuginnAgent::Helper.open3("false"
|
13
|
+
(status, output) = HuginnAgent::Helper.open3("false")
|
21
14
|
expect(status).to eq(1)
|
22
15
|
end
|
23
16
|
|
24
17
|
it "returns 1 when an IOError occurred" do
|
25
18
|
expect(IO).to receive(:select).and_raise(IOError)
|
26
|
-
(status, output) = HuginnAgent::Helper.open3("pwd"
|
19
|
+
(status, output) = HuginnAgent::Helper.open3("pwd")
|
27
20
|
expect(status).to eq(1)
|
28
21
|
expect(output).to eq('IOError IOError')
|
29
22
|
end
|
30
23
|
end
|
24
|
+
|
25
|
+
context '#exec' do
|
26
|
+
it "returns the exit status and output of the command" do
|
27
|
+
(status, output) = HuginnAgent::Helper.exec("pwd")
|
28
|
+
expect(status).to eq(0)
|
29
|
+
expect(output).to eq('')
|
30
|
+
end
|
31
|
+
|
32
|
+
it "return 1 as the status for failing command" do
|
33
|
+
(status, output) = HuginnAgent::Helper.exec("false")
|
34
|
+
expect(status).to eq(1)
|
35
|
+
end
|
36
|
+
end
|
31
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Cantino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/huginn_agent/cli/new.rb
|
125
125
|
- lib/huginn_agent/helper.rb
|
126
126
|
- lib/huginn_agent/patches/coverage.rb
|
127
|
+
- lib/huginn_agent/patches/gemfile_helper.rb
|
127
128
|
- lib/huginn_agent/spec_helper.rb
|
128
129
|
- lib/huginn_agent/spec_runner.rb
|
129
130
|
- lib/huginn_agent/templates/newagent/Gemfile.tt
|