ini_file 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,104 @@
1
+ # INI File
2
+ [![Build Status](https://secure.travis-ci.org/jdantonio/ini_file.png)](http://travis-ci.org/jdantonio/ini_file?branch=master) [![Dependency Status](https://gemnasium.com/jdantonio/ini_file.png)](https://gemnasium.com/jdantonio/ini_file)
3
+
4
+ A simple gem for reading INI files. Originally written because I wanted to read
5
+ my Git config file in Ruby programs. Now supports virtually all features described
6
+ in the [Wikipedia page](http://en.wikipedia.org/wiki/INI_file). Key/value pairs
7
+ can be accessed from the +IniFile+ object using both hash syntax and attribute
8
+ reader syntax.
9
+
10
+ The project is hosted on the following sites:
11
+
12
+ * [RubyGems project page](https://rubygems.org/gems/ini_file)
13
+ * [Source code on GitHub](https://github.com/jdantonio/ini_file)
14
+ * [YARD documentation on RubyDoc.org](http://rubydoc.info/github/jdantonio/ini_file/)
15
+ * [Continuous integration on Travis-CI](https://travis-ci.org/jdantonio/ini_file)
16
+ * [Dependency tracking on Gemnasium](https://gemnasium.com/jdantonio/ini_file)
17
+ * [Follow me on Twitter](https://twitter.com/jerrydantonio)
18
+
19
+ ## Supported Ruby Versions
20
+
21
+ * ruby-1.9.2
22
+ * ruby-1.9.3
23
+ * ruby-2.0.0
24
+ * jruby-1.7.0
25
+
26
+ ## Installation
27
+
28
+ Install from RubyGems:
29
+
30
+ gem install ini_file
31
+
32
+ or add the following line to Gemfile:
33
+
34
+ gem 'ini_file'
35
+
36
+ and run *bundle install* from your shell.
37
+
38
+ ## Usage
39
+
40
+ Require INI File within your Ruby project:
41
+
42
+ require 'ini_file'
43
+
44
+ then use it:
45
+
46
+ ini = IniFile.load('~/.gitconfig')
47
+
48
+ ini[:user][:name] #=> "Jerry D'Antonio"
49
+ ini.user.name #=> "Jerry D'Antonio"
50
+
51
+ ini[:user].empty? #=> false
52
+ ini.user.empty? #=> false
53
+
54
+ ini.color.each do |key, value|
55
+ puts "#{key} is set to #{value}"
56
+ end
57
+ #=> branch is set to auto
58
+ #=> diff is set to auto
59
+ #=> interactive is set to auto
60
+ #=> status is set to auto
61
+
62
+ ini.each_section do |section|
63
+ puts section.__name__
64
+ end
65
+ #=> user
66
+ #=> alias
67
+ #=> color
68
+ #=> core
69
+ #=> giggle
70
+
71
+ ini[:core].to_hash #=> {:editor=>"vim", :excludesfile=>"~/.gitignore"}
72
+ ini.core.to_hash #=> {:editor=>"vim", :excludesfile=>"~/.gitignore"}
73
+
74
+ ini.to_hash #=> {:user=>{:name=>"Jerry D'Antonio", ...
75
+
76
+ ## Copyright
77
+
78
+ Copyright © 2013 [Jerry D'Antonio](https://twitter.com/jerrydantonio).
79
+ It is free software and may be redistributed under the terms specified in
80
+ the LICENSE file.
81
+
82
+ ## License
83
+
84
+ Released under the MIT license.
85
+
86
+ http://www.opensource.org/licenses/mit-license.php
87
+
88
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
89
+ > of this software and associated documentation files (the "Software"), to deal
90
+ > in the Software without restriction, including without limitation the rights
91
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
92
+ > copies of the Software, and to permit persons to whom the Software is
93
+ > furnished to do so, subject to the following conditions:
94
+ >
95
+ > The above copyright notice and this permission notice shall be included in
96
+ > all copies or substantial portions of the Software.
97
+ >
98
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
99
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
100
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
101
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
102
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
103
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
104
+ > THE SOFTWARE.
@@ -4,7 +4,7 @@ module IniFile
4
4
 
5
5
  class Content
6
6
 
7
- attr_reader :name
7
+ attr_reader :__name__
8
8
 
9
9
  def empty?
10
10
  return @content.empty?
@@ -62,7 +62,7 @@ module IniFile
62
62
  private
63
63
 
64
64
  def initialize(name = nil)
65
- @name = name
65
+ @__name__ = name
66
66
  @content = {}
67
67
  end
68
68
 
@@ -1,3 +1,3 @@
1
1
  module IniFile
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
@@ -268,7 +268,7 @@ module IniFile
268
268
 
269
269
  it 'iterates over each section in the root' do
270
270
  subject.each_section do |section|
271
- sections.should include section.name
271
+ sections.should include section.__name__
272
272
  end
273
273
  end
274
274
 
@@ -280,7 +280,7 @@ module IniFile
280
280
 
281
281
  it 'does not iterate over properties at the root' do
282
282
  subject.each_section do |section|
283
- keys.should_not include section.name
283
+ keys.should_not include section.__name__
284
284
  end
285
285
  end
286
286
 
@@ -312,7 +312,7 @@ module IniFile
312
312
 
313
313
  it 'iterates over each section in the root' do
314
314
  subject.section_1.each_section do |section|
315
- subsections.should include section.name
315
+ subsections.should include section.__name__
316
316
  end
317
317
  end
318
318
 
@@ -324,7 +324,7 @@ module IniFile
324
324
 
325
325
  it 'does not iterate over properties at the root' do
326
326
  subject.section_1.each_section do |section|
327
- subsection_keys.should_not include section.name
327
+ subsection_keys.should_not include section.__name__
328
328
  end
329
329
  end
330
330
 
@@ -31,7 +31,6 @@ module IniFile
31
31
  it 'throws an exception if the first argument is not a string' do
32
32
  lambda { subject.parse(123) }.should raise_error(ArgumentError)
33
33
  end
34
-
35
34
  end
36
35
 
37
36
  context 'return value' do
@@ -43,7 +42,6 @@ module IniFile
43
42
  it 'is an empty hash when the content is only comments' do
44
43
  subject.parse('; this is a comment').should be_empty
45
44
  end
46
-
47
45
  end
48
46
 
49
47
  context 'content' do
@@ -163,13 +161,6 @@ module IniFile
163
161
  ini = subject.parse('key=This is the VALUE')
164
162
  ini[:key].should eq 'This is the VALUE'
165
163
  end
166
-
167
- it 'allows line continuation when a line ends with a backslash' do
168
- pending
169
- ini = subject.parse("key=this\\\nvalue")
170
- ini[:key].should eq 'this value'
171
- end
172
-
173
164
  end
174
165
 
175
166
  context 'escape sequences' do
@@ -228,7 +219,6 @@ module IniFile
228
219
  ini = subject.parse("key=this\\u1234value")
229
220
  ini[:key].should eq "this\u1234value"
230
221
  end
231
-
232
222
  end
233
223
 
234
224
  context 'comments' do
@@ -289,7 +279,6 @@ module IniFile
289
279
  ini[:key1].should eq 'value1'
290
280
  ini[:key2].should eq 'value2'
291
281
  end
292
-
293
282
  end
294
283
 
295
284
  context 'sections' do
@@ -444,7 +433,6 @@ module IniFile
444
433
  subject.parse("[this.is\\the/section,header]")
445
434
  }.should raise_error(IniFormatError)
446
435
  end
447
-
448
436
  end
449
437
 
450
438
  context 'multiple lines' do
@@ -465,7 +453,6 @@ module IniFile
465
453
  ini[:key1].should eq 'value1'
466
454
  ini[:key2].should eq 'value2'
467
455
  end
468
-
469
456
  end
470
457
 
471
458
  context 'garbage' do
@@ -475,7 +462,6 @@ module IniFile
475
462
  subject.parse('this line is garbage')
476
463
  }.should raise_error(IniFormatError)
477
464
  end
478
-
479
465
  end
480
466
 
481
467
  context 'property data types' do
@@ -492,7 +478,6 @@ module IniFile
492
478
  ini[:key1].should be_within(0.1).of(123.45)
493
479
  end
494
480
  end
495
-
496
481
  end
497
482
  end
498
483
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ini_file
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-21 00:00:00.000000000 Z
12
+ date: 2013-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :development
@@ -24,15 +24,15 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: debugger
31
+ name: rake
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  type: :development
@@ -40,15 +40,15 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: rake
47
+ name: simplecov
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  type: :development
@@ -56,15 +56,15 @@ dependencies:
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
- name: simplecov
63
+ name: rspec
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - ! '>='
67
+ - - '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  type: :development
@@ -72,15 +72,15 @@ dependencies:
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ! '>='
75
+ - - '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
- name: rspec
79
+ name: fakefs
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - ! '>='
83
+ - - '>='
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  type: :development
@@ -88,15 +88,15 @@ dependencies:
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - ! '>='
91
+ - - '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  - !ruby/object:Gem::Dependency
95
- name: fakefs
95
+ name: yard
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
- - - ! '>='
99
+ - - '>='
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  type: :development
@@ -104,33 +104,52 @@ dependencies:
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
- - - ! '>='
107
+ - - '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
- description: ! '''The INI file format is an informal standard for configuration files
111
- for some platforms or software. INI files are simple text files with a basic structure
112
- composed of ''sections'' and ''properties''.'' - Wikipedia'
110
+ - !ruby/object:Gem::Dependency
111
+ name: redcarpet
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: |2
127
+ The INI file format is an informal standard for configuration files
128
+ for some platforms or software. INI files are simple text files with
129
+ a basic structure composed of 'sections' and 'properties'.' - Wikipedia
113
130
  email:
114
131
  - jerry.dantonio@gmail.com
115
132
  executables: []
116
133
  extensions: []
117
- extra_rdoc_files: []
134
+ extra_rdoc_files:
135
+ - README.md
136
+ - LICENSE
118
137
  files:
119
- - Rakefile
120
- - README.rdoc
138
+ - README.md
121
139
  - LICENSE
122
- - lib/ini_file.rb
123
- - lib/ini_file/version.rb
124
- - lib/ini_file/parser.rb
125
140
  - lib/ini_file/content.rb
126
- - spec/ini_file_spec.rb
127
- - spec/spec_helper.rb
141
+ - lib/ini_file/parser.rb
142
+ - lib/ini_file/version.rb
143
+ - lib/ini_file.rb
128
144
  - spec/ini_file/content_spec.rb
129
145
  - spec/ini_file/parser_spec.rb
130
- - tasks/rcov.rake
146
+ - spec/ini_file_spec.rb
147
+ - spec/spec_helper.rb
131
148
  homepage: https://github.com/jdantonio/ini_file
132
- licenses: []
133
- post_install_message:
149
+ licenses:
150
+ - MIT
151
+ post_install_message: |2
152
+ Alright you primitive screwheads, listen up. See this? This is my boomstick!'
134
153
  rdoc_options: []
135
154
  require_paths:
136
155
  - lib
@@ -138,23 +157,27 @@ require_paths:
138
157
  required_ruby_version: !ruby/object:Gem::Requirement
139
158
  none: false
140
159
  requirements:
141
- - - ! '>='
160
+ - - '>='
142
161
  - !ruby/object:Gem::Version
143
- version: '0'
162
+ version: 1.9.2
144
163
  required_rubygems_version: !ruby/object:Gem::Requirement
145
164
  none: false
146
165
  requirements:
147
- - - ! '>='
166
+ - - '>='
148
167
  - !ruby/object:Gem::Version
149
168
  version: '0'
169
+ segments:
170
+ - 0
171
+ hash: -1783671089307373917
150
172
  requirements: []
151
173
  rubyforge_project:
152
- rubygems_version: 1.8.24
174
+ rubygems_version: 1.8.25
153
175
  signing_key:
154
176
  specification_version: 3
155
177
  summary: Manage simple INI files.
156
178
  test_files:
157
- - spec/ini_file_spec.rb
158
- - spec/spec_helper.rb
159
179
  - spec/ini_file/content_spec.rb
160
180
  - spec/ini_file/parser_spec.rb
181
+ - spec/ini_file_spec.rb
182
+ - spec/spec_helper.rb
183
+ has_rdoc:
@@ -1 +0,0 @@
1
- README for ini_file
data/Rakefile DELETED
@@ -1,16 +0,0 @@
1
- require "rubygems"
2
- require "bundler/gem_tasks"
3
- require "rspec"
4
- require "rspec/core/rake_task"
5
-
6
- $:.unshift 'tasks'
7
- Dir.glob('tasks/**/*.rake').each do|rakefile|
8
- load rakefile
9
- end
10
-
11
- Bundler::GemHelper.install_tasks
12
- RSpec::Core::RakeTask.new(:spec) do |t|
13
- t.rspec_opts = '-fd --color'
14
- end
15
-
16
- #task :default => [:default_task]
@@ -1,11 +0,0 @@
1
- namespace :rcov do
2
-
3
- RSpec::Core::RakeTask.new(:rspec) do |t|
4
- rm "coverage.data" if File.exist?("coverage.data")
5
- t.pattern = 'spec/**/*_spec.rb'
6
- t.rcov = true
7
- t.rcov_opts = %w{--exclude osx\/objc,Users\/,gems\/,spec\/,teamcity}
8
- t.verbose = true
9
- end
10
-
11
- end