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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd4c07e96bdf6326edef6857e3333478cf4518b6
4
- data.tar.gz: ab060170632721a5ee8d6b993713101fe73296cd
3
+ metadata.gz: b916efe568514474c9fd9aba9c80a809cf0fb12a
4
+ data.tar.gz: 56b4428e2fdd46c42387d169e78ee231288e467b
5
5
  SHA512:
6
- metadata.gz: b6c2665dedb53a32d894996d4e5e8e4928d1849608d45116d4e7e904bf1aefb6a2844d0d54f7e5b3f1f289c2d65126969b5158974673b642c316ffce0c0627f0
7
- data.tar.gz: 5c2c4475640c6503c54faa35e33a93a2530c5d140a09443811a26adf4d7a652e4d154cd69a4c096ce79ccaed5ae954d9370bb929fcbbfc7317fae7f990899c5c
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.5.0...HEAD
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
@@ -2,18 +2,15 @@ require 'open3'
2
2
 
3
3
  class HuginnAgent
4
4
  class Helper
5
- def self.open3(command, streaming_output = true)
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
- data = stdout.read_nonblock(1024)
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 ../*_spec.rb,../{[!huginn/]}**/*_spec.rb", 'Running specs ...', true
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
- HuginnAgent::Helper.open3(command, streaming_output)
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
@@ -1,3 +1,3 @@
1
1
  class HuginnAgent
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
data/lib/tasks/spec.rake CHANGED
@@ -10,6 +10,7 @@ desc "Setup Huginn source, install gems and create the database"
10
10
  task :prepare do
11
11
  runner.clone
12
12
  runner.reset
13
+ runner.patch
13
14
  runner.bundle
14
15
  runner.database
15
16
  end
@@ -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", false)
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", 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", false)
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.5.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-02-04 00:00:00.000000000 Z
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