iniparse 1.1.3 → 1.1.4

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/History CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.1.4 (2nd September 2010)
2
+
3
+ * Fix parsing of lines which contains an equals in the value
4
+
1
5
  == 1.1.3 (4th March 2010)
2
6
 
3
7
  * Fix so that VERSION is correctly read on Windows.
data/README.rdoc CHANGED
@@ -10,7 +10,7 @@ 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.
13
+ IniParse tests pass on Ruby 1.8.6p399, 1.8.7p249, and 1.9.1p378, JRuby 1.4.0 and Rubinius 1.0.0 RC2.
14
14
 
15
15
  === Main features
16
16
 
data/Rakefile CHANGED
@@ -1,6 +1,43 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'date'
4
+
1
5
  require 'rake/clean'
2
6
  require 'rake/rdoctask'
3
- require 'spec/rake/spectask'
7
+ require 'rspec/core/rake_task'
8
+
9
+ ##############################################################################
10
+ # Helpers
11
+ ##############################################################################
12
+
13
+ def name
14
+ @name ||= Dir['*.gemspec'].first.split('.').first
15
+ end
16
+
17
+ def version
18
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
19
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
20
+ end
21
+
22
+ def date
23
+ Date.today.to_s
24
+ end
25
+
26
+ def rubyforge_project
27
+ name
28
+ end
29
+
30
+ def gemspec_file
31
+ "#{name}.gemspec"
32
+ end
33
+
34
+ def gem_file
35
+ "#{name}-#{version}.gem"
36
+ end
37
+
38
+ def replace_header(head, header_name)
39
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
40
+ end
4
41
 
5
42
  ##############################################################################
6
43
  # Packaging & Installation.
@@ -8,33 +45,67 @@ require 'spec/rake/spectask'
8
45
 
9
46
  CLEAN.include ['pkg', '*.gem', 'doc', 'coverage']
10
47
 
11
- begin
12
- require 'jeweler'
48
+ desc 'Build the gem, and push to Github'
49
+ task :release => :build do
50
+ unless `git branch` =~ /^\* master$/
51
+ puts "You must be on the master branch to release!"
52
+ exit!
53
+ end
54
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
55
+ sh "git tag v#{version}"
56
+ sh "git push origin master"
57
+ sh "git push origin v#{version}"
58
+
59
+ puts "Push to Rubygems.org with"
60
+ puts " gem push pkg/#{name}-#{version}.gem"
61
+ end
13
62
 
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'
63
+ desc 'Builds the IniParse gem'
64
+ task :build => :gemspec do
65
+ sh "mkdir -p pkg"
66
+ sh "gem build #{gemspec_file}"
67
+ sh "mv #{gem_file} pkg"
68
+ end
22
69
 
23
- gem.files = %w(LICENSE README.rdoc Rakefile VERSION) +
24
- Dir.glob("{lib,spec}/**/*")
70
+ desc 'Creates a fresh gemspec'
71
+ task :gemspec => :validate do
72
+ # read spec file and split out manifest section
73
+ spec = File.read(gemspec_file)
74
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
25
75
 
26
- # rdoc
27
- gem.has_rdoc = true
28
- gem.extra_rdoc_files = %w(README.rdoc History LICENSE VERSION)
76
+ # replace name version and date
77
+ replace_header(head, :name)
78
+ replace_header(head, :version)
79
+ replace_header(head, :date)
80
+ #comment this out if your rubyforge_project has a different name
81
+ replace_header(head, :rubyforge_project)
29
82
 
30
- # Dependencies
31
- gem.add_development_dependency 'rspec', '>= 1.2.0'
32
- end
83
+ # determine file list from git ls-files
84
+ files = `git ls-files`.
85
+ split("\n").
86
+ sort.
87
+ reject { |file| file =~ /^\./ }.
88
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
89
+ map { |file| " #{file}" }.
90
+ join("\n")
33
91
 
