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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2433fd78a6dc212be0dcf5f17d9a1fe33808b751ec33c01d3b1b29c34109b7c8
4
- data.tar.gz: 30b685955ba69659665e28d7e31ca6ca1d940b9b52b47b09f16e51983603200b
3
+ metadata.gz: 7c2773ea35aa9555f6b68b5ef319621381b3f0305f1ca0df85d9e7fbd42e623c
4
+ data.tar.gz: 1c4f07d4ff42bf55e59ef731884a399cc2c7801c9aa5c101754c459729c2ccf8
5
5
  SHA512:
6
- metadata.gz: 3a0d91c8d8a9cc7a2c2f437808b996f95929aa915cde1b5c775700a0d23bb4a9cd86b9cb72eafa1f0dab67cf3478a2d3860c74b5a341b0717a818f0101e502b8
7
- data.tar.gz: 5708efd946052a012ecdcc5f3d63fa9a42ee49bed8c66b63699bb373a5710f431f6aac2a59b5f60c5074cc600818d79488036409e233e17ad4593b38f6c0f669
6
+ metadata.gz: 2dc5eb7267abb2ce4ce5bdff6b1676c39651b8e1c47006b982b14859833c241780b4577b9af0081e851c05a3e32e7967573ba19fa0cd1ca230bae4b2bfebfae4
7
+ data.tar.gz: e295be52897d817da9df062d3909d02af3feb4a8c74a2f874043cfc5af469764f4450e5ce7de48e9c527a5ef4c38c23c5cd506c8cbcf661d3a25e80e50da1424
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- liquigen (0.0.1)
4
+ liquigen (0.0.2)
5
5
  activesupport
6
6
  gli (= 2.18.0)
7
7
 
data/README.md CHANGED
@@ -18,10 +18,10 @@ liquigen help
18
18
  ## create_table
19
19
 
20
20
  ```bash
21
- liquigen create_table -t table_name prop1:type prop2:type
21
+ liquigen add_table -t table_name prop1:type prop2:type
22
22
 
23
23
  # Example
24
- liquigen create_table -t user id:integer name:string email:string created_time:datetime updated_time:datetime
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 "modify_table command ran"
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 "drop_table command ran"
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
@@ -1,13 +1,13 @@
1
1
  module Liquigen
2
2
  class ChangeSet
3
3
  attr_accessor :id
4
- attr_accessor :name
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.name = 'Jeremy'
10
+ self.author = 'Jeremy'
11
11
  self.changes = []
12
12
  end
13
13
  end
@@ -12,7 +12,7 @@ module Liquigen
12
12
  self.name = attributes[:name]
13
13
  self.type = TypeMap.new(attributes[:type]).db_type
14
14
 
15
- self.constraints = []
15
+ self.constraints = Constraint.new
16
16
  end
17
17
  end
18
18
  end
@@ -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
- line = line.gsub '!ruby/object:Liquigen::', ''
57
- line = line.rstrip + ":\n"
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
- empty_marks << index unless lines[index + 1].include?('-')
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
- constraint.primary_key = true
23
+ column.constraints.primary_key = true
25
24
  else
26
- constraint.nullable = false
25
+ column.constraints.nullable = false
27
26
  end
28
27
 
29
- column.constraints << constraint
30
28
  column
31
29
  end
32
30
  end
@@ -8,6 +8,7 @@ module Liquigen
8
8
  # http://blog.ifyouseewendy.com/blog/2015/08/10/data-types-in-rails/
9
9
  self.map = {
10
10
  integer: 'bigint',
11
+ long: 'bigint',
11
12
  string: 'varchar(255)',
12
13
  text: 'text',
13
14
  float: 'float',
@@ -1,3 +1,3 @@
1
1
  module Liquigen
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe Liquigen::Handler, type: :model do
4
- let(:handler) { Liquigen::Handler.new 'User', 'id: integer' }
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(:remove_empty, lines) }
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 15
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(:camelize_lines, lines)
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.2
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-04 00:00:00.000000000 Z
11
+ date: 2018-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport