filegen 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/filegen/data.rb CHANGED
@@ -23,8 +23,8 @@ module Filegen
23
23
  # The variable to lookup
24
24
  # @return [String]
25
25
  # The value of the variable
26
- def lookup(variable)
27
- try_to_fetch_unless_found_or_end(variable)
26
+ def lookup(variable, default_value='')
27
+ try_to_fetch_unless_found_or_end(variable) || default_value
28
28
  end
29
29
 
30
30
  # Make the binding of the class available
@@ -42,7 +42,7 @@ module Filegen
42
42
  (result = s.fetch(variable)) && (return result)
43
43
  end
44
44
 
45
- ''
45
+ nil
46
46
  end
47
47
  end
48
48
  end
@@ -1,4 +1,4 @@
1
1
  #main Filegen
2
2
  module Filegen
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
  end
data/spec/data_spec.rb CHANGED
@@ -50,11 +50,17 @@ describe Filegen::Data do
50
50
  source1 = double('DataSource1')
51
51
  expect(source1).to receive(:fetch).with('MY_NAME').and_return(nil)
52
52
 
53
- source2 = double('DataSource2')
54
- expect(source2).to receive(:fetch).with('MY_NAME').and_return(nil)
55
-
56
- data = Filegen::Data.new([source1, source2])
53
+ data = Filegen::Data.new(source1)
57
54
  expect(data.lookup('MY_NAME')).to eq('')
58
55
  end
56
+
57
+ it 'let you return a default value' do
58
+ source1 = double('DataSource1')
59
+ expect(source1).to receive(:fetch).with('MY_NAME').and_return(nil)
60
+
61
+ data = Filegen::Data.new(source1)
62
+ expect(data.lookup('MY_NAME', 'abcde')).to eq('abcde')
63
+
64
+ end
59
65
  end
60
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filegen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-13 00:00:00.000000000 Z
12
+ date: 2014-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: moneta