configstruct 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d65d2c8e268ef10541747c3aefaf9cc24d750e54
4
- data.tar.gz: 37d8459de43f1f92e99b19ff502b07f837e6e9e2
3
+ metadata.gz: f9e6ed7a4fc44632fc1a402fdaecc3933e5c7799
4
+ data.tar.gz: c364d1390c0058a08b860501136885af8711eb59
5
5
  SHA512:
6
- metadata.gz: fcfb7686bdaba07dee5bc8179d808e22279bbdd2b6fdf131ec6b366257deed5a1a35a4fb97a4600d4208c73e0fe8c6c518838990cdfb73833afbb2195de542b3
7
- data.tar.gz: c5a5a5eb499e8fd56ff4295664708573c7620c7da1c01659ddd9d5adbc1baf4a68bc4c31f6f88f99733a83d89ca904139d93d84710482d8b960dc921c72996b2
6
+ metadata.gz: 2ee4ad4f1b48e5dcf3a045b1fba3dbbfdacc2a15995bb7f6a78ea64c8f145f64dc409b3965955c986d4d7520ba6e30c2a2347ec2fa815c4caa261c41e10fc411
7
+ data.tar.gz: 5005bc1b18655b808ac35699580f26a2fc0355f9e0af4027b0e84c0810cfca704b42e96875083cd0210d3f13bb3f118dbc6e103aa06120c963be5d7120a74ac4
@@ -1,9 +1,15 @@
1
1
  ConfigStruct Changelog
2
2
  =======================
3
3
 
4
+ v0.1.0 - 2015-11-16
5
+ ----------------------
6
+ - fix tests for rspec3
7
+ - add some code documentation
8
+
4
9
  v0.0.4 - 2014-08-19
5
10
  -----------------------
6
- - add a furth params at init for conductig the behaviour of overriding values from options provided
11
+ - add a fourth params at init for conducting the behaviour
12
+ of overriding values from options provided
7
13
 
8
14
  v0.0.3 - 2014-06-01
9
15
  -----------------------
