dirty 0.0.3 → 0.0.4

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.
Files changed (4) hide show
  1. data/README.md +5 -2
  2. data/lib/dirty.rb +42 -13
  3. data/lib/dirty/version.rb +1 -1
  4. metadata +2 -2
data/README.md CHANGED
@@ -1,12 +1,15 @@
1
1
  dirty
2
2
  =====
3
3
 
4
- Easily run dirty (changed, untracked, added) cucumber features in the current directory when using Git.
4
+ Easily run dirty (changed, untracked, added) specs and/or features in the
5
+ current directory when using Git.
5
6
 
6
7
  Usage:
7
8
 
8
9
  $ gem install dirty
9
- $ dirty
10
+ $ dirty # specs and features
11
+ $ dirty spec # just specs
12
+ $ dirty feature # just features
10
13
 
11
14
  Credits:
12
15
 
@@ -1,29 +1,58 @@
1
1
  module Dirty
2
2
  extend self
3
3
 
4
- def status
5
- `git status --porcelain`.split("\n")
4
+ def perform
5
+ commands.any? ? run_commands : 0
6
6
  end
7
7
 
8
- def dirty_files
9
- status.reject { |f| f[/^ D/] }
8
+ def run_commands
9
+ commands.each { |c| puts(c); system(c) }
10
+ $?.exitstatus
11
+ end
12
+
13
+ def commands
14
+ case type
15
+ when /feature/
16
+ [cucumber]
17
+ when /spec/
18
+ [rspec]
19
+ else
20
+ [rspec, cucumber]
21
+ end.compact
22
+ end
23
+
24
+ def type
25
+ @type ||= ARGV[0]
26
+ end
27
+
28
+ def rspec
29
+ "rspec #{dirty_specs.join(' ')}" if dirty_specs.any?
30
+ end
31
+
32
+ def cucumber
33
+ "cucumber #{dirty_features.join(' ')}" if dirty_features.any?
10
34
  end
11
35
 
12
36
  def dirty_features
37
+ dirty_matches(/(features.*\.feature)/)
38
+ end
39
+
40
+ def dirty_specs
41
+ dirty_matches(/(spec.*\_spec.rb)/)
42
+ end
43
+
44
+ def dirty_matches(regex)
13
45
  dirty_files.map do |s|
14
- s[/(features.*\.feature)/]
46
+ s[regex]
15
47
  end.compact
16
48
  end
17
49
 
18
- def perform
19
- return 0 if dirty_features.empty?
20
-
21
- command = "cucumber #{dirty_features * ' '}"
22
- puts command
23
- system command
50
+ def dirty_files
51
+ status.reject { |f| f[/^ D/] }
52
+ end
24
53
 
25
- # Return cucumber's error status.
26
- $?.exitstatus
54
+ def status
55
+ `git status --porcelain`.split("\n")
27
56
  end
28
57
 
29
58
  end
@@ -1,3 +1,3 @@
1
1
  module Dirty
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dirty
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Robert Pitts
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-10 00:00:00 -04:00
13
+ date: 2011-04-19 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies: []
16
16