34
- Jeweler::GemcutterTasks.new
35
- rescue LoadError
36
- puts 'Jeweler (or a dependency) not available. Install it with: gem ' \
37
- 'install jeweler'
92
+ # piece file back together and write
93
+ manifest = " s.files = %w[\n#{files}\n ]\n"
94
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
95
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
96
+ puts "Updated #{gemspec_file}"
97
+ end
98
+
99
+ task :validate do
100
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
101
+ unless libfiles.empty?
102
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
103
+ exit!
104
+ end
105
+ unless Dir['VERSION*'].empty?
106
+ puts "A `VERSION` file at root level violates Gem best practices."
107
+ exit!
108
+ end
38
109
  end
39
110
 
40
111
  ##############################################################################
@@ -42,8 +113,6 @@ end
42
113
  ##############################################################################
43
114
 
44
115
  Rake::RDocTask.new do |rdoc|
45
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
-
47
116
  rdoc.rdoc_dir = 'rdoc'
48
117
  rdoc.title = "iniparse #{version}"
49
118
  rdoc.rdoc_files.include('README*')
@@ -54,20 +123,6 @@ end
54
123
  # Tests & Metrics.
55
124
  ##############################################################################
56
125
 
57
- desc "Run all examples"
58
- Spec::Rake::SpecTask.new(:spec) do |spec|
59
- spec.libs << 'lib' << 'spec'
60
- spec.spec_files = FileList['spec/**/*_spec.rb']
61
- spec.spec_opts = ['-c -f p']
62
- end
63
-
64
- desc "Run all examples with RCov"
65
- Spec::Rake::SpecTask.new(:rcov) do |spec|
66
- spec.libs << 'lib' << 'spec'
126
+ RSpec::Core::RakeTask.new('spec') do |spec|
67
127
  spec.pattern = 'spec/**/*_spec.rb'
68
- spec.spec_opts = ['-c -f s']
69
- spec.rcov = true
70
- spec.rcov_opts = ['--exclude', 'spec']
71
128
  end
72
-
73
- task :spec => :check_dependencies
data/TODO ADDED
@@ -0,0 +1,2 @@
1
+ * Support multi-line options with backslashes (presumably with
2
+ OptionCollection).
data/iniparse.gemspec ADDED
@@ -0,0 +1,66 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.specification_version = 2 if s.respond_to? :specification_version=
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
+ s.rubygems_version = '1.3.5'
10
+
11
+ ## Leave these as is they will be modified for you by the rake gemspec task.
12
+ ## If your rubyforge_project name is different, then edit it and comment out
13
+ ## the sub! line in the Rakefile
14
+ s.name = 'iniparse'
15
+ s.version = '1.1.4'
16
+ s.date = '2010-09-02'
17
+ s.rubyforge_project = 'iniparse'
18
+
19
+ s.summary = 'A pure Ruby library for parsing INI documents.'
20
+ s.authors = ['Anthony Williams']
21
+ s.email = 'hi@antw.me'
22
+ s.homepage = 'http://github.com/antw/iniparse'
23
+
24
+ s.require_paths = %w(lib)
25
+
26
+ s.rdoc_options = ['--charset=UTF-8']
27
+ s.extra_rdoc_files = %w(History LICENSE README.rdoc)
28
+
29
+ # Dependencies.
30
+ s.add_development_dependency('rspec', '>= 2.0.0.beta.20')
31
+
32
+ # = MANIFEST =
33
+ s.files = %w[
34
+ History
35
+ LICENSE
36
+ README.rdoc
37
+ Rakefile
38
+ TODO
39
+ iniparse.gemspec
40
+ lib/iniparse.rb
41
+ lib/iniparse/document.rb
42
+ lib/iniparse/generator.rb
43
+ lib/iniparse/line_collection.rb
44
+ lib/iniparse/lines.rb
45
+ lib/iniparse/parser.rb
46
+ spec/document_spec.rb
47
+ spec/fixture_spec.rb
48
+ spec/fixtures/openttd.ini
49
+ spec/fixtures/race07.ini
50
+ spec/fixtures/smb.ini
51
+ spec/generator/method_missing_spec.rb
52
+ spec/generator/with_section_blocks_spec.rb
53
+ spec/generator/without_section_blocks_spec.rb
54
+ spec/iniparse_spec.rb
55
+ spec/line_collection_spec.rb
56
+ spec/lines_spec.rb
57
+ spec/parser/document_parsing_spec.rb
58
+ spec/parser/line_parsing_spec.rb
59
+ spec/spec_fixtures.rb
60
+ spec/spec_helper.rb
61
+ spec/spec_helper_spec.rb
62
+ ]
63
+ # = MANIFEST =
64
+
65
+ s.test_files = s.files.select { |path| path =~ /^spec\/.*\.rb/ }
66
+ end
data/lib/iniparse.rb CHANGED
@@ -7,7 +7,7 @@ require File.join(dir, 'lines')
7
7
  require File.join(dir, 'parser')
