dbml 0.2.0 → 0.3.0
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 +4 -4
- data/lib/dbml.rb +12 -6
- data/lib/dbml/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d397713801bd11420626394ef9e93a83cea36401027ebc27c0d024060c3df47
|
4
|
+
data.tar.gz: e0c31278a397d67841cdf77dcb944bd19847a8e0975af6c9bf6bc7e7c120b562
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2ce41f83c7a3f37c15b49bdfd5af8cbb485fa822ede5bfb18d9b70ca2c052148dcec45a76810ed716a5126558fa7e5a0f8232c148d66751788528c172c1912b
|
7
|
+
data.tar.gz: 6145c6e8e58d6d7d6259f8cf80fc79b5c3f7e4b32c88a8c8f0048bbd4ae11f7ba2334d55adfec7a67deaf0a2f0424ef788917f8d74419849c57696eb971f8c07
|
data/lib/dbml.rb
CHANGED
@@ -50,20 +50,25 @@ module DBML
|
|
50
50
|
BOOLEAN = 'true'.r.map {|_| true } | 'false'.r.map {|_| false }
|
51
51
|
NULL = 'null'.r.map {|_| nil }
|
52
52
|
NUMBER = prim(:double)
|
53
|
-
EXPRESSION = seq('`'.r, /[^`]
|
53
|
+
EXPRESSION = seq('`'.r, /[^`]*/.r, '`'.r)[1].map {|str| Expression.new str}
|
54
54
|
# KEYWORD parses phrases: 'no action' => :"no action"
|
55
55
|
KEYWORD = /[^#{RESERVED_PUNCTUATION}\s][^#{RESERVED_PUNCTUATION}]*/.r.map {|str| str.to_sym}
|
56
|
-
SINGLE_LING_STRING = seq("'".r, /[^']
|
56
|
+
SINGLE_LING_STRING = seq("'".r, /[^']*/.r, "'".r)[1] | seq('"'.r, /[^"]*/.r, '"'.r)[1]
|
57
57
|
# MULTI_LINE_STRING ignores indentation on the first line: "''' long\n string'''" => "long\n string"
|
58
58
|
# MULTI_LINE_STRING allows apostrophes: "'''it's a string with '' bunny ears'''" => "it's a string with '' bunny ears"
|
59
|
-
MULTI_LINE_STRING
|
59
|
+
# MULTI_LINE_STRING allows blanks: "''''''" => ""
|
60
|
+
# MULTI_LINE_STRING allows blank lines to have no indent: "''' my string\n\n it's really great'''" => "my string\nit's really great"
|
61
|
+
# MULTI_LINE_STRING allows blank first lines: "'''\n start of\n my writing'''" => "start of\nmy writing"
|
62
|
+
MULTI_LINE_STRING = seq(/'''\n?/.r, /([^']|'[^']|''[^'])*/m.r, /\n?'''/.r)[1].map do |string|
|
60
63
|
indent = string.match(/^\s*/m)[0].size
|
61
64
|
string.lines.map do |line|
|
62
|
-
raise "Indentation does not match" unless line =~ /\s{#{indent}}/
|
65
|
+
raise "Indentation does not match in #{line.inspect}" unless line =~ /\s{#{indent}}/ or line =~ /^\n$/
|
63
66
|
line[indent..]
|
64
67
|
end.join
|
65
68
|
end
|
66
|
-
STRING
|
69
|
+
# STRING parses blank strings: "''" => ""
|
70
|
+
# STRING parses double quotes: '""' => ""
|
71
|
+
STRING = MULTI_LINE_STRING | SINGLE_LING_STRING
|
67
72
|
ATOM = BOOLEAN | NULL | NUMBER | EXPRESSION | STRING
|
68
73
|
|
69
74
|
# Each setting item can take in 2 forms: Key: Value or keyword, similar to that of Python function parameters.
|
@@ -282,12 +287,13 @@ module DBML
|
|
282
287
|
# RELATIONSHIP parses long form: "Ref name {\nleft.lcol < right.rcol\n}" => DBML::Relationship.new('name', 'left', ['lcol'], '<', 'right', ['rcol'], {})
|
283
288
|
# RELATIONSHIP parses short form: "Ref name: left.lcol > right.rcol" => DBML::Relationship.new('name', 'left', ['lcol'], '>', 'right', ['rcol'], {})
|
284
289
|
# RELATIONSHIP parses composite form: 'Ref: left.(a, b) - right.(c, d)' => DBML::Relationship.new(nil, 'left', ['a', 'b'], '-', 'right', ['c', 'd'], {})
|
290
|
+
# RELATIONSHIP parses lowercase r: "ref name: left.lcol > right.rcol" => DBML::Relationship.new('name', 'left', ['lcol'], '>', 'right', ['rcol'], {})
|
285
291
|
# RELATIONSHIP parses settings: "Ref: L.a > R.b [delete: cascade, update: no action]" => DBML::Relationship.new(nil, 'L', ['a'], '>', 'R', ['b'], {delete: :cascade, update: :'no action'})
|
286
292
|
COMPOSITE_COLUMNS = '('.r >> comma_separated(COLUMN_NAME) << ')'
|
287
293
|
RELATIONSHIP_TYPE = '>'.r | '<'.r | '-'.r
|
288
294
|
RELATIONSHIP_PART = seq(seq(IDENTIFIER, '.'.r)[0], (COLUMN_NAME.map {|c| [c]}) | COMPOSITE_COLUMNS)
|
289
295
|
RELATIONSHIP_BODY = seq_(RELATIONSHIP_PART, RELATIONSHIP_TYPE, RELATIONSHIP_PART, SETTINGS.maybe)
|
290
|
-
RELATIONSHIP = seq_(
|
296
|
+
RELATIONSHIP = seq_(/[Rr]ef/.r >> NAKED_IDENTIFIER.maybe, long_or_short(RELATIONSHIP_BODY)).map do |(name, (left, type, right, settings))|
|
291
297
|
Relationship.new unwrap(name), *left, type, *right, unwrap(settings) || {}
|
292
298
|
end
|
293
299
|
|
data/lib/dbml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Worthington
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rsec
|