configstruct 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +5 -5
- data/lib/configstruct.rb +18 -0
- data/spec/lib/configstruct_spec.rb +41 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b3f5a41063b4236fde2d985b2c2b539a402af1f
|
4
|
+
data.tar.gz: a58aece0b159e578e5a6086a608e0dea0069c159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc7749c11156bfe3fb8f2bb2d5cb40e65ffed089805b2d6491e8997790f8dfeb1874cb5d5ae8c72298c65d96a55b1611488e6948e2cb11d185e6e31c6dedc23f
|
7
|
+
data.tar.gz: 273c166288cffa59f75b1f9cc1b0475cb61d751efe45e9f8e9999622abe129c16e427f63a947c063fd9362c1a1cc5fd8d1afdfe99bcb49b6862c00190f0ff9f4
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
ConfigStruct Changelog
|
2
2
|
=======================
|
3
3
|
|
4
|
-
v0.0.
|
4
|
+
v0.0.3 - 2014-06-01
|
5
|
+
-----------------------
|
6
|
+
|
7
|
+
- add StringIO override for purpose of being used on setup and testing
|
8
|
+
|
9
|
+
v0.0.2 - 2014-05-31
|
5
10
|
-----------------------
|
6
11
|
|
7
12
|
- fix the name of the lib file
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Configstruct
|
2
2
|
=============
|
3
3
|
|
4
|
-
[![Gem Version](https://
|
5
|
-
[![Build Status](https://
|
6
|
-
[![Coverage Status](https://
|
7
|
-
[![Dependency Status](https://
|
8
|
-
[![Code Climate](https://
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/configstruct.svg)](http://rubygems.org/gems/configstruct)
|
5
|
+
[![Build Status](https://img.shields.io/travis/mose/configstruct.svg)](https://travis-ci.org/mose/configstruct)
|
6
|
+
[![Coverage Status](https://img.shields.io/coveralls/mose/configstruct.svg)](https://coveralls.io/r/mose/configstruct?branch=master)
|
7
|
+
[![Dependency Status](https://img.shields.io/gemnasium/mose/configstruct.svg)](https://gemnasium.com/mose/configstruct)
|
8
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/mose/configstruct.svg)](https://codeclimate.com/github/mose/configstruct)
|
9
9
|
|
10
10
|
----
|
11
11
|
|
data/lib/configstruct.rb
CHANGED
@@ -5,6 +5,8 @@ class ConfigStruct < OpenStruct
|
|
5
5
|
|
6
6
|
def initialize(options = nil, input = STDIN, output = STDOUT)
|
7
7
|
super(options)
|
8
|
+
@input = input
|
9
|
+
@output = output
|
8
10
|
set_defaults
|
9
11
|
prepare_dirs
|
10
12
|
addvalues
|
@@ -41,4 +43,20 @@ class ConfigStruct < OpenStruct
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
46
|
+
def puts(*string)
|
47
|
+
@output.puts *string
|
48
|
+
end
|
49
|
+
|
50
|
+
def print(*string)
|
51
|
+
@output.print *string
|
52
|
+
end
|
53
|
+
|
54
|
+
def printf(string, *args)
|
55
|
+
@output.printf string, *args
|
56
|
+
end
|
57
|
+
|
58
|
+
def gets(*args)
|
59
|
+
@input.gets *args
|
60
|
+
end
|
61
|
+
|
44
62
|
end
|
@@ -16,7 +16,7 @@ describe ConfigStruct do
|
|
16
16
|
it { expect(subject.var).to eq value1 }
|
17
17
|
end
|
18
18
|
|
19
|
-
describe 'new' do
|
19
|
+
describe '.new' do
|
20
20
|
context 'when there is no config file, ' do
|
21
21
|
let(:basefile) { File.expand_path('../../files/xxx.yml', __FILE__) }
|
22
22
|
after { FileUtils.rm basefile if File.exist? basefile }
|
@@ -28,4 +28,44 @@ describe ConfigStruct do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
describe 'output/input override' do
|
32
|
+
let(:input) { StringIO.new }
|
33
|
+
let(:output) { StringIO.new }
|
34
|
+
let(:str) { "xxx" }
|
35
|
+
subject { ConfigStruct.new options, input, output }
|
36
|
+
context "when single string is used" do
|
37
|
+
it 'redirect puts to StringIO object' do
|
38
|
+
subject.puts str
|
39
|
+
expect(output.string).to eq "#{str}\n"
|
40
|
+
end
|
41
|
+
it 'redirect print to StringIO object' do
|
42
|
+
subject.print str
|
43
|
+
expect(output.string).to eq str
|
44
|
+
end
|
45
|
+
it 'redirect printf to StringIO object' do
|
46
|
+
subject.printf "-- %s --", str
|
47
|
+
expect(output.string).to eq "-- #{str} --"
|
48
|
+
end
|
49
|
+
it 'redirect gets to StringIO object' do
|
50
|
+
input.stub(:gets).and_return(str)
|
51
|
+
expect(subject.gets).to eq str
|
52
|
+
end
|
53
|
+
end
|
54
|
+
context "when multiple strings are used" do
|
55
|
+
let(:str2) { "zzz" }
|
56
|
+
it 'redirect puts to StringIO object' do
|
57
|
+
subject.puts str, str2
|
58
|
+
expect(output.string).to eq "#{str}\n#{str2}\n"
|
59
|
+
end
|
60
|
+
it 'redirect print to StringIO object' do
|
61
|
+
subject.print str, str2
|
62
|
+
expect(output.string).to eq "#{str}#{str2}"
|
63
|
+
end
|
64
|
+
it 'redirect printf to StringIO object' do
|
65
|
+
subject.printf "-- %s -- %s --", str, str2
|
66
|
+
expect(output.string).to eq "-- #{str} -- #{str2} --"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
31
71
|
end
|