8
8
 
9
9
  module IniParse
10
- VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip
10
+ VERSION = '1.1.4'
11
11
 
12
12
  # A base class for IniParse errors.
13
13
  class IniParseError < StandardError; end
@@ -200,9 +200,9 @@ module IniParse
200
200
  class Option
201
201
  include Line
202
202
 
203
- @regex = /^(.*) # Key
203
+ @regex = /^\s*([^=]+) # Option
204
204
  =
205
- (.*?)$ # Value
205
+ (.*?)$ # Value
206
206
  /x
207
207
 
208
208
  attr_accessor :key, :value
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe "IniParse::Document" do
4
4
  it 'should have a +lines+ reader' do
data/spec/fixture_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe "IniParse" do
4
4
  describe 'openttd.ini fixture' do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  # Tests use of the Generator when used like so:
4
4
  #
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  # Tests use of the Generator when used like so:
4
4
  #
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  # Tests use of the Generator when used like so:
4
4
  #
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
 
4
4
  describe "IniParse" do
@@ -1,10 +1,10 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  # ----------------------------------------------------------------------------
4
4
  # Shared specs for all Collection types...
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- describe "LineCollection", :shared => true do
7
+ share_examples_for "LineCollection" do
8
8
  before(:each) do
9
9
  @collection << (@c1 = IniParse::Lines::Comment.new)
10
10
  @collection << @i1
@@ -180,6 +180,7 @@ describe 'IniParse::OptionCollection' do
180
180
 
181
181
  describe '#keys' do
182
182
  it 'should handle duplicates' do
183
+ @collection << @i1 << @i2 << @i3
183
184
  @collection << IniParse::Lines::Option.new('first', 'v5')
184
185
  @collection.keys.should == ['first', 'second', 'third']
185
186
  end
@@ -205,6 +206,7 @@ describe 'IniParse::SectionCollection' do
205
206
 
206
207
  it 'should add merge Section with the other, if it is a duplicate' do
207
208
  new_section = IniParse::Lines::Section.new('first')
209
+ @collection << @i1
208
210
  @i1.should_receive(:merge!).with(new_section).once
209
211
  @collection << new_section
210
212
  end
data/spec/lines_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  module IniParse::Test
4
4
  class FakeLine
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  # Tests parsing of multiple lines, in context, using #parse.
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  # Tests parsing of individual, out of context, line types using #parse_line.
4
4
 
@@ -154,6 +154,21 @@ describe 'Parsing a line' do
154
154
  end
155
155
  end
156
156
 
