ferver 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +2 -1
- data/.rubocop.yml +13 -0
- data/.ruby-version +1 -1
- data/.travis.yml +6 -1
- data/Gemfile +2 -1
- data/README.md +11 -1
- data/Rakefile +1 -0
- data/bin/ferver +20 -9
- data/ferver.gemspec +22 -20
- data/lib/ferver.rb +9 -11
- data/lib/ferver/app.rb +5 -4
- data/lib/ferver/configuration.rb +18 -9
- data/lib/ferver/controller.rb +25 -30
- data/lib/ferver/errors.rb +5 -0
- data/lib/ferver/ferver_directory.rb +43 -0
- data/lib/ferver/file_list.rb +10 -34
- data/lib/ferver/found_file.rb +2 -1
- data/lib/ferver/version.rb +2 -1
- data/spec/configuration_spec.rb +16 -10
- data/spec/ferver_directory_spec.rb +78 -0
- data/spec/ferver_spec.rb +62 -97
- data/spec/file_list_spec.rb +40 -112
- data/spec/found_file_spec.rb +54 -0
- data/spec/spec_helper.rb +44 -29
- metadata +41 -24
- data/lib/ferver/directory_not_found_error.rb +0 -3
- data/lib/ferver/file_id_request.rb +0 -32
- data/spec/file_id_request_spec.rb +0 -65
@@ -1,32 +0,0 @@
|
|
1
|
-
|
2
|
-
module Ferver
|
3
|
-
class FileIdRequest
|
4
|
-
attr_reader :value
|
5
|
-
|
6
|
-
def initialize(value = nil)
|
7
|
-
@is_valid = false
|
8
|
-
|
9
|
-
self.value = value
|
10
|
-
end
|
11
|
-
|
12
|
-
def value=(value)
|
13
|
-
@value = parse_value(value)
|
14
|
-
end
|
15
|
-
|
16
|
-
def valid?
|
17
|
-
@is_valid
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def parse_value(value)
|
23
|
-
begin
|
24
|
-
int_val = Integer(value)
|
25
|
-
@is_valid = true
|
26
|
-
int_val
|
27
|
-
rescue
|
28
|
-
@is_valid = false
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Ferver::FileIdRequest do
|
4
|
-
describe 'creating new instance' do
|
5
|
-
context 'when valid Integer is passed' do
|
6
|
-
subject { Ferver::FileIdRequest.new(1) }
|
7
|
-
|
8
|
-
it 'should return expected value' do
|
9
|
-
expect(subject.value).to eq(1)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'when nil argument is passed' do
|
14
|
-
it 'should be invalid' do
|
15
|
-
id_request = Ferver::FileIdRequest.new(nil)
|
16
|
-
|
17
|
-
expect(id_request.valid?).to be_falsey
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#value= method' do
|
23
|
-
subject { Ferver::FileIdRequest.new }
|
24
|
-
|
25
|
-
context 'when valid Integer is passed' do
|
26
|
-
before { subject.value = 1 }
|
27
|
-
|
28
|
-
it 'should be valid' do
|
29
|
-
expect(subject.valid?).to be_truthy
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should return expected value' do
|
33
|
-
expect(subject.value).to eq(1)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'when valid String as Integer is passed' do
|
38
|
-
before { subject.value = '1' }
|
39
|
-
|
40
|
-
it 'should be valid' do
|
41
|
-
expect(subject.valid?).to be_truthy
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should return expected value' do
|
45
|
-
expect(subject.value).to eq(1)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'when a string is passed' do
|
50
|
-
before { subject.value = 'foo' }
|
51
|
-
|
52
|
-
it 'should be invalid' do
|
53
|
-
expect(subject.valid?).to be_falsey
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'when an empty string is passed' do
|
58
|
-
it 'should be invalid' do
|
59
|
-
subject.value = ''
|
60
|
-
|
61
|
-
expect(subject.valid?).to be_falsey
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|