iniparse 0.2.1 → 1.0.0

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.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2009 Anthony Williams
1
+ Copyright (c) 2008-2010 Anthony Williams
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.rdoc CHANGED
@@ -10,6 +10,8 @@ or you feed it an INI file which doesn't work as you'd expected, please mail
10
10
  me at +anthony at ninecraft dot com+, ideally with a copy of the INI file in
11
11
  question.
12
12
 
13
+ IniParse tests pass on Ruby 1.8.6p383, 1.8.7p174, and 1.9.1p243.
14
+
13
15
  === Main features
14
16
 
15
17
  * <b>Support for duplicate options.</b> While not common, some INI files
data/Rakefile CHANGED
@@ -1,102 +1,75 @@
1
- require 'rubygems'
2
1
  require 'rake/clean'
3
- require 'rake/gempackagetask'
4
- require 'rubygems/specification'
5
- require 'date'
2
+ require 'rake/rdoctask'
6
3
  require 'spec/rake/spectask'
7
4
 
8
- begin
9
- require 'hanna/rdoctask'
10
- rescue LoadError
11
- require 'rake/rdoctask'
12
- end
13
-
14
- require 'lib/iniparse/version'
15
-
16
- GEM = 'iniparse'
17
- GEM_VERSION = IniParse::VERSION
18
-
19
5
  ##############################################################################
20
- # Packaging & Installation
6
+ # Packaging & Installation.
21
7
  ##############################################################################
22
8
 
23
9
  CLEAN.include ['pkg', '*.gem', 'doc', 'coverage']
24
10
 
