archieml 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38f795c262135209607462aaf552bad7daec3bc0
4
- data.tar.gz: 44fe6ad8971f1232b65dfb34caded74fd947f8bb
3
+ metadata.gz: 20d1f2ce2e413edb046e36127d145f97d467b723
4
+ data.tar.gz: 6f84f4940d148c1e5d01e7e73e1b7f71ae514659
5
5
  SHA512:
6
- metadata.gz: e3895fd7157bca39da81dab19a4998b31a9ac6f6aa3b4c5e792fe6b9e68f3a22a41b6b8745ec94dddc77db48fccc35a081652bbbcf822ac6ad1321c9749b2390
7
- data.tar.gz: d0a2d979cb5cd1600f5e82b851e38c3fb39adee415641d757fad44ab8a38ce04cbb883cab26c6e5b290c6b2f74297cd159009c3cad79f827612bb79c22e64a61
6
+ metadata.gz: 98ebe6f5d69d8bc03fb564b1f19b7d54fb2b70eb08526ba3d6d1165d8cd7ef2f7f8995d5ce87637b674265f2589c5cec8bfe6a9221ff21754399e14d54a6cebb
7
+ data.tar.gz: 94414bb4b8a3fd0d43d516fa130a4c39ec471d0dad7e2f3cb828405fb3344cedc8cba64aafd0fbc43a8906ba05953b95e7284cac89f573ca5159aa6f2182bfbe
data/README.md CHANGED
@@ -4,7 +4,7 @@ Parse Archie Markup Language (ArchieML) documents into Ruby Hashes.
4
4
 
5
5
  Read about the ArchieML specification at [archieml.org](http://archieml.org).
6
6
 
7
- The current version is `v0.1.0`.
7
+ The current version is `v0.1.1`.
8
8
 
9
9
  ## Installation
10
10
 
@@ -167,6 +167,11 @@ end
167
167
  aml = Archieml.load(html_aml)
168
168
  ```
169
169
 
170
+ ## Tests
171
+
172
+ There is a full test suite using rspec. `bundle install`, and then `rspec` to execute them.
173
+
170
174
  ## Changelog
171
175
 
176
+ * `0.1.1` - More consistent handling of newlines. Fixed bugs around detecting the scope of multi-line values.
172
177
  * `0.1.0` - Initial release supporting the first version of the ArchieML spec, published [2015-03-06](http://archieml.org/spec/1.0/CR-20150306.html).
@@ -3,9 +3,9 @@ module Archieml
3
3
 
4
4
  NEXT_LINE = /.*((\r|\n)+)/
5
5
  START_KEY = /^\s*([A-Za-z0-9\-_\.]+)[ \t\r]*:[ \t\r]*(.*(?:\n|\r|$))/
6
- COMMAND_KEY = /^\s*:[ \t\r]*(endskip|ignore|skip|end)/i
6
+ COMMAND_KEY = /^\s*:[ \t\r]*(endskip|ignore|skip|end)(.*(?:\n|\r|$))/i
7
7
  ARRAY_ELEMENT = /^\s*\*[ \t\r]*(.*(?:\n|\r|$))/
8
- SCOPE_PATTERN = /^\s*(\[|\{)[ \t\r]*([A-Za-z0-9\-_\.]*)[ \t\r]*(?:\]|\})[ \t\r]*.*?(\n|\r|$)/
8
+ SCOPE_PATTERN = /^\s*(\[|\{)[ \t\r]*([A-Za-z0-9\-_\.]*)[ \t\r]*(?:\]|\}).*?(\n|\r|$)/
9
9
 
10
10
  def initialize
11
11
  @data = @scope = {}
@@ -99,8 +99,6 @@ module Archieml
99
99
  when "endskip"
100
100
  @is_skipping = false
101
101
  end
102
-
103
- self.flush_buffer!
104
102
  end
105
103
 
106
104
  def parse_scope(scope_type, scope_key)
@@ -119,6 +117,7 @@ module Archieml
119
117
 
120
118
  if scope_type == '['
121
119
  @array = key_scope[key_bits.last] ||= []
120
+ @array = key_scope[key_bits.last] = [] if @array.class == String
122
121
 
123
122
  if @array.length > 0
124
123
  @array_type = @array.first.class == String ? 'simple' : 'complex'
@@ -165,7 +164,7 @@ module Archieml
165
164
  end
166
165
 
167
166
  def flush_scope!
168
- @array = @array_type = @array_first_key = nil
167
+ @array = @array_type = @array_first_key = @buffer_key = nil
169
168
  end
170
169
 
171
170
  # type can be either :replace or :append.
@@ -1,3 +1,3 @@
1
1
  module Archieml
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -56,10 +56,10 @@ describe Archieml::Loader do
56
56
  @loader.load("scope.key:value\nscope.otherkey:value")['scope']['key'].should == 'value'
57
57
  @loader.load("scope.key:value\nscope.otherkey:value")['scope']['otherkey'].should == 'value'
58
58
  end
59
- it "the value of key that used to be a parent object should be replaced with a string if necessary" do
59
+ it "the value of key that used to be a string should be replaced with an object if necessary" do
60
60
  @loader.load("scope.level:value\nscope.level.level:value")['scope']['level']['level'].should == 'value'
61
61
  end
62
- it "the value of key that used to be a string object should be replaced with an object if necessary" do
62
+ it "the value of key that used to be a parent object should be replaced with a string if necessary" do
63
63
  @loader.load("scope.level.level:value\nscope.level:value")['scope']['level'].should == 'value'
64
64
  end
65
65
 
@@ -257,12 +257,27 @@ describe Archieml::Loader do
257
257
  @loader.load("key:value\n\\[comment]\n:end")['key'].should == "value"
258
258
  @loader.load("key:value\n\\[[array]]\n:end")['key'].should == "value\n[array]"
259
259
  end
260
+ it "arrays within a multi-line value breaks up the value" do
261
+ @loader.load("key:value\ntext\n[array]\nmore text\n:end")['key'].should == "value"
262
+ end
263
+ it "objects within a multi-line value breaks up the value" do
264
+ @loader.load("key:value\ntext\n{scope}\nmore text\n:end")['key'].should == "value"
265
+ end
266
+ it "bullets within a multi-line value do not break up the value" do
267
+ @loader.load("key:value\ntext\n* value\nmore text\n:end")['key'].should == "value\ntext\n* value\nmore text"
268
+ end
269
+ it "skips within a multi-line value do not break up the value" do
270
+ @loader.load("key:value\ntext\n:skip\n:endskip\nmore text\n:end")['key'].should == "value\ntext\nmore text"
271
+ end
260
272
  it "allows escaping initial backslash at the beginning of lines" do
261
273
  @loader.load("key:value\n\\\\:end\n:end")['key'].should == "value\n\\:end"
262
274
  end
263
275
  it "escapes only one initial backslash" do
264
276
  @loader.load("key:value\n\\\\\\:end\n:end")['key'].should == "value\n\\\\:end"
265
277
  end
278
+ it "allows escaping multiple lines in a value" do
279
+ @loader.load("key:value\n\\:end\n\\:ignore\n\\:endskip\n\\:skip\n:end'")['key'].should == "value\n:end\n:ignore\n:endskip\n:skip"
280
+ end
266
281
  it "doesn't escape colons after beginning of lines" do
267
282
  @loader.load("key:value\nLorem key2\\:value\n:end")['key'].should == "value\nLorem key2\\:value"
268
283
  end
@@ -427,12 +442,30 @@ describe Archieml::Loader do
427
442
  it "does not allow escaping of colons not at the beginning of lines" do
428
443
  @loader.load("[array]\n*Value\nword key\\:value\n:end")['array'].first.should == "Value\nword key\\:value"
429
444
  end
445
+ it "arrays within a multi-line value breaks up the value" do
446
+ @loader.load("[array]\n* value\n[array]\nmore text\n:end")['array'].first.should == "value"
447
+ end
448
+ it "objects within a multi-line value breaks up the value" do
449
+ @loader.load("[array]\n* value\n{scope}\nmore text\n:end")['array'].first.should == "value"
450
+ end
451
+ it "key/values within a multi-line value do not break up the value" do
452
+ @loader.load("[array]\n* value\nkey: value\nmore text\n:end")['array'].first.should == "value\nkey: value\nmore text"
453
+ end
454
+ it "bullets within a multi-line value break up the value" do
455
+ @loader.load("[array]\n* value\n* value\nmore text\n:end")['array'].first.should == "value"
456
+ end
457
+ it "skips within a multi-line value do not break up the value" do
458
+ @loader.load("[array]\n* value\n:skip\n:endskip\nmore text\n:end")['array'].first.should == "value\nmore text"
459
+ end
430
460
  it "arrays that are reopened add to existing array" do
431
461
  @loader.load("[array]\n*Value\n[]\n[array]\n*Value")['array'].should == ['Value', 'Value']
432
462
  end
433
463
  it "simple arrays that are reopened remain simple" do
434
464
  @loader.load("[array]\n*Value\n[]\n[array]\nkey:value")['array'].should == ['Value']
435
465
  end
466
+ it "simple arrays overwrite existing keys" do
467
+ @loader.load("a.b:complex value\n[a.b]\n*simple value")['a']['b'][0].should == 'simple value'
468
+ end
436
469
 
437
470
  end
438
471
 
@@ -455,12 +488,30 @@ describe Archieml::Loader do
455
488
  it "duplicate keys must match on dot-notation scope" do
456
489
  @loader.load("[array]\nscope.key:value\nkey:value\notherscope.key:value")['array'].length.should == 1
457
490
  end
491
+ it "arrays within a multi-line value breaks up the value" do
492
+ @loader.load("[array]\nkey:value\n[array]\nmore text\n:end")['array'].first['key'].should == "value"
493
+ end
494
+ it "objects within a multi-line value breaks up the value" do
495
+ @loader.load("[array]\nkey:value\n{scope}\nmore text\n:end")['array'].first['key'].should == "value"
496
+ end
497
+ it "key/values within a multi-line value break up the value" do
498
+ @loader.load("[array]\nkey:value\nother: value\nmore text\n:end")['array'].first['key'].should == "value"
499
+ end
500
+ it "bullets within a multi-line value do not break up the value" do
501
+ @loader.load("[array]\nkey:value\n* value\nmore text\n:end")['array'].first['key'].should == "value\n* value\nmore text"
502
+ end
503
+ it "skips within a multi-line value do not break up the value" do
504
+ @loader.load("[array]\nkey:value\n:skip\n:endskip\nmore text\n:end")['array'].first['key'].should == "value\nmore text"
505
+ end
458
506
  it "arrays that are reopened add to existing array" do
459
507
  @loader.load("[array]\nkey:value\n[]\n[array]\nkey:value")['array'].length.should == 2
460
508
  end
461
509
  it "complex arrays that are reopened remain complex" do
462
510
  @loader.load("[array]\nkey:value\n[]\n[array]\n*Value")['array'].should == [{'key' => 'value'}]
463
511
  end
512
+ it "complex arrays overwrite existing keys" do
513
+ @loader.load("a.b:complex value\n[a.b]\nkey:value")['a']['b'][0]['key'].should == 'value'
514
+ end
464
515
 
465
516
  end
466
517
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archieml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Strickland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-05 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parse Archie Markup Language documents
14
14
  email:
@@ -17,7 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - .gitignore
20
+ - ".gitignore"
21
21
  - Gemfile
22
22
  - LICENSE
23
23
  - README.md
@@ -38,12 +38,12 @@ require_paths:
38
38
  - lib
39
39
  required_ruby_version: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  requirements: []