testdiff 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 40b7d12a640156ca49a1459766a815f71940b586
4
+ data.tar.gz: 6964bca54d5b95b5d198c84237b7bdfe5d3199df
5
+ SHA512:
6
+ metadata.gz: 7f0fe6aa165d8f2acdc78d3b727edfe3070c01b93a2f6c27b5671e12b3162afcbb879e7944d35f84bd0730dd47f646715e4c122626f6f8638fb7bd48840b89fc
7
+ data.tar.gz: da30ba0a9226cc8a45081b16ca43322a9cfcf568d089a2fecc6822be985660d05bb3399cfb1ddbc0aa39dedd42c5256d296b274c4413bd73717d33809377ffa7
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # testdiff
2
+
3
+ Ruby gem to locally test only modified files.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+ ```ruby
9
+ gem 'testdiff'
10
+ ```
11
+
12
+ And then execute:
13
+ ```ruby
14
+ bundle
15
+ ```
16
+
17
+ Or install it yourself as:
18
+ ```ruby
19
+ gem install testdiff
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Run Rubocop and Rspec on all modified files:
25
+ ```ruby
26
+ testdiff
27
+ ```
28
+
29
+ Run Rubocop on all modified files:
30
+ ```ruby
31
+ testdiff rubocop
32
+ ```
33
+
34
+ Run Rspec on all modified files:
35
+ ```ruby
36
+ testdiff rspec
37
+ ```
data/bin/console ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/setup'
3
+ require 'testdiff'
4
+ require 'irb'
5
+
6
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+ bundle install
data/bin/testdiff ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'testdiff'
3
+ Testdiff.run(ARGV)
@@ -0,0 +1,14 @@
1
+ module Testdiff
2
+ module Modified
3
+ # Finds all modified Ruby files
4
+ module RubyFiles
5
+ module_function
6
+
7
+ def find
8
+ `git status --porcelain | cut -c4- | grep '.rb'`
9
+ .split("\n")
10
+ .select { |file| File.exist?(file) }
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ require 'testdiff/modified/ruby_files'
2
+
3
+ module Testdiff
4
+ module Modified
5
+ # Finds all modified Rspec files
6
+ module Specs
7
+ module_function
8
+
9
+ def find
10
+ modified.concat(associated)
11
+ .select { |file| File.exist?(file) }
12
+ end
13
+
14
+ # private
15
+
16
+ def modified
17
+ files.select { |file| file.include?('_spec.rb') }
18
+ end
19
+
20
+ def associated
21
+ files.map do |file|
22
+ file.gsub('.rb', '_spec.rb')
23
+ .gsub('app/', 'spec/')
24
+ .gsub('lib/', 'spec/lib/')
25
+ end
26
+ end
27
+
28
+ def files
29
+ Testdiff::Modified::RubyFiles.find
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ require 'testdiff/modified/specs'
2
+
3
+ module Testdiff
4
+ # Runs Rspec on modified files
5
+ module Rspec
6
+ module_function
7
+
8
+ def run
9
+ puts 'Running RSpec on modified files...'
10
+ files = Testdiff::Modified::Specs.find
11
+ if files.any?
12
+ exec "rspec #{files.join(' ')}"
13
+ else
14
+ puts 'No modified specs.'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'testdiff/modified/ruby_files'
2
+
3
+ module Testdiff
4
+ # Runs Rubocop on modified files
5
+ module Rubocop
6
+ module_function
7
+
8
+ def run
9
+ puts 'Running Rubocop on modified files...'
10
+ files = Testdiff::Modified::RubyFiles.find
11
+ if files.any?
12
+ system "rubocop #{files.join(' ')}"
13
+ else
14
+ puts 'No modified Ruby files.'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ # The current version of this gem
2
+ module Testdiff
3
+ VERSION = '0.1.0'.freeze
4
+ end
data/lib/testdiff.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'testdiff/version'
2
+ require 'testdiff/rubocop'
3
+ require 'testdiff/rspec'
4
+
5
+ # Tests modified files
6
+ module Testdiff
7
+ module_function
8
+
9
+ def run(tests)
10
+ if tests.empty?
11
+ run(%w(rubocop rspec))
12
+ else
13
+ tests.each do |test|
14
+ run_test(test)
15
+ puts
16
+ end
17
+ end
18
+ end
19
+
20
+ # private
21
+
22
+ def run_test(test)
23
+ case test.to_s.downcase
24
+ when 'rubocop'
25
+ Rubocop.run
26
+ when 'rspec'
27
+ Rspec.run
28
+ else
29
+ puts "Unknown test: #{test}."
30
+ end
31
+ end
32
+ end
data/testdiff.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'testdiff/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'testdiff'
8
+ spec.version = Testdiff::VERSION
9
+ spec.author = 'Isaac Anthony'
10
+ spec.email = 'ianthony@optoro.com'
11
+ spec.summary = 'Ruby gem to locally test only modified files.'
12
+ spec.description = 'Run Rubocop and Rspec only on your modified files.'
13
+ spec.homepage = 'https://github.com/isaacanthony/testdiff'
14
+ spec.license = 'MIT'
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = ['testdiff']
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.11'
20
+ spec.add_development_dependency 'rubocop', '~> 0.40'
21
+ spec.add_development_dependency 'rspec', '~> 3.0'
22
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: testdiff
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Isaac Anthony
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-24 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: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '0.40'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0.40'
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: Run Rubocop and Rspec only on your modified files.
56
+ email: ianthony@optoro.com
57
+ executables:
58
+ - testdiff
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE
65
+ - README.md
66
+ - bin/console
67
+ - bin/setup
68
+ - bin/testdiff
69
+ - lib/testdiff.rb
70
+ - lib/testdiff/modified/ruby_files.rb
71
+ - lib/testdiff/modified/specs.rb
72
+ - lib/testdiff/rspec.rb
73
+ - lib/testdiff/rubocop.rb
74
+ - lib/testdiff/version.rb
75
+ - testdiff.gemspec
76
+ homepage: https://github.com/isaacanthony/testdiff
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.8
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Ruby gem to locally test only modified files.
100
+ test_files: []
101
+ has_rdoc: