liquigen 0.0.2 → 0.0.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -2
- data/bin/liquigen +6 -6
- data/lib/liquigen/change_set.rb +2 -2
- data/lib/liquigen/column.rb +1 -1
- data/lib/liquigen/handlers/base.rb +14 -3
- data/lib/liquigen/handlers/create_table.rb +2 -4
- data/lib/liquigen/type_map.rb +1 -0
- data/lib/liquigen/version.rb +1 -1
- data/spec/liquigen/handler_spec.rb +6 -7
- 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: 7c2773ea35aa9555f6b68b5ef319621381b3f0305f1ca0df85d9e7fbd42e623c
|
4
|
+
data.tar.gz: 1c4f07d4ff42bf55e59ef731884a399cc2c7801c9aa5c101754c459729c2ccf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dc5eb7267abb2ce4ce5bdff6b1676c39651b8e1c47006b982b14859833c241780b4577b9af0081e851c05a3e32e7967573ba19fa0cd1ca230bae4b2bfebfae4
|
7
|
+
data.tar.gz: e295be52897d817da9df062d3909d02af3feb4a8c74a2f874043cfc5af469764f4450e5ce7de48e9c527a5ef4c38c23c5cd506c8cbcf661d3a25e80e50da1424
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -18,10 +18,10 @@ liquigen help
|
|
18
18
|
## create_table
|
19
19
|
|
20
20
|
```bash
|
21
|
-
liquigen
|
21
|
+
liquigen add_table -t table_name prop1:type prop2:type
|
22
22
|
|
23
23
|
# Example
|
24
|
-
liquigen
|
24
|
+
liquigen add_table -t user id:integer name:string email:string created_time:datetime updated_time:datetime
|
25
25
|
```
|
26
26
|
The result file:
|
27
27
|
```yaml
|
@@ -49,6 +49,14 @@ databaseChangeLog:
|
|
49
49
|
|
50
50
|
```
|
51
51
|
|
52
|
+
## modify_table
|
53
|
+
|
54
|
+
ToDo.
|
55
|
+
|
56
|
+
## drop table
|
57
|
+
|
58
|
+
ToDo.
|
59
|
+
|
52
60
|
## Contributing
|
53
61
|
Bug reports and pull requests are welcome on GitHub at https://github.com/jerecui/liquigen.
|
54
62
|
|
data/bin/liquigen
CHANGED
@@ -37,20 +37,20 @@ class App
|
|
37
37
|
desc 'Describe modify_table here'
|
38
38
|
arg_name 'Describe arguments to modify_table here'
|
39
39
|
command :modify_table do |c|
|
40
|
-
c.action do |global_options,options,args|
|
41
|
-
puts
|
40
|
+
c.action do |global_options, options,args|
|
41
|
+
puts 'waiting for the implementation'
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
desc 'Describe drop_table here'
|
46
46
|
arg_name 'Describe arguments to drop_table here'
|
47
47
|
command :drop_table do |c|
|
48
|
-
c.action do |global_options,options,args|
|
49
|
-
puts
|
48
|
+
c.action do |global_options, options,args|
|
49
|
+
puts 'waiting for the implementation'
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
pre do |global,command,options,args|
|
53
|
+
pre do |global, command, options, args|
|
54
54
|
# Pre logic here
|
55
55
|
# Return true to proceed; false to abort and not call the
|
56
56
|
# chosen command
|
@@ -59,7 +59,7 @@ class App
|
|
59
59
|
true
|
60
60
|
end
|
61
61
|
|
62
|
-
post do |global,command,options,args|
|
62
|
+
post do |global, command, options, args|
|
63
63
|
# Post logic here
|
64
64
|
# Use skips_post before a command to skip this
|
65
65
|
# block on that command only
|
data/lib/liquigen/change_set.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Liquigen
|
2
2
|
class ChangeSet
|
3
3
|
attr_accessor :id
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :author
|
5
5
|
attr_accessor :changes
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
self.id = Time.new.strftime('%Y%m%d%H%M%S')
|
9
9
|
# todo Get the current git config name
|
10
|
-
self.
|
10
|
+
self.author = 'Jeremy'
|
11
11
|
self.changes = []
|
12
12
|
end
|
13
13
|
end
|
data/lib/liquigen/column.rb
CHANGED
@@ -53,8 +53,12 @@ module Liquigen::Handlers
|
|
53
53
|
lines = []
|
54
54
|
File.readlines(file_path).each do |line|
|
55
55
|
if line.include?('!ruby/object:Liquigen::')
|
56
|
-
|
57
|
-
|
56
|
+
if line.include?('-')
|
57
|
+
line = line.gsub '!ruby/object:Liquigen::', ''
|
58
|
+
else
|
59
|
+
line = line.split(':')[0]
|
60
|
+
end
|
61
|
+
line = line.rstrip + ':'
|
58
62
|
end
|
59
63
|
lines << line.rstrip
|
60
64
|
end
|
@@ -72,7 +76,14 @@ module Liquigen::Handlers
|
|
72
76
|
next if line.strip.size.zero?
|
73
77
|
next if lines[index + 1].nil?
|
74
78
|
|
75
|
-
|
79
|
+
current_blank = line.gsub(/^(\s+).*$/, '\1')
|
80
|
+
next_blank = lines[index + 1].gsub(/^(\s+).*$/, '\1')
|
81
|
+
|
82
|
+
valid = false
|
83
|
+
valid = true if lines[index + 1].include?('-')
|
84
|
+
valid = true if current_blank.size < next_blank.size
|
85
|
+
|
86
|
+
empty_marks << index unless valid
|
76
87
|
end
|
77
88
|
|
78
89
|
lines.select.with_index { |_, i| !empty_marks.include?(i) }
|
@@ -18,15 +18,13 @@ module Liquigen::Handlers
|
|
18
18
|
kv = name_and_type.split(':')
|
19
19
|
column = Liquigen::Column.new(name: kv[0], type: kv[1])
|
20
20
|
|
21
|
-
constraint = Liquigen::Constraint.new
|
22
21
|
if column.name == 'id'
|
23
22
|
column.auto_increment = true
|
24
|
-
|
23
|
+
column.constraints.primary_key = true
|
25
24
|
else
|
26
|
-
|
25
|
+
column.constraints.nullable = false
|
27
26
|
end
|
28
27
|
|
29
|
-
column.constraints << constraint
|
30
28
|
column
|
31
29
|
end
|
32
30
|
end
|
data/lib/liquigen/type_map.rb
CHANGED
data/lib/liquigen/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe Liquigen::
|
4
|
-
let(:handler) {
|
3
|
+
RSpec.describe Liquigen::Handlers::Base, type: :model do
|
4
|
+
let(:handler) { described_class.new 'User', 'id: integer' }
|
5
5
|
|
6
6
|
let(:source) {
|
7
7
|
'databaseChangeLog:
|
@@ -16,20 +16,19 @@ RSpec.describe Liquigen::Handler, type: :model do
|
|
16
16
|
name: id
|
17
17
|
type:
|
18
18
|
constraints:
|
19
|
-
- Constraint:
|
20
|
-
nullable: false
|
21
19
|
primary_key:
|
20
|
+
nullable: false
|
22
21
|
|
23
22
|
'
|
24
23
|
}
|
25
24
|
describe '#remove_empty' do
|
26
25
|
let(:lines) { source.split("\n") }
|
27
|
-
subject { handler.send(:
|
26
|
+
subject { handler.send(:remove_lines_with_empty_value, lines) }
|
28
27
|
|
29
28
|
it 'should remove the lines which contains empty value' do
|
30
29
|
ret = subject
|
31
30
|
|
32
|
-
expect(ret.size).to eq
|
31
|
+
expect(ret.size).to eq 14
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
@@ -47,7 +46,7 @@ RSpec.describe Liquigen::Handler, type: :model do
|
|
47
46
|
let(:lines) { source.split("\n") }
|
48
47
|
|
49
48
|
it 'should camelize the lines' do
|
50
|
-
ret = handler.send(:
|
49
|
+
ret = handler.send(:camelize_words, lines)
|
51
50
|
expect(ret[ret.size - 1]).to eq ' tableName: user'
|
52
51
|
end
|
53
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquigen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Cui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|