data/README.md CHANGED
@@ -7,6 +7,7 @@ Configstruct
7
7
  [![Coverage Status](https://img.shields.io/coveralls/mose/configstruct.svg)](https://coveralls.io/r/mose/configstruct?branch=master)
8
8
  [![Dependency Status](https://img.shields.io/gemnasium/mose/configstruct.svg)](https://gemnasium.com/mose/configstruct)
9
9
  [![Code Climate](https://img.shields.io/codeclimate/github/mose/configstruct.svg)](https://codeclimate.com/github/mose/configstruct)
10
+ [![Inch](https://inch-ci.org/github/mose/configstruct.svg)](https://inch-ci.org/github/mose/configstruct)
10
11
 
11
12
  ----
12
13
 
@@ -1,8 +1,14 @@
1
1
  require 'ostruct'
2
2
  require 'yaml'
3
3
 
4
+ # the Configstruct object
5
+ # inherits from OpenStruct and adds some features:
6
+ # - set default values
7
+ # - redirects output and input IO to custom streams
8
+ # - writes file on disk as yaml
4
9
  class ConfigStruct < OpenStruct
5
10
 
11
+ # creates new object
6
12
  def initialize(options = nil, input = STDIN, output = STDOUT, unless_set = false)
7
13
  super(options)
8
14
  @input = input
@@ -13,15 +19,18 @@ class ConfigStruct < OpenStruct
13
19
  addvalues
14
20
  end
15
21
 
22
+ # sets defaults value for initializer
16
23
  def set_defaults
17
24
  default :basedir, '/tmp'
18
25
  default :basefile, File.join(self.basedir, 'config.yml')
19
26
  end
20
27
 
28
+ # creates dir where to store config if it does not exist
21
29
  def prepare_dirs
22
30
  FileUtils.mkdir_p self.basedir unless Dir.exist? self.basedir
23
31
  end
24
32
 
33
+ # adds value in the configuration hash
25
34
  def addvalues
26
35
  setup unless File.exist? self.basefile
27
36
  YAML.load_file(self.basefile).each do |k, v|
@@ -32,32 +41,39 @@ class ConfigStruct < OpenStruct
32
41
  end
33
42
  end
34
43
 
44
+ # creates a blank config file with empty values
35
45
  def setup
36
46
  write Hash.new
37
47
  end
38
48
 
49
+ # attributes value if it is nil
39
50
  def default(var, value)
40
51
  send(var).nil? && send("#{var}=", value)
41
52
  end
42
53
 
54
+ # writes config faile on disk as yaml
43
55
  def write(values)
44
56
  File.open(self.basefile, 'w') do |f|
45
57
  f.write YAML.dump(values)
46
58
  end
47
59
  end
48
60
 
61
+ # redirect puts to the initialized output
49
62
  def puts(*string)
50
63
  @output.puts *string
51
64
  end
52
65
 
66
+ # redirect print to the initialized output
53
67
  def print(*string)
54
68
  @output.print *string
55
69
  end
56
70
 
71
+ # redirect printf to the initialized output
57
72
  def printf(string, *args)
58
73
  @output.printf string, *args
59
74
  end
60
75
 
76
+ # redirect gets fromm the initialized input
61
77
  def gets(*args)
62
78
  @input.gets *args
63
79
  end
@@ -23,7 +23,7 @@ describe ConfigStruct do
23
23
  subject { ConfigStruct.new options }
24
24
  it 'then a config file is created calling' do
25
25
  expect(subject.basefile).to eq basefile
26
- expect(File.exist? basefile).to be_true
26
+ expect(File.exist? basefile).to be_truthy
27
27
  end
28
28
  end
29
29
  end
@@ -47,7 +47,7 @@ describe ConfigStruct do
47
47
  expect(output.string).to eq "-- #{str} --"
48
48
  end
49
49
  it 'redirect gets to StringIO object' do
50
- input.stub(:gets).and_return(str)
50
+ allow(input).to receive(:gets).and_return(str)
51
51
  expect(subject.gets).to eq str
52
52
  end
53
53
  end
@@ -12,9 +12,6 @@ if ENV['COV']
12
12
  else
13
13
  require 'coveralls'
14
14
  Coveralls.wear!
15
-
16
- # require "codeclimate-test-reporter"
17
- # CodeClimate::TestReporter.start
18
15
  end
19
16
 
20
17
  RSpec.configure do |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configstruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-19 00:00:00.000000000 Z
11
+ date: 2015-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: codeclimate-test-reporter
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  description: Lib for managing config files based on OpenStruct, includes file saving
84
70
  and prompt at creation.
85
71
  email:
@@ -88,15 +74,9 @@ executables: []
88
74
  extensions: []
89
75
  extra_rdoc_files: []
90
76
  files:
91
- - ".coveralls.yml"
92
- - ".gitignore"
93
- - ".travis.yml"
94
77
  - CHANGELOG.md
95
- - Gemfile
96
78
  - LICENSE.txt
97
79
  - README.md
98
- - Rakefile
99
- - configstruct.gemspec
100
80
  - lib/configstruct.rb
101
81
  - spec/files/config.yml
102
82
  - spec/lib/configstruct_spec.rb
@@ -121,11 +101,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
101
  version: '0'
122
102
  requirements: []
123
103
  rubyforge_project:
124
- rubygems_version: 2.2.2
104
+ rubygems_version: 2.4.8
125
105
  signing_key:
126
106
  specification_version: 4
127
107
  summary: Lib for managing config files based on OpenStruct.
128
108
  test_files:
129
- - spec/files/config.yml
130
- - spec/lib/configstruct_spec.rb
131
109
  - spec/spec_helper.rb
110
+ - spec/lib/configstruct_spec.rb
111
+ - spec/files/config.yml
@@ -1 +0,0 @@
1
- repo_token: PJCj4fDDbnGb3BA3qehKdZmQOWGXVulAl
data/.gitignore DELETED
@@ -1,23 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.bundle
19
- *.so
20
- *.o
21
- *.a
22
- mkmf.log
23
- vendor/
@@ -1,6 +0,0 @@
1
- language: ruby
2
- bundler_args: --path vendor
3
- cache: bundler
4
- rvm:
5
- - 1.9.3
6
- - 2.1.1
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in configstruct.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- require 'bundler/setup'
8
- require 'bundler/gem_tasks'
9
- require 'rake/testtask'
10
- require 'rspec/core/rake_task' # RSpec 2.0
11
-
12
- desc 'launch rspec tests'
13
- task :spec do
14
- RSpec::Core::RakeTask.new(:spec) do |t|
15
- t.rspec_opts = ['-c', '-f progress', '-r ./spec/spec_helper.rb']
16
- t.pattern = 'spec/lib/**/*_spec.rb'
17
- end
18
- end
19
-
20
- task default: :spec
@@ -1,25 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "configstruct"
7
- spec.version = File.read(File.expand_path('../CHANGELOG.md', __FILE__))[/([0-9]+\.[0-9]+\.[0-9]+)/]
8
- spec.authors = ["mose"]
9
- spec.email = ["mose@mose.com"]
10
- spec.summary = %q{Lib for managing config files based on OpenStruct.}
11
- spec.description = %q{Lib for managing config files based on OpenStruct, includes file saving and prompt at creation.}
12
- spec.homepage = "https://github.com/mose/configstruct"
13
- spec.license = "MIT"
14
-
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(/^spec\//)
18
- spec.require_paths = ['lib']
19
-
20
- spec.add_development_dependency "bundler", "~> 1.6"
21
- spec.add_development_dependency "rake"
22
- spec.add_development_dependency 'rspec'
23
- spec.add_development_dependency 'coveralls'
24
- spec.add_development_dependency 'codeclimate-test-reporter'
25
- end