git_evolution 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/git_evolution/errors.rb +9 -0
- data/lib/git_evolution/option_handler.rb +9 -7
- data/lib/git_evolution/version.rb +1 -1
- data/pkg/git_evolution-0.1.2.gem +0 -0
- data/spec/git_evolution/option_handler_spec.rb +15 -6
- 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: 9601a4a1eb15dc6bda2ed6c3229858602d933733
|
4
|
+
data.tar.gz: 98056387ada1c9303ce8f47603a82657df8b5df6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8ae0797250443a52f297cf840d002fea1ab97598586a43f8cbc25892ab5d8160775806a3535c8aa364e0b90a87aa076331591e96c5773c7fff4c3c9803eb768
|
7
|
+
data.tar.gz: e2ba200cfb1bfe7d0aa87963be0c3e58667f38460b6bd09707a0064529a3f29cc5deada0a36971d45170e64973618a39ca61b25160fe40c0f3087ef908241148
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
module GitEvolution
|
2
|
+
class Exception < StandardError; end
|
3
|
+
|
4
|
+
class FileMissingError < GitEvolution::Exception; end
|
5
|
+
class InvalidRangeFormatError < GitEvolution::Exception; end
|
6
|
+
class FileDoesNotExistError < GitEvolution::Exception; end
|
7
|
+
class RangeOutOfBoundsError < GitEvolution::Exception; end
|
8
|
+
class TimeParseError < GitEvolution::Exception; end
|
9
|
+
end
|
@@ -5,7 +5,7 @@ module GitEvolution
|
|
5
5
|
range: nil,
|
6
6
|
since: nil,
|
7
7
|
start_line: nil,
|
8
|
-
end_line: nil
|
8
|
+
end_line: nil
|
9
9
|
)
|
10
10
|
|
11
11
|
OptionParser.new do |opts|
|
@@ -19,6 +19,8 @@ module GitEvolution
|
|
19
19
|
end
|
20
20
|
end.parse!
|
21
21
|
|
22
|
+
raise(FileMissingError, 'Missing required file argument') if args.empty?
|
23
|
+
|
22
24
|
options[:file] = File.expand_path(args[0])
|
23
25
|
options[:start_line], options[:end_line] = parse_range(options[:range])
|
24
26
|
|
@@ -31,7 +33,7 @@ module GitEvolution
|
|
31
33
|
return if range.nil?
|
32
34
|
|
33
35
|
regex_matches = range.match(/^(\d+):(\d+)/)
|
34
|
-
raise 'The --range option was not in the valid format (N:N)' if regex_matches.nil?
|
36
|
+
raise(InvalidRangeFormatError, 'The --range option was not in the valid format (N:N)') if regex_matches.nil?
|
35
37
|
|
36
38
|
start_line = regex_matches[1].to_i
|
37
39
|
end_line = regex_matches[2].to_i
|
@@ -41,21 +43,21 @@ module GitEvolution
|
|
41
43
|
|
42
44
|
def self.validate_options!(options)
|
43
45
|
if options.file.nil?
|
44
|
-
raise 'Missing required file argument'
|
46
|
+
raise(FileMissingError, 'Missing required file argument')
|
45
47
|
elsif !File.exist?(options.file)
|
46
|
-
raise "File #{options.file} does not exist"
|
48
|
+
raise(FileDoesNotExistError, "File #{options.file} does not exist")
|
47
49
|
end
|
48
50
|
|
49
51
|
if !options.range.nil?
|
50
|
-
raise 'Start line cannot be greater than the end line' if options.start_line > options.end_line
|
52
|
+
raise(RangeOutOfBoundsError, 'Start line cannot be greater than the end line') if options.start_line > options.end_line
|
51
53
|
|
52
54
|
file_length = File.new(options.file).readlines.size
|
53
|
-
raise "End line cannot be larger than the length of the file (#{file_length})" if options.end_line > file_length
|
55
|
+
raise(RangeOutOfBoundsError, "End line cannot be larger than the length of the file (#{file_length})") if options.end_line > file_length
|
54
56
|
end
|
55
57
|
|
56
58
|
if !options.since.nil?
|
57
59
|
options.since = Chronic.parse(options.since)
|
58
|
-
raise 'The since time could not be properly parsed' if options.since.nil?
|
60
|
+
raise(TimeParseError, 'The since time could not be properly parsed') if options.since.nil?
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
data/pkg/git_evolution-0.1.2.gem
CHANGED
Binary file
|
@@ -2,8 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe GitEvolution::OptionHandler do
|
4
4
|
describe '.parse_options' do
|
5
|
-
subject { described_class.parse_options(
|
5
|
+
subject { described_class.parse_options(args) }
|
6
6
|
|
7
|
+
let(:args) { [file] }
|
7
8
|
let!(:tmp_dir) { Dir.mktmpdir }
|
8
9
|
let(:file) { tmp_dir + '/file.txt' }
|
9
10
|
let(:start_line) { 1 }
|
@@ -21,6 +22,14 @@ RSpec.describe GitEvolution::OptionHandler do
|
|
21
22
|
expect(subject.end_line).to eq(end_line)
|
22
23
|
expect(subject.file).to eq(file)
|
23
24
|
end
|
25
|
+
|
26
|
+
context 'no arguments passed' do
|
27
|
+
let(:args) { [] }
|
28
|
+
|
29
|
+
it 'raises a FileMissingException' do
|
30
|
+
expect { subject }.to raise_error(GitEvolution::FileMissingError)
|
31
|
+
end
|
32
|
+
end
|
24
33
|
end
|
25
34
|
|
26
35
|
describe '.parse_range' do
|
@@ -84,7 +93,7 @@ RSpec.describe GitEvolution::OptionHandler do
|
|
84
93
|
let(:end_line) { 1 }
|
85
94
|
|
86
95
|
it 'invalid options' do
|
87
|
-
expect { described_class.validate_options!(options) }.to raise_error
|
96
|
+
expect { described_class.validate_options!(options) }.to raise_error(GitEvolution::RangeOutOfBoundsError)
|
88
97
|
end
|
89
98
|
end
|
90
99
|
|
@@ -94,13 +103,13 @@ RSpec.describe GitEvolution::OptionHandler do
|
|
94
103
|
before { FileUtils.rm(file) }
|
95
104
|
|
96
105
|
it 'invalid options' do
|
97
|
-
expect { described_class.validate_options!(options) }.to raise_error
|
106
|
+
expect { described_class.validate_options!(options) }.to raise_error(GitEvolution::FileDoesNotExistError)
|
98
107
|
end
|
99
108
|
|
100
109
|
context 'missing file argument' do
|
101
110
|
it 'invalid options' do
|
102
111
|
options.file = nil
|
103
|
-
expect { described_class.validate_options!(options) }.to raise_error
|
112
|
+
expect { described_class.validate_options!(options) }.to raise_error(GitEvolution::FileMissingError)
|
104
113
|
end
|
105
114
|
end
|
106
115
|
end
|
@@ -110,7 +119,7 @@ RSpec.describe GitEvolution::OptionHandler do
|
|
110
119
|
let(:end_line) { 40 }
|
111
120
|
|
112
121
|
it 'invalid options' do
|
113
|
-
expect { described_class.validate_options!(options) }.to raise_error
|
122
|
+
expect { described_class.validate_options!(options) }.to raise_error(GitEvolution::RangeOutOfBoundsError)
|
114
123
|
end
|
115
124
|
end
|
116
125
|
|
@@ -119,7 +128,7 @@ RSpec.describe GitEvolution::OptionHandler do
|
|
119
128
|
let(:since) { 'csdcsdc' }
|
120
129
|
|
121
130
|
it 'invalid options' do
|
122
|
-
expect { described_class.validate_options!(options) }.to raise_error
|
131
|
+
expect { described_class.validate_options!(options) }.to raise_error(GitEvolution::TimeParseError)
|
123
132
|
end
|
124
133
|
end
|
125
134
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_evolution
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Jalbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- git_evolution.gemspec
|
87
87
|
- lib/git_evolution.rb
|
88
88
|
- lib/git_evolution/commit.rb
|
89
|
+
- lib/git_evolution/errors.rb
|
89
90
|
- lib/git_evolution/initialize.rb
|
90
91
|
- lib/git_evolution/option_handler.rb
|
91
92
|
- lib/git_evolution/report_presenter.rb
|