devloop 0.0.1 → 0.0.2

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
  SHA256:
3
- metadata.gz: 5c58cf90575fbc861048dba5e43e4b2498248c2a955931f0336e161168759512
4
- data.tar.gz: d86a34e42e0f9851c79acaced99f54f1ad0468f1b0d301aa92394420fa238344
3
+ metadata.gz: f2dab016e7249d6883987e3d5cebb59e0d08e644884ee3c54320e44ac84cee8d
4
+ data.tar.gz: 4cd78a1c396874542cf1c0790c2b94c3366a5355f26cf206806a1bfb28c06522
5
5
  SHA512:
6
- metadata.gz: 3cc7f78b87bf3dadf84392a795feecb8aade84578e784e8a4b5e330a4bad9d043383882a17173c64453298c7e2e376d2875804fa8b39e1fa903ba9f4553e645d
7
- data.tar.gz: 3b6e4772b2f595bb78824dcbc6008d09f87eee2198e1b38f95ef66abd51cb8e8e2d31f1adf4bfa37b09d7d9a253cd659ae39dd749de53e0b5deb106203f487b3
6
+ metadata.gz: b8f7cee13c1094e4d7214083f102e2274d279211fe8956784fa847406f19387a734ef0357cb1b7db2052e60d5e7fcbb5dc60f56e24ad93d37baf4d32760b650e
7
+ data.tar.gz: 839f53f6b4f803454b7722c70b827aa3f5abf73a7c5763231f442d590741d29364b7d95ce7bf07e8abdc6082465e0d57616572590e382208e24b9952991d7389
data/bin/devloop ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib") unless $LOAD_PATH.include?(File.dirname(__FILE__) + "/../lib")
5
+
6
+ require "devloop"
7
+
8
+ begin
9
+ puts "Devloop: watching for changes in spec directory..."
10
+ system("fswatch -e '.*' -i '\.rb$' #{Dir.pwd}/spec | xargs -n1 -I{} bundle exec devloop_run")
11
+ rescue Interrupt # user pressed CTRL+C
12
+ STDERR.puts "\nDevloop: exiting due to user request"
13
+ exit 130
14
+ end
data/bin/devloop_run ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib") unless $LOAD_PATH.include?(File.dirname(__FILE__) + "/../lib")
3
+
4
+ require "devloop"
5
+ begin
6
+ require "spring/env"
7
+ rescue LoadError
8
+ # Spring not available
9
+ end
10
+
11
+ begin
12
+ diff = `git diff -U0 spec/`
13
+ if diff == ""
14
+ diff = `git diff HEAD~1 -U0 spec/`
15
+ end
16
+
17
+ tests = Devloop::DiffParser.call(diff)
18
+ puts "Devloop running tests:"
19
+ if tests.length == 0
20
+ puts "No tests to run"
21
+ return
22
+ end
23
+ puts tests
24
+ command = if defined?(Spring) && Spring::Env.new.server_running?
25
+ "spring rspec"
26
+ else
27
+ "rspec"
28
+ end
29
+ system("bundle exec #{command} #{tests.join(" ")}")
30
+ rescue Interrupt # user pressed CTRL+C
31
+ STDERR.puts "\nDevloop: exiting due to user request"
32
+ exit 130
33
+ end
data/devloop.gemspec CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.test_files = s.files.grep(%r{^(spec)/})
16
16
  s.require_paths = ["lib"]
17
+ s.executables = ["devloop", "devloop_run"]
17
18
  s.license = "MIT"
18
19
  s.add_development_dependency "rake"
19
20
  s.add_development_dependency "rspec"
@@ -0,0 +1,22 @@
1
+ module Devloop
2
+ class DiffParser
3
+ def self.call(diff)
4
+ new.call(diff)
5
+ end
6
+
7
+ def call(diff)
8
+ lines = diff.split("\n")
9
+ results = []
10
+ lines.each_with_index do |line, index|
11
+ if line.start_with?("+++ b/")
12
+ file = line[6..-1]
13
+ if lines[index + 1] && lines[index + 1].start_with?("@@ -")
14
+ line_number = lines[index + 1].split(" ")[1].split(",")[0][1..-1]
15
+ results << "#{file}:#{line_number}"
16
+ end
17
+ end
18
+ end
19
+ results
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Devloop
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
data/lib/devloop.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "devloop/diff_parser"
4
+
3
5
  module Devloop
4
6
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+ require "devloop/diff_parser"
5
+
6
+ describe Devloop::DiffParser do
7
+ let(:diff) do
8
+ <<~DIFF
9
+ diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb
10
+ index 19772f2a..a32824f9 100644
11
+ --- a/spec/models/team_spec.rb
12
+ +++ b/spec/models/team_spec.rb
13
+ @@ -10,2 +10,2 @@ describe Team do
14
+ - it "has a valid factory" do
15
+ - expect(team).to be_valid
16
+ + it "has valid factory" do
17
+ + expect(team).not_to be_valid
18
+ diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
19
+ index 410ffa8c..610d9e19 100644
20
+ --- a/spec/models/user_spec.rb
21
+ +++ b/spec/models/user_spec.rb
22
+ @@ -167 +167 @@ describe User do
23
+ - web_auth_token_generated_at: 50.minutes.ago,
24
+ + web_auth_token_generated_at: 10.minutes.ago,
25
+ DIFF
26
+ end
27
+
28
+ it "parses the diff correctly" do
29
+ expect(Devloop::DiffParser.call(diff)).to eq(["spec/models/team_spec.rb:10", "spec/models/user_spec.rb:167"])
30
+ end
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devloop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
@@ -56,7 +56,9 @@ description: " This simple tool allows to run apps tests based on current git di
56
56
  output. "
57
57
  email:
58
58
  - contact@pawelurbanek.com
59
- executables: []
59
+ executables:
60
+ - devloop
61
+ - devloop_run
60
62
  extensions: []
61
63
  extra_rdoc_files: []
62
64
  files:
@@ -65,10 +67,13 @@ files:
65
67
  - LICENSE.txt
66
68
  - README.md
67
69
  - Rakefile
70
+ - bin/devloop
71
+ - bin/devloop_run
68
72
  - devloop.gemspec
69
73
  - lib/devloop.rb
74
+ - lib/devloop/diff_parser.rb
70
75
  - lib/devloop/version.rb
71
- - spec/smoke_spec.rb
76
+ - spec/diff_parser_spec.rb
72
77
  - spec/spec_helper.rb
73
78
  homepage: https://github.com/pawurb/devloop
74
79
  licenses:
@@ -95,5 +100,5 @@ signing_key:
95
100
  specification_version: 4
96
101
  summary: Ruby test runner
97
102
  test_files:
98
- - spec/smoke_spec.rb
103
+ - spec/diff_parser_spec.rb
99
104
  - spec/spec_helper.rb
data/spec/smoke_spec.rb DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe Devloop do
6
- end