25
- spec = Gem::Specification.new do |s|
26
- s.name = GEM
27
- s.version = GEM_VERSION
28
- s.platform = Gem::Platform::RUBY
29
- s.summary = "A pure Ruby library for parsing INI documents."
30
- s.description = s.summary
31
- s.author = 'Anthony Williams'
32
- s.email = 'anthony@ninecraft.com'
33
- s.homepage = 'http://github.com/anthonyw/iniparse'
34
-
35
- # rdoc
36
- s.has_rdoc = true
37
- s.extra_rdoc_files = %w(README.rdoc LICENSE)
38
-
39
- # Dependencies
40
- s.add_dependency 'extlib', '>= 0.9.9'
41
-
42
- s.require_path = 'lib'
43
- s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{lib,spec}/**/*")
44
-
45
- s.rubyforge_project = 'iniparse'
46
- end
47
-
48
-
49
- Rake::GemPackageTask.new(spec) do |pkg|
50
- pkg.gem_spec = spec
51
- end
52
-
53
- desc "Run :package and install the resulting .gem"
54
- task :install => :package do
55
- sh %(gem install --local pkg/#{GEM}-#{GEM_VERSION}.gem)
56
- end
57
-
58
- desc "Run :clean and uninstall the .gem"
59
- task :uninstall => :clean do
60
- sh %(gem uninstall #{GEM})
61
- end
62
-
63
- desc "Create a gemspec file"
64
- task :make_spec do
65
- File.open("#{GEM}.gemspec", "w") do |file|
66
- file.puts spec.to_ruby
11
+ begin
12
+ require 'jeweler'
13
+
14
+ Jeweler::Tasks.new do |gem|
15
+ gem.name = 'iniparse'
16
+ gem.platform = Gem::Platform::RUBY
17
+ gem.summary = 'A pure Ruby library for parsing INI documents.'
18
+ gem.description = gem.summary
19
+ gem.author = 'Anthony Williams'
20
+ gem.email = 'anthony@ninecraft.com'
21
+ gem.homepage = 'http://github.com/antw/iniparse'
22
+
23
+ gem.files = %w(LICENSE README.rdoc Rakefile VERSION) +
24
+ Dir.glob("{lib,spec}/**/*")
25
+
26
+ # rdoc
27
+ gem.has_rdoc = true
28
+ gem.extra_rdoc_files = %w(README.rdoc LICENSE VERSION)
29
+
30
+ # Dependencies
31
+ gem.add_dependency 'extlib', '>= 0.9.9'
32
+ gem.add_development_dependency 'rspec', '>= 1.2.0'
67
33
  end
34
+
35
+ Jeweler::GemcutterTasks.new
36
+ Jeweler::RubyforgeTasks.new
37
+ rescue LoadError
38
+ puts 'Jeweler (or a dependency) not available. Install it with: gem ' \
39
+ 'install jeweler'
68
40
  end
69
41
 
70
42
  ##############################################################################
71
43
  # Documentation
72
44
  ##############################################################################
73
- task :doc => ['doc:rdoc']
74
- namespace :doc do
75
45
 
76
- Rake::RDocTask.new do |rdoc|
77
- rdoc.rdoc_files.add(%w(LICENSE README.rdoc lib/**/*.rb))
78
- rdoc.main = "README.rdoc"
79
- rdoc.title = "IniParse API Documentation"
80
- rdoc.options << "--line-numbers" << "--inline-source"
81
- rdoc.rdoc_dir = 'doc'
82
- end
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
83
48
 
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "iniparse #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
84
53
  end
85
54
 
86
55
  ##############################################################################
87
- # rSpec & rcov
56
+ # Tests & Metrics.
88
57
  ##############################################################################
89
58
 
90
59
  desc "Run all examples"
91
- Spec::Rake::SpecTask.new('spec') do |t|
92
- t.spec_files = FileList['spec/**/*.rb']
93
- t.spec_opts = ['-c -f s']
60
+ Spec::Rake::SpecTask.new(:spec) do |spec|
61
+ spec.libs << 'lib' << 'spec'
62
+ spec.spec_files = FileList['spec/**/*_spec.rb']
63
+ spec.spec_opts = ['-c -f s']
94
64
  end
95
65
 
96
66
  desc "Run all examples with RCov"
97
- Spec::Rake::SpecTask.new('spec:rcov') do |t|
98
- t.spec_files = FileList['spec/**/*.rb']
99
- t.spec_opts = ['-c -f s']
100
- t.rcov = true
101
- t.rcov_opts = ['--exclude', 'spec']
67
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
68
+ spec.libs << 'lib' << 'spec'
69
+ spec.pattern = 'spec/**/*_spec.rb'
70
+ spec.spec_opts = ['-c -f s']
71
+ spec.rcov = true
72
+ spec.rcov_opts = ['--exclude', 'spec']
102
73
  end
74
+
75
+ task :spec => :check_dependencies
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/lib/iniparse.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'extlib'
3
2
 
4
3
  dir = Pathname(__FILE__).dirname.expand_path / 'iniparse'
@@ -8,9 +7,12 @@ require dir / 'generator'
8
7
  require dir / 'line_collection'
9
8
  require dir / 'lines'
10
9
  require dir / 'parser'
11
- require dir / 'version'
12
10
 
13
11
  module IniParse
12
+ VERSION = File.read(
13
+ Pathname(__FILE__).dirname.expand_path / '..' / 'VERSION'
14
+ ).strip
15
+
14
16
  # A base class for IniParse errors.
15
17
  class IniParseError < StandardError; end
16
18
 
@@ -1,6 +1,8 @@
1
1
  module IniParse
2
2
  # Represents an INI document.
3
3
  class Document
4
+ include Enumerable
5
+
4
6
  attr_reader :lines
5
7
  attr_accessor :path
6
8
 
@@ -197,4 +197,4 @@ module IniParse
197
197
  @opt_stack.last.empty? ? given_opts : @opt_stack.last.merge(given_opts)
198
198
  end
199
199
  end
200
- end
200
+ end
@@ -90,7 +90,7 @@ module IniParse
90
90
  # Returns this collection as a hash. Does not contain blank and comment
91
91
  # lines.
92
92
  def to_hash
93
- Hash[ map { |line| [line.key, line] } ]
93
+ Hash[ *(map { |line| [line.key, line] }).flatten ]
94
94
  end
95
95
 
96
96
  alias_method :to_h, :to_hash
@@ -287,4 +287,4 @@ module IniParse
287
287
  end
288
288
  end
289
289
  end # Lines
290
- end # IniParse
290
+ end # IniParse
@@ -88,5 +88,5 @@ module IniParse
88
88
  [line, opts]
89
89
  end
90
90
  end
91
- end
92
- end
91
+ end # Parser
92
+ end # IniParse
@@ -1,12 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe "IniParse::Document" do
4
- it 'should have a +sections+ reader' do
5
- IniParse::Document.instance_methods.should include('lines')
4
+ it 'should have a +lines+ reader' do
5
+ methods = IniParse::Document.instance_methods.map { |m| m.to_sym }
6
+ methods.should include(:lines)
6
7
  end
7
8
 
8
- it 'should not have a +sections+ writer' do
9
- IniParse::Document.instance_methods.should_not include('lines=')
9
+ it 'should not have a +lines+ writer' do
10
+ methods = IniParse::Document.instance_methods.map { |m| m.to_sym }
11
+ methods.should_not include(:lines=)
10
12
  end
11
13
 
12
14
  it 'should delegate #[] to +lines+' do
@@ -21,6 +23,20 @@ describe "IniParse::Document" do
21
23
  doc.each { |l| }
22
24
  end
23
25
 
26
+ it 'should be enumerable' do
27
+ IniParse::Document.included_modules.should include(Enumerable)
28
+
29
+ sections = [
30
+ IniParse::Lines::Section.new('first section'),
31
+ IniParse::Lines::Section.new('second section')
32
+ ]
33
+
34
+ doc = IniParse::Document.new
35
+ doc.lines << sections[0] << sections[1]
36
+
37
+ doc.map { |line| line }.should == sections
38
+ end
39
+
24
40
  describe '#has_section?' do
25
41
  before(:all) do
26
42
  @doc = IniParse::Document.new
@@ -101,4 +101,4 @@ describe 'When generating a document using Generator with section blocks using m
101
101
  # Comments and blanks are added in the same way as in the
102
102
  # 'with_section_block_spec.rb' specification.
103
103
 
104
- end
104
+ end
@@ -319,4 +319,4 @@ describe 'When generating a document using Generator with section blocks,' do
319
319
  end
320
320
  end
321
321
 
322
- end
322
+ end
@@ -133,4 +133,4 @@ describe 'When generating a document using Generator without section blocks,' do
133
133
  end
134
134
  end
135
135
 
136
- end
136
+ end
@@ -47,4 +47,4 @@ describe 'Parsing a document' do
47
47
  lambda { IniParse::Parser.new(fixture(:invalid_line)).parse }.should \
48
48
  raise_error(IniParse::ParseError)
49
49
  end
50
- end
50
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  $:.push File.join(File.dirname(__FILE__), '..', 'lib')
2
+
3
+ require 'rubygems'
2
4
  require 'iniparse'
3
5
  require File.join(File.dirname(__FILE__), 'spec_fixtures')
4
6
 
@@ -198,4 +198,4 @@ describe 'Line tuple [:comment, "A comment", {:opt => "val"}]' do
198
198
  it 'should fail be_comment_tuple("A comment", {:opt => "invalid"})' do
199
199
  @tuple.should_not be_comment_tuple("A comment", {:opt => "invalid"})
200
200
  end
201
- end
201
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iniparse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Williams
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-13 00:00:00 +00:00
12
+ date: 2010-01-05 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 0.9.9
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.0
34
+ version:
25
35
  description: A pure Ruby library for parsing INI documents.
26
36
  email: anthony@ninecraft.com
27
37
  executables: []
@@ -29,44 +39,43 @@ executables: []
29
39
  extensions: []
30
40
 
31
41
  extra_rdoc_files:
32
- - README.rdoc
33
42
  - LICENSE
43
+ - README.rdoc
44
+ - VERSION
34
45
  files:
35
46
  - LICENSE
36
47
  - README.rdoc
37
48
  - Rakefile
38
- - lib/iniparse
49
+ - VERSION
50
+ - lib/iniparse.rb
39
51
  - lib/iniparse/document.rb
40
52
  - lib/iniparse/generator.rb
41
53
  - lib/iniparse/line_collection.rb
42
54
  - lib/iniparse/lines.rb
43
55
  - lib/iniparse/parser.rb
44
- - lib/iniparse/version.rb
45
- - lib/iniparse.rb
46
56
  - spec/document_spec.rb
47
57
  - spec/fixture_spec.rb
48
- - spec/fixtures
49
58
  - spec/fixtures/openttd.ini
50
59
  - spec/fixtures/race07.ini
51
60
  - spec/fixtures/smb.ini
52
- - spec/generator
53
61
  - spec/generator/method_missing_spec.rb
54
62
  - spec/generator/with_section_blocks_spec.rb
55
63
  - spec/generator/without_section_blocks_spec.rb
56
64
  - spec/iniparse_spec.rb
57
65
  - spec/line_collection_spec.rb
58
66
  - spec/lines_spec.rb
59
- - spec/parser
60
67
  - spec/parser/document_parsing_spec.rb
61
68
  - spec/parser/line_parsing_spec.rb
62
69
  - spec/spec_fixtures.rb
63
70
  - spec/spec_helper.rb
64
71
  - spec/spec_helper_spec.rb
65
72
  has_rdoc: true
66
- homepage: http://github.com/anthonyw/iniparse
67
- post_install_message:
68
- rdoc_options: []
73
+ homepage: http://github.com/antw/iniparse
74
+ licenses: []
69
75
 
76
+ post_install_message:
77
+ rdoc_options:
78
+ - --charset=UTF-8
70
79
  require_paths:
71
80
  - lib
72
81
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -83,10 +92,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
92
  version:
84
93
  requirements: []
85
94
 
86
- rubyforge_project: iniparse
87
- rubygems_version: 1.3.0
95
+ rubyforge_project:
96
+ rubygems_version: 1.3.5
88
97
  signing_key:
89
- specification_version: 2
98
+ specification_version: 3
90
99
  summary: A pure Ruby library for parsing INI documents.
91
- test_files: []
92
-
100
+ test_files:
101
+ - spec/document_spec.rb
102
+ - spec/fixture_spec.rb
103
+ - spec/generator/method_missing_spec.rb
104
+ - spec/generator/with_section_blocks_spec.rb
105
+ - spec/generator/without_section_blocks_spec.rb
106
+ - spec/iniparse_spec.rb
107
+ - spec/line_collection_spec.rb
108
+ - spec/lines_spec.rb
109
+ - spec/parser/document_parsing_spec.rb
110
+ - spec/parser/line_parsing_spec.rb
111
+ - spec/spec_fixtures.rb
112
+ - spec/spec_helper.rb
113
+ - spec/spec_helper_spec.rb
@@ -1,3 +0,0 @@
1
- module IniParse
2
- VERSION = '0.2.1'
3
- end