fixture_fox 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 559cb3c1dc15071bcb9ddb4dd8dbb7f31e212cfa131093aa29db1a8d8be5137e
4
- data.tar.gz: 919e1f0458dc7d632dfd37c5cc62851adaedd05cb9a927477d021f637a1b9480
3
+ metadata.gz: f5d11738a008959b4da678a81352f3cf2d78c5a32dfcee362085cf9371b729ac
4
+ data.tar.gz: 7fc2a1f30a2b3f5a940e2454c9856e2979b71317559b1577955e2cae1b08348b
5
5
  SHA512:
6
- metadata.gz: 5c8e37e8ced79cf730949f3bf7c05e53cca8d63c617071fb27c69693f2e025387a29941672fa59ec5a4f001c8d4e258660be64ea6e29a1992103f06492783a02
7
- data.tar.gz: db3e0a16ee29fa1f31b33b27c05da0d702e70ce90617200a91b474ce29ae36eca40f9238c14e4ff7507a583de5c1ceeb481f7fd3b3784a14de283f2e0ce85953
6
+ metadata.gz: f34d0bf3301a95c14fc8666a86934c51e9ffc51de5016233a4567173731c1dd92827011db9b99225748dc0af26749246f177d52d98fa06df6b97989d5082cb22
7
+ data.tar.gz: 5df4eb70caa2e9e1f21bd018f7c30ce0d9c93b718b4c9796b28632c74f31ca2ef419441907496fe0fe079567305fa6d07abc94a23d2307f6bf2b905f1adb3afc
@@ -108,7 +108,7 @@ module FixtureFox
108
108
  ast.tables.each { |ast_table|
109
109
  @type.key?(ast_table.schema.value.downcase) or
110
110
  ast_table.schema.error("Can't find schema '#{ast_table.schema}'")
111
- type = ast_table.type = @type[ast_table.schema.value.downcase][ast_table.name.downcase] or
111
+ type = ast_table.type = @type[ast_table.schema.value.downcase][ast_table.name.downcase] or
112
112
  ast_table.ident.error(
113
113
  "Can't find ast_table '#{ast_table.ident}' (maybe you forgot to declare a schema?)")
114
114
  @tables[type.uid] = type
@@ -136,7 +136,7 @@ module FixtureFox
136
136
 
137
137
  def assign_field_types(ast_record)
138
138
  ast_record.members.each { |field|
139
- field.column = ast_record.type[field.ident.litt.downcase] or
139
+ field.column = ast_record.type[field.ident.litt.downcase] or
140
140
  field.ident.error("Can't find field '#{ast_record.type.table.name}.#{field.ident}'")
141
141
  field.type = field.column.type
142
142
  case field
@@ -174,9 +174,9 @@ module FixtureFox
174
174
  end
175
175
 
176
176
  values.each { |value|
177
- if value.is_a?(klass) || !f.type.array? &&
178
- klass == Time &&
179
- value.is_a?(String) &&
177
+ if value.is_a?(klass) || !f.type.array? &&
178
+ (klass == Time || klass == Date) &&
179
+ value.is_a?(String) &&
180
180
  value =~ /^\d\d\d\d-\d\d-\d\d(?: \d\d:\d\d(?::\d\d)?)?$/
181
181
  ;
182
182
  else
@@ -192,9 +192,9 @@ module FixtureFox
192
192
  end
193
193
 
194
194
  def check_ref(ast_ref)
195
- anchor = ast_ref.referenced_anchor = @anchors[ast_ref.reference.value.to_sym] or
195
+ anchor = ast_ref.referenced_anchor = @anchors[ast_ref.reference.value.to_sym] or
196
196
  ast_ref.reference.error("Can't find anchor for reference '#{ast_ref.reference.litt}'")
197
- anchor_types =
197
+ anchor_types =
198
198
  [anchor.type] +
199
199
  (anchor.type.table.sub_table? ? [anchor.type.table.super_table.record_type] : [])
200
200
  anchor_types.any? { |anchor_type| ast_ref.type == anchor_type } or
@@ -319,7 +319,7 @@ module FixtureFox
319
319
  field.elements.each { |r|
320
320
  record_id = r.is_a?(AstReferenceElement) ? r.referenced_anchor.id : r.id
321
321
  idr.put(
322
- record_table.schema.name, record_table.name,
322
+ record_table.schema.name, record_table.name,
323
323
  record_id, record_column.that_link_column, record.id)
324
324
  }
325
325
  end
@@ -45,7 +45,7 @@ module FixtureFox
45
45
  constrain arg, PgGraph::Type::RecordType, String
46
46
  constrain id, NilClass, Integer # id is initially nil for anchors declared in the source
47
47
  !@anchors.key?(name) or raise Error, "Duplicate anchor: #{name.inspect}"
48
- type =
48
+ type =
49
49
  case arg
50
50
  when PgGraph::Type::RecordType; arg
51
51
  when String; @type.dot(arg) or raise Error, "Illegal path: #{path.inspect}"
@@ -38,7 +38,7 @@ private
38
38
  value = extract_value
39
39
  [key.to_sym, value]
40
40
  end
41
-
41
+
42
42
  def extract_key
43
43
  key = ""
44
44
  while @i < @s.size && @s[@i] =~ /\w/
@@ -104,7 +104,7 @@ private
104
104
  else
105
105
  litt.strip
106
106
  end
107
- value
107
+ value
108
108
  end
109
109
  end
110
110
 
@@ -9,7 +9,7 @@ module FixtureFox
9
9
  # List of materialized views that depends on the tables. Assigned by the analyzer
10
10
  # FIXME: Is this in use?
11
11
  attr_accessor :materialized_views
12
-
12
+
13
13
  # Data as a hash from schema to table to id to record to field to value.
14
14
  # Ie. { "schema" => { "table" => { 1 => { id: 1, name: "Alice" } } } }
15
15
  attr_reader :data
@@ -49,7 +49,7 @@ module FixtureFox
49
49
  def dump
50
50
  data.sort_by(&:first).each { |schema, tables|
51
51
  puts schema
52
- tables.each { |table, records|
52
+ tables.each { |table, records|
53
53
  puts " #{table}"
54
54
  records.each { |id, fields|
55
55
  puts " #{fields.inspect}"
@@ -88,11 +88,11 @@ module FixtureFox
88
88
  end
89
89
 
90
90
  class Line < TokenizedLine
91
- attr_reader :dash
91
+ attr_reader :dash
92
92
  attr_reader :ident
93
93
  attr_reader :empty # Empty token
94
- attr_reader :value
95
- attr_reader :reference
94
+ attr_reader :value
95
+ attr_reader :reference
96
96
  attr_reader :anchor
97
97
 
98
98
  attr_reader :directive # SchemaDirective token
@@ -143,7 +143,7 @@ module FixtureFox
143
143
  error "Illegal character after '-'"
144
144
  end
145
145
 
146
- # Expect key/value pair
146
+ # Expect key/value pair
147
147
  case line
148
148
  when /^(\w+)(\s*):\s*$/ # Record
149
149
  @ident = make_ident($1)
@@ -197,15 +197,15 @@ module FixtureFox
197
197
  def to_s(long: false)
198
198
  super +
199
199
  if long
200
- [ dash && "dash:#{dash.pos}",
201
- ident && "ident:#{ident.pos} #{ident.value}",
200
+ [ dash && "dash:#{dash.pos}",
201
+ ident && "ident:#{ident.pos} #{ident.value}",
202
202
  value && "value:#{value.pos} #{value.value}",
203
203
  reference && "reference:#{reference.pos} #{reference.value}",
204
204
  anchor && "anchor:##{anchor.pos} #{anchor.value}"
205
205
  ]
206
206
  else
207
- [ dash && "dash",
208
- ident && "ident: #{ident.to_s}",
207
+ [ dash && "dash",
208
+ ident && "ident: #{ident.to_s}",
209
209
  value && "value: #{value.to_s}",
210
210
  reference && "reference: #{reference.to_s}",
211
211
  anchor && "anchor: #{anchor.to_s}"
@@ -8,7 +8,7 @@ module FixtureFox
8
8
  attr_reader :anchor_files # Name of external anchor files from @anchors directive
9
9
 
10
10
  def initialize(file, lines, schema: nil)
11
- @file = file
11
+ @file = file
12
12
  @lines = lines
13
13
  @schema = schema || "public"
14
14
  @anchor_files = []
@@ -18,7 +18,7 @@ module FixtureFox
18
18
  @ast = ast || Ast.new(file)
19
19
 
20
20
  # Current schema. The schema is initialized with a synthetic Ident token
21
- # because the #analyzer needs a token to emit an error message if the
21
+ # because the #analyzer needs a token to emit an error message if the
22
22
  # public schema doesn't exist
23
23
  schema = Ident.new(file, 1, peek.initial_indent, 1, @schema)
24
24
 
@@ -86,14 +86,14 @@ module FixtureFox
86
86
  include_file = include_path.to_s
87
87
  else
88
88
  including_dir = Pathname.new(file).expand_path.dirname
89
- include_file =
89
+ include_file =
90
90
  Pathname.new(including_dir.to_s + "/" + include_path.to_s)
91
91
  .cleanpath
92
92
  .relative_path_from(Pathname.getwd).to_s
93
93
  end
94
94
  tokenizer = Tokenizer.new(include_file)
95
95
  Parser.new(tokenizer.file, tokenizer.call).call(@ast)
96
- end
96
+ end
97
97
 
98
98
  # Parse table elements. Current line should be the first element
99
99
  def parse_elements(table)
@@ -42,7 +42,7 @@ module FixtureFox
42
42
  !source.empty? or return []
43
43
  @initial_indent = source.first[/\A */].size
44
44
 
45
- while !source.empty?
45
+ while !source.empty?
46
46
  line = source.shift
47
47
  @lineno += 1
48
48
 
@@ -1,3 +1,3 @@
1
1
  module FixtureFox
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
data/lib/fixture_fox.rb CHANGED
@@ -22,7 +22,7 @@ module FixtureFox
22
22
  attr_reader :type
23
23
 
24
24
  # Name of first source file
25
- attr_reader :file
25
+ attr_reader :file
26
26
 
27
27
  # Names of all source files except included files. FIXME: Not maintained - always []
28
28
  attr_reader :files
@@ -43,8 +43,8 @@ module FixtureFox
43
43
  def idr() @idr || generate end
44
44
 
45
45
  # List of tables with records (PgGraph::Type::Table)
46
- def tables()
47
- @analyzer.data_tables
46
+ def tables()
47
+ @analyzer.data_tables
48
48
  end
49
49
 
50
50
  # Default schema. Defaults to "public"
@@ -60,12 +60,12 @@ module FixtureFox
60
60
 
61
61
  # List of anchors defined by the sources
62
62
  def defined_anchors()
63
- @analyzer.defined_anchors.values
63
+ @analyzer.defined_anchors.values
64
64
  end
65
65
 
66
66
  # List of external anchors referenced by the sources. FIXME: Unused
67
- def referenced_anchors()
68
- @analyzer.referenced_anchors.values
67
+ def referenced_anchors()
68
+ @analyzer.referenced_anchors.values
69
69
  end
70
70
 
71
71
  def parsed?() !@ast.nil? end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixture_fox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen