rgviz 0.27 → 0.28

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/lib/rgviz/nodes.rb CHANGED
@@ -42,7 +42,7 @@ module Rgviz
42
42
  str << "offset #{offset} " if offset
43
43
  str << "label #{labels.map(&:to_s).join(', ')} " if labels
44
44
  str << "format #{formats.map(&:to_s).join(', ')} " if formats
45
- str << "options #{options.map(&:to_s).join(', ')} " if options
45
+ str << "options #{options} " if options
46
46
  str.strip
47
47
  end
48
48
  end
@@ -191,24 +191,16 @@ module Rgviz
191
191
  end
192
192
  end
193
193
 
194
- class Option
195
-
196
- NoValues = :no_values
197
- NoFormat = :no_format
198
-
199
- attr_accessor :option
200
-
201
- def initialize(option)
202
- @option = option
203
- end
194
+ class Options
204
195
 
205
- def accept(visitor)
206
- visitor.visit_option(self)
207
- visitor.end_visit_option self
208
- end
196
+ attr_accessor :no_values
197
+ attr_accessor :no_format
209
198
 
210
199
  def to_s
211
- @option.to_s
200
+ s = ''
201
+ s += 'no_values ' if @no_values
202
+ s += 'no_format ' if @no_format
203
+ s.strip
212
204
  end
213
205
 
214
206
  end
data/lib/rgviz/parser.rb CHANGED
@@ -138,14 +138,22 @@ module Rgviz
138
138
  def parse_options
139
139
  return if not token_is! Token::Options
140
140
 
141
- @query.options = []
141
+ @query.options = Options.new
142
142
 
143
- while @token.value == Token::NoValues || @token.value == Token::NoFormat
144
- @query.options << Option.new(@token.value)
145
- next_token
143
+ while true
144
+ case @token.value
145
+ when Token::NoFormat
146
+ @query.options.no_format = true
147
+ next_token
148
+ when Token::NoValues
149
+ @query.options.no_values = true
150
+ next_token
151
+ else
152
+ break
153
+ end
146
154
  end
147
155
 
148
- raise ParseException.new "Expecting option" if @query.options.empty?
156
+ raise ParseException.new "Expecting option" if !@query.options.no_format && !@query.options.no_values
149
157
  raise ParseException.new "Unknown option" if @token.value != Token::EOF
150
158
  end
151
159
 
data/lib/rgviz/visitor.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Rgviz
2
2
  class Visitor
3
3
  ['query', 'select', 'group_by', 'pivot', 'order_by',
4
- 'sort', 'where', 'label', 'format', 'option',
4
+ 'sort', 'where', 'label', 'format',
5
5
  'binary_expression', 'unary_expression',
6
6
  'id_column', 'number_column', 'string_column',
7
7
  'boolean_column', 'date_column', 'date_time_column',
@@ -327,13 +327,8 @@ describe Parser do
327
327
  it "parses options" do
328
328
  query = parse "options no_values no_format"
329
329
  options = query.options
330
- options.length.should == 2
331
-
332
- options[0].should be_a_kind_of Option
333
- options[0].option.should == Option::NoValues
334
-
335
- options[1].should be_a_kind_of Option
336
- options[1].option.should == Option::NoFormat
330
+ options.no_values.should be_true
331
+ options.no_format.should be_true
337
332
  end
338
333
 
339
334
  it_raises_on 'select'
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgviz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 27
9
- version: "0.27"
8
+ - 28
9
+ version: "0.28"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ary Borenszweig