157
+
158
+ describe 'with "key = EEjDDJJjDJDJD233232=="' do
159
+ it 'should include the "equals" in the option value' do
160
+ IniParse::Parser.parse_line('key = EEjDDJJjDJDJD233232==').should \
161
+ be_option_tuple('key', 'EEjDDJJjDJDJD233232==')
162
+ end
163
+ end
164
+
165
+ describe 'with "key = ==EEjDDJJjDJDJD233232"' do
166
+ it 'should include the "equals" in the option value' do
167
+ IniParse::Parser.parse_line('key = ==EEjDDJJjDJDJD233232').should \
168
+ be_option_tuple('key', '==EEjDDJJjDJDJD233232')
169
+ end
170
+ end
171
+
157
172
  describe 'with "key.two = value"' do
158
173
  it 'should return an option tuple with the correct key' do
159
174
  IniParse::Parser.parse_line('key.two = value').should \
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  $:.push File.join(File.dirname(__FILE__), '..', 'lib')
2
2
 
3
3
  require 'rubygems'
4
+ require 'rspec'
5
+
4
6
  require 'iniparse'
5
7
  require File.join(File.dirname(__FILE__), 'spec_fixtures')
6
8
 
@@ -161,6 +163,6 @@ module IniParse
161
163
  end
162
164
  end
163
165
 
164
- Spec::Runner.configure do |config|
166
+ RSpec.configure do |config|
165
167
  config.include(IniParse::Test::Helpers)
166
168
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  # --
4
4
  # ============================================================================
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iniparse
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 1
8
- - 3
9
- version: 1.1.3
9
+ - 4
10
+ version: 1.1.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Anthony Williams
@@ -14,25 +15,29 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-03-04 00:00:00 +00:00
18
+ date: 2010-09-02 00:00:00 +01:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rspec
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 62196427
27
30
  segments:
28
- - 1
29
31
  - 2
30
32
  - 0
31
- version: 1.2.0
33
+ - 0
34
+ - beta
35
+ - 20
36
+ version: 2.0.0.beta.20
32
37
  type: :development
33
38
  version_requirements: *id001
34
- description: A pure Ruby library for parsing INI documents.
35
- email: anthony@ninecraft.com
39
+ description:
40
+ email: hi@antw.me
36
41
  executables: []
37
42
 
38
43
  extensions: []
@@ -41,12 +46,13 @@ extra_rdoc_files:
41
46
  - History
42
47
  - LICENSE
43
48
  - README.rdoc
44
- - VERSION
45
49
  files:
50
+ - History
46
51
  - LICENSE
47
52
  - README.rdoc
48
53
  - Rakefile
49
- - VERSION
54
+ - TODO
55
+ - iniparse.gemspec
50
56
  - lib/iniparse.rb
51
57
  - lib/iniparse/document.rb
52
58
  - lib/iniparse/generator.rb
@@ -69,7 +75,6 @@ files:
69
75
  - spec/spec_fixtures.rb
70
76
  - spec/spec_helper.rb
71
77
  - spec/spec_helper_spec.rb
72
- - History
73
78
  has_rdoc: true
74
79
  homepage: http://github.com/antw/iniparse
75
80
  licenses: []
@@ -80,25 +85,29 @@ rdoc_options:
80
85
  require_paths:
81
86
  - lib
82
87
  required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
83
89
  requirements:
84
90
  - - ">="
85
91
  - !ruby/object:Gem::Version
92
+ hash: 3
86
93
  segments:
87
94
  - 0
88
95
  version: "0"
89
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
90
98
  requirements:
91
99
  - - ">="
92
100
  - !ruby/object:Gem::Version
101
+ hash: 3
93
102
  segments:
94
103
  - 0
95
104
  version: "0"
96
105
  requirements: []
97
106
 
98
- rubyforge_project:
99
- rubygems_version: 1.3.6
107
+ rubyforge_project: iniparse
108
+ rubygems_version: 1.3.7
100
109
  signing_key:
101
- specification_version: 3
110
+ specification_version: 2
102
111
  summary: A pure Ruby library for parsing INI documents.
103
112
  test_files:
104
113
  - spec/document_spec.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.1.3