weskit 0.3.2 → 0.3.3

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.
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.0.0
3
4
  - 1.9.3
4
5
  - 1.8.7
@@ -1,9 +1,14 @@
1
- Weskit [![Build Status](https://secure.travis-ci.org/f6p/weskit.png?branch=master)](http://travis-ci.org/f6p/weskit)
2
- ====================================================================================================================
1
+ Weskit
2
+ ======
3
3
 
4
- Weskit gem consists of tools for interaction with Wesnoth Markup Langage and Wesnoth infrastructure.
5
- For more documentation check out ri pages and examples directory. Production code that
6
- utilizes weskit capabilites can be found inside Ladder8 sources.
4
+ [![Build Status](https://secure.travis-ci.org/f6p/weskit.png?branch=master)](http://travis-ci.org/f6p/weskit)
5
+ [![Gem Version](https://badge.fury.io/rb/weskit.png)](http://badge.fury.io/rb/weskit)
6
+ [![Code Climate](https://codeclimate.com/github/f6p/weskit.png)](https://codeclimate.com/github/f6p/weskit.png)
7
+
8
+ Weskit gem consists of tools for interaction with Wesnoth Markup Langage and
9
+ Wesnoth infrastructure. For more documentation check out ri pages and examples
10
+ directory. Production code that utilizes weskit capabilites can be found
11
+ inside Ladder8 sources.
7
12
 
8
13
  #### Modules
9
14
 
@@ -2,11 +2,12 @@ require 'term/ansicolor'
2
2
 
3
3
  module Weskit::MP
4
4
  class Adapter
5
- attr_accessor :buffer, :socket
5
+ attr_accessor :buffer, :parser, :socket
6
6
 
7
7
  def initialize connection, debug = false
8
8
  @connection = connection
9
9
  @debug = debug
10
+ @parser = :simple
10
11
  end
11
12
 
12
13
  def message container, hash
@@ -56,7 +57,7 @@ module Weskit::MP
56
57
  @buffer = nil
57
58
 
58
59
  puts debug_header(:read) if @debug
59
- @buffer = ::Weskit::WML::Parser.string Zlib::GzipReader.new(data).read
60
+ @buffer = ::Weskit::WML::Parser.string Zlib::GzipReader.new(data).read, @parser
60
61
  puts debug(@buffer) if @debug
61
62
 
62
63
  @buffer
@@ -78,4 +79,4 @@ module Weskit::MP
78
79
  puts debug(node) if @debug
79
80
  end
80
81
  end
81
- end
82
+ end
@@ -1,3 +1,3 @@
1
1
  module Weskit
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -3,7 +3,7 @@ class Object
3
3
 
4
4
  attr_reader :attribute
5
5
 
6
- alias_method :attr, :attribute
6
+ alias_method :attr, :attribute
7
7
 
8
8
  def attribute= item
9
9
  @attribute = item ? (raise_unless ::Weskit::WML::Attribute, item ; item) : nil
@@ -16,4 +16,4 @@ class Object
16
16
  end
17
17
 
18
18
  alias_method :attr?, :attribute?
19
- end
19
+ end
@@ -2,7 +2,7 @@ module Weskit::WML::Mixins
2
2
  module Grammar
3
3
  module_function
4
4
 
5
- def raise_on_mismatching opening, closing
5
+ def raise_on_mismatch opening, closing
6
6
  unless opening.name == closing.name
7
7
  raise ::Weskit::WML::Errors::ParseError, 'Invalid element'
8
8
  end
@@ -14,4 +14,4 @@ module Weskit::WML::Mixins
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -83,13 +83,22 @@ module Weskit::WML::Parsers
83
83
  def current_attribute
84
84
  tmp = @current_match[1..2].collect &:strip
85
85
 
86
- tmp[0] = tmp.first.to_sym
86
+ name = attribute_name tmp.first
87
+ value = attribute_value tmp.last
87
88
 
88
- tmp.last.gsub! /^"|"$/, ''
89
- tmp.last.gsub! '""', '"'
90
- tmp.last.strip!
89
+ [name, value]
90
+ end
91
+
92
+ def attribute_name string
93
+ string.to_sym
94
+ end
91
95
 
92
- tmp
96
+ def attribute_value string
97
+ case string
98
+ when /^"(.*)"$/ then $1.strip
99
+ when /^"(.*)$/ then $1.strip + '...'
100
+ else string
101
+ end.gsub '""', '"'
93
102
  end
94
103
 
95
104
  def current_tag
@@ -60,8 +60,17 @@ describe Weskit::WML::Parser do
60
60
  end
61
61
 
62
62
  context 'with Simple backend' do
63
+ let(:backend) { :simple }
64
+
63
65
  it_should_behave_like 'basic parser' do
64
- let(:parser) { :simple }
66
+ let(:parser) { backend }
67
+ end
68
+
69
+ context 'attribute' do
70
+ specify 'multiline' do
71
+ parsed = Weskit::WML::Parser.string %Q{a = "a \n b"}, backend
72
+ parsed[:a].should match_value_of('a...')
73
+ end
65
74
  end
66
75
  end
67
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weskit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-15 00:00:00.000000000 Z
12
+ date: 2013-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: kpeg
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  requirements: []
172
172
  rubyforge_project:
173
- rubygems_version: 1.8.24
173
+ rubygems_version: 1.8.25
174
174
  signing_key:
175
175
  specification_version: 3
176
176
  summary: Ruby utilies for BfW