mybatis-cli 0.0.2
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 +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/mybatis +14 -0
- data/changelog.txt +7 -0
- data/lib/mybatis.rb +28 -0
- data/lib/mybatis/builder/builder.rb +15 -0
- data/lib/mybatis/builder/mapper_builder.rb +46 -0
- data/lib/mybatis/builder/mapper_xml_builder.rb +108 -0
- data/lib/mybatis/builder/po_builder.rb +51 -0
- data/lib/mybatis/cli.rb +26 -0
- data/lib/mybatis/util/context.rb +53 -0
- data/lib/mybatis/util/folder.rb +25 -0
- data/lib/mybatis/util/generate.rb +30 -0
- data/lib/mybatis/util/string_ext.rb +43 -0
- data/lib/mybatis/version.rb +5 -0
- data/mybatis-cli.gemspec +22 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 24960118fc7c95722ff3b7404a2d7e0888f0099d
|
4
|
+
data.tar.gz: 354301c7c9a7749cacbc2fd219b2c4d099de6c02
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5453606544d01908fd9e83f503dd3b6d621b1f743f1feeb8e04a00126082c048c3fbff03d3545b9eac50b692c64fb8e95eff26bcb9f9a640ee1cede59ada7c66
|
7
|
+
data.tar.gz: d191a860f476edb94fcd6698cefa195141a248f5ba233d0e0882dc6e6b730c60afc23b752bff5d7ffddcb3968e78e87617221a56245cc9973fd983ef5a67129c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Mybatis::Cli
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'mybatis-cli'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install mybatis-cli
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/mybatis-cli/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/mybatis
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require_relative '../lib/mybatis'
|
5
|
+
|
6
|
+
begin
|
7
|
+
system "export LC_ALL=en_US.UTF-8;export LC_CTYPE=en_US.UTF-8;export LANG=en_US.UTF-8"
|
8
|
+
Mybatis::CLI.start ARGV
|
9
|
+
rescue => e
|
10
|
+
raise e if $DEBUG
|
11
|
+
STDERR.puts e.message
|
12
|
+
STDERR.puts e.backtrace.join("\n")
|
13
|
+
exit 1
|
14
|
+
end
|
data/changelog.txt
ADDED
data/lib/mybatis.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'fileutils'
|
5
|
+
require_relative './mybatis/version'
|
6
|
+
require_relative './mybatis/cli'
|
7
|
+
require_relative './mybatis/util/generate'
|
8
|
+
require_relative '../lib/mybatis/util/string_ext'
|
9
|
+
|
10
|
+
module Mybatis
|
11
|
+
class << self
|
12
|
+
include Mybatis::Generate
|
13
|
+
|
14
|
+
def launch_dir
|
15
|
+
Dir.pwd
|
16
|
+
end
|
17
|
+
|
18
|
+
def confirm_options(description)
|
19
|
+
result = ''
|
20
|
+
until result == 'y' || result == 'n'
|
21
|
+
puts description
|
22
|
+
result = $stdin.gets.sub /[\s]/,''
|
23
|
+
end
|
24
|
+
yield result == 'y' ? true : false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative 'po_builder'
|
4
|
+
require_relative 'mapper_builder'
|
5
|
+
require_relative 'mapper_xml_builder'
|
6
|
+
|
7
|
+
module Mybatis
|
8
|
+
module Builder
|
9
|
+
class << self
|
10
|
+
include Mybatis::PoBuilder
|
11
|
+
include Mybatis::MapperBuilder
|
12
|
+
include Mybatis::MapperXMLBuilder
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Mybatis
|
4
|
+
module MapperBuilder
|
5
|
+
public
|
6
|
+
def build_mapper(workspace,context)
|
7
|
+
#实体类存放目录
|
8
|
+
mapper_path = get_mapper_path workspace,context
|
9
|
+
|
10
|
+
FileUtils.makedirs mapper_path unless File.directory? mapper_path
|
11
|
+
|
12
|
+
file_path = "#{mapper_path}#{context.po_name}Mapper.java"
|
13
|
+
#实体类对应文件
|
14
|
+
file = File.new file_path ,"w"
|
15
|
+
file.puts "package #{context.package}.mapper;" if context.package
|
16
|
+
file.puts
|
17
|
+
file.puts "import #{context.join_package_and_po_name};"
|
18
|
+
file.puts
|
19
|
+
file.puts "/**"
|
20
|
+
file.puts " * Created by mybatis-cli"
|
21
|
+
file.puts " */"
|
22
|
+
file.puts "public interface #{context.po_name}Mapper {"
|
23
|
+
file.puts " void insert(#{context.po_name} #{context.po_name.downcase_first});"
|
24
|
+
file.puts
|
25
|
+
file.puts " void delete(int id);"
|
26
|
+
file.puts
|
27
|
+
file.puts " void update(#{context.po_name} #{context.po_name.downcase_first});"
|
28
|
+
file.puts
|
29
|
+
file.puts " #{context.po_name} select(int id);"
|
30
|
+
file.puts
|
31
|
+
file.puts "}"
|
32
|
+
file.close
|
33
|
+
|
34
|
+
puts "create file: #{file_path}"
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def get_mapper_path(workspace,context)
|
39
|
+
mapper_path = workspace
|
40
|
+
mapper_path << '/' unless mapper_path.end_with? '/'
|
41
|
+
mapper_path << context.package.gsub(/\./,'/') if context.package
|
42
|
+
mapper_path << '/' unless mapper_path.end_with? '/'
|
43
|
+
mapper_path << 'mapper/'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Mybatis
|
4
|
+
module MapperXMLBuilder
|
5
|
+
public
|
6
|
+
def build_mapper_xml(workspace,context)
|
7
|
+
#实体类存放目录
|
8
|
+
mapper_path = get_mapper_xml_path workspace,context
|
9
|
+
|
10
|
+
FileUtils.makedirs mapper_path unless File.directory? mapper_path
|
11
|
+
|
12
|
+
file_path = "#{mapper_path}#{context.po_name}Mapper.xml"
|
13
|
+
#实体类对应文件
|
14
|
+
file = File.new file_path ,"w"
|
15
|
+
file.puts "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
|
16
|
+
file.puts "<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\""
|
17
|
+
file.puts " \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\">"
|
18
|
+
file.puts
|
19
|
+
file.puts "<mapper namespace=\"#{self.get_class_path context}Mapper\">"
|
20
|
+
file.puts " <resultMap id=\"BaseResultMap\" type=\"#{self.get_class_path context}\" >"
|
21
|
+
context.attributes.each_with_index do |attr,index|
|
22
|
+
file.puts " <result column=\"#{attr.column_name}\" property=\"#{attr.field_name}\" />"
|
23
|
+
end
|
24
|
+
file.puts " </resultMap>"
|
25
|
+
file.puts
|
26
|
+
file.puts " <insert id=\"insert\" parameterType=\"#{self.get_class_path context} \">"
|
27
|
+
file.puts " insert into #{self.get_table_name context} ("
|
28
|
+
file.puts " #{self.get_all_column context}"
|
29
|
+
file.puts ' )'
|
30
|
+
file.puts ' values('
|
31
|
+
context.attributes.each_with_index do |attr,index|
|
32
|
+
result = self.get_mapper_column attr.field_name
|
33
|
+
if index != context.attributes.size - 1
|
34
|
+
result << ','
|
35
|
+
end
|
36
|
+
file.puts " #{result}"
|
37
|
+
end
|
38
|
+
file.puts ' )'
|
39
|
+
file.puts ' </insert>'
|
40
|
+
file.puts
|
41
|
+
file.puts ' <delete id="delete">'
|
42
|
+
file.puts " delete from #{self.get_table_name context} where id = \#{id}"
|
43
|
+
file.puts ' </delete>'
|
44
|
+
file.puts
|
45
|
+
file.puts " <update id=\"update\" parameterType=\"#{self.get_class_path context}\">"
|
46
|
+
file.puts " update #{self.get_table_name context}"
|
47
|
+
file.puts ' set'
|
48
|
+
context.attributes.each_with_index do |attr,index|
|
49
|
+
result = self.get_mapper_column attr.field_name
|
50
|
+
if index != context.attributes.size - 1
|
51
|
+
result << ','
|
52
|
+
end
|
53
|
+
file.puts " #{attr.field_name} = #{result}"
|
54
|
+
end
|
55
|
+
file.puts " where id = \#{id}"
|
56
|
+
file.puts ' </update>'
|
57
|
+
file.puts
|
58
|
+
file.puts " <select id=\"select\" resultType=\"#{self.get_class_path context}\" resultMap=\"BaseResultMap\">"
|
59
|
+
file.puts " select * from #{self.get_table_name context} where id = \#{id}"
|
60
|
+
file.puts ' </select>'
|
61
|
+
file.puts '</mapper>'
|
62
|
+
file.close
|
63
|
+
|
64
|
+
puts "create file: #{file_path}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_mapper_xml_path(workspace,context)
|
68
|
+
mapper_path = workspace
|
69
|
+
mapper_path << '/' unless mapper_path.end_with? '/'
|
70
|
+
mapper_path << context.package.gsub(/\./,'/') if context.package
|
71
|
+
mapper_path << '/' unless mapper_path.end_with? '/'
|
72
|
+
mapper_path << 'mapper/'
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_class_path(context)
|
76
|
+
return "#{context.package}.#{context.po_name}" if context.package
|
77
|
+
"#{context.po_name}"
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_table_name(context)
|
81
|
+
"t_#{context.po_name.downcase_first.replace_upcase_to_underline}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_all_column(context)
|
85
|
+
result = ''
|
86
|
+
context.attributes.each_with_index do |attr|
|
87
|
+
result << ',' unless result.end_with? ','
|
88
|
+
result << attr.column_name
|
89
|
+
end
|
90
|
+
result[1,result.size]
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_mapper_column(field_name)
|
94
|
+
result = "\#{"
|
95
|
+
result << "#{field_name}"
|
96
|
+
result << '}'
|
97
|
+
end
|
98
|
+
|
99
|
+
def get_update_values_column(context)
|
100
|
+
result = ''
|
101
|
+
context.attributes.each_with_index do |attr|
|
102
|
+
result << ',\n' if result.end_with? ',\n'
|
103
|
+
result << "#{attr.field_name} = " << '#{' << attr.field_name + '}'
|
104
|
+
end
|
105
|
+
result
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Mybatis
|
4
|
+
module PoBuilder
|
5
|
+
def build_po(workspace,context)
|
6
|
+
#实体类存放目录
|
7
|
+
entity_path = get_po_folder workspace,context
|
8
|
+
FileUtils.makedirs entity_path unless File.directory? entity_path
|
9
|
+
|
10
|
+
file_path = "#{entity_path}#{context.po_name}.java"
|
11
|
+
#实体类对应文件
|
12
|
+
file = File.new file_path ,"w"
|
13
|
+
file.puts "package #{context.package};" if context.package
|
14
|
+
file.puts
|
15
|
+
file.puts "/**"
|
16
|
+
file.puts " * Created by mybatis-cli"
|
17
|
+
file.puts " */"
|
18
|
+
file.puts "public class #{context.po_name} {"
|
19
|
+
|
20
|
+
context.attributes.each_with_index do |attr|
|
21
|
+
file.puts " private String #{attr.field_name};"
|
22
|
+
file.puts
|
23
|
+
end
|
24
|
+
|
25
|
+
context.attributes.each_with_index do |attr|
|
26
|
+
file.puts " public String get#{attr.field_name.upcase_first}() {"
|
27
|
+
file.puts " return this.#{attr.field_name};"
|
28
|
+
file.puts " }"
|
29
|
+
file.puts
|
30
|
+
end
|
31
|
+
context.attributes.each_with_index do |attr|
|
32
|
+
file.puts " public void set#{attr.field_name.upcase_first}(String #{attr.field_name}) {"
|
33
|
+
file.puts " this.#{attr.field_name} = #{attr.field_name};"
|
34
|
+
file.puts " }"
|
35
|
+
file.puts
|
36
|
+
end
|
37
|
+
file.puts "}"
|
38
|
+
file.close
|
39
|
+
|
40
|
+
puts "create file: #{file_path}"
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def get_po_folder(workspace,context)
|
45
|
+
entity_path = workspace
|
46
|
+
entity_path << '/' unless entity_path.end_with? '/'
|
47
|
+
entity_path << context.package.gsub(/\./,'/') if context.package
|
48
|
+
entity_path << '/' unless entity_path.end_with? '/'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/mybatis/cli.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Mybatis
|
4
|
+
class CLI < Thor
|
5
|
+
class_option :help, type: :boolean, aliases: "-h", desc: "Show this help message and quit"
|
6
|
+
|
7
|
+
desc "generate -p package -n name table_columns", "Build po-class,mapper-class,mapper-xml (alias: 'g')."
|
8
|
+
map ["g"] => :generate
|
9
|
+
|
10
|
+
method_option :name, type: :string, aliases: "-n", :required => true, desc: "po class name"
|
11
|
+
method_option :package, type: :string, aliases: "-p", default: "mybatis-cli" , desc: "po class package name"
|
12
|
+
method_option :tablename, type: :string, aliases: "-t", default: '' , desc: "table name"
|
13
|
+
method_option :list, type: :array, aliases: "-l", :required => true, desc: "table columns"
|
14
|
+
|
15
|
+
def generate *args
|
16
|
+
Mybatis.generate(*args, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "version", "Show Mybatis-CLI version number and quit (aliases: v)"
|
20
|
+
map ["v", "-v", "--version"] => :version
|
21
|
+
|
22
|
+
def version
|
23
|
+
say "mybatis-command-line-tool #{Mybatis::VERSION}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Mybatis
|
4
|
+
module Generate
|
5
|
+
class Attribute
|
6
|
+
attr_accessor :field_name
|
7
|
+
attr_accessor :column_name
|
8
|
+
attr_accessor :type
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def instance_with_options str
|
12
|
+
attribute = self.new
|
13
|
+
attribute.field_name = str.replace_underline_upcase_to.downcase_first
|
14
|
+
attribute.column_name = str
|
15
|
+
attribute
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class GenerateContext
|
21
|
+
attr_accessor :package
|
22
|
+
attr_accessor :po_name
|
23
|
+
attr_accessor :table_name
|
24
|
+
attr_accessor :attributes
|
25
|
+
|
26
|
+
class << self
|
27
|
+
def instance_with_options options
|
28
|
+
#{"package"=>"package", "name"=>"Order", "tablename"=>"t_order", "list"=>["id", "order_no", "create_time"]}
|
29
|
+
context = self.new
|
30
|
+
context.package = options[:package]
|
31
|
+
context.po_name = options[:name].upcase_first
|
32
|
+
context.table_name =
|
33
|
+
options[:tablename] != '' ? options[:tablename] : "t#{context.po_name.replace_upcase_to_underline}"
|
34
|
+
for str in options[:list]
|
35
|
+
attr = Mybatis::Generate::Attribute.instance_with_options str
|
36
|
+
context.attributes << attr
|
37
|
+
end
|
38
|
+
context
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def initialize
|
43
|
+
self.package = ''
|
44
|
+
self.attributes = []
|
45
|
+
end
|
46
|
+
|
47
|
+
def join_package_and_po_name
|
48
|
+
return "#{self.package}.#{self.po_name}" if self.package
|
49
|
+
"#{self.po_name}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Mybatis
|
4
|
+
module Folder
|
5
|
+
def get_source_folder
|
6
|
+
folder = "#{Mybatis.launch_dir}/src/main/java"
|
7
|
+
|
8
|
+
folder
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_resources_folder
|
12
|
+
folder = "#{Mybatis.launch_dir}/src/main/resources"
|
13
|
+
|
14
|
+
folder
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_test_source_folder
|
18
|
+
Mybatis.launch_dir << "/src/test/java/"
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_test_resources_folder
|
22
|
+
Mybatis.launch_dir << "/src/test/resources/"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative 'context'
|
4
|
+
require_relative 'folder'
|
5
|
+
require_relative '../builder/builder'
|
6
|
+
|
7
|
+
module Mybatis
|
8
|
+
module Generate
|
9
|
+
|
10
|
+
include Mybatis::Folder
|
11
|
+
include Mybatis::Builder
|
12
|
+
|
13
|
+
def generate *args, options
|
14
|
+
context = Mybatis::Generate::GenerateContext.instance_with_options options
|
15
|
+
|
16
|
+
for folder in [self.get_source_folder,self.get_resources_folder]
|
17
|
+
next if File.directory? folder
|
18
|
+
puts "Warning. not found #{folder}"
|
19
|
+
self.confirm_options 'Are you sure create folder (y/n)?' do |result|
|
20
|
+
exit 0 unless result
|
21
|
+
FileUtils.makedirs folder
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Mybatis::Builder.build_po self.get_source_folder,context
|
26
|
+
Mybatis::Builder.build_mapper self.get_source_folder,context
|
27
|
+
Mybatis::Builder.build_mapper_xml self.get_resources_folder,context
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class String
|
4
|
+
#首字母变大写
|
5
|
+
def upcase_first
|
6
|
+
str = "#{self}"
|
7
|
+
"#{str[0].upcase}#{str[1,str.size]}"
|
8
|
+
end
|
9
|
+
|
10
|
+
#首字母变小写
|
11
|
+
def downcase_first
|
12
|
+
str = "#{self}"
|
13
|
+
"#{str[0].downcase}#{str[1,str.size]}"
|
14
|
+
end
|
15
|
+
|
16
|
+
#把大写字母转换成小写字母并在前面加下划线 MybatisCli => mybatis_cli
|
17
|
+
def replace_upcase_to_underline
|
18
|
+
str = ''
|
19
|
+
self.each_char do |ch|
|
20
|
+
if /[A-Z]/ =~ ch
|
21
|
+
str << "_#{ch.downcase}"
|
22
|
+
else
|
23
|
+
str << ch
|
24
|
+
end
|
25
|
+
end
|
26
|
+
str
|
27
|
+
end
|
28
|
+
|
29
|
+
#去掉下划线并把后一个字母转换成大写 mybatis_cli => MybatisCli
|
30
|
+
def replace_underline_upcase_to
|
31
|
+
str = ''
|
32
|
+
next_to_downcase = false
|
33
|
+
self.each_char do |ch|
|
34
|
+
if next_to_downcase
|
35
|
+
str << ch.upcase
|
36
|
+
next_to_downcase = false
|
37
|
+
next;
|
38
|
+
end
|
39
|
+
str << ch unless next_to_downcase = (ch == '_')
|
40
|
+
end
|
41
|
+
str
|
42
|
+
end
|
43
|
+
end
|
data/mybatis-cli.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mybatis/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mybatis-cli"
|
8
|
+
spec.version = Mybatis::VERSION
|
9
|
+
spec.authors = ["tong"]
|
10
|
+
spec.email = ["php12345@163.com"]
|
11
|
+
spec.summary = %q{mybatis command line tool.}
|
12
|
+
spec.description = %q{mybatis command line tool..}
|
13
|
+
spec.homepage = "https://github.com/typ0520/mybatis-cli"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mybatis-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tong
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: mybatis command line tool..
|
42
|
+
email:
|
43
|
+
- php12345@163.com
|
44
|
+
executables:
|
45
|
+
- mybatis
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/mybatis
|
55
|
+
- changelog.txt
|
56
|
+
- lib/mybatis.rb
|
57
|
+
- lib/mybatis/builder/builder.rb
|
58
|
+
- lib/mybatis/builder/mapper_builder.rb
|
59
|
+
- lib/mybatis/builder/mapper_xml_builder.rb
|
60
|
+
- lib/mybatis/builder/po_builder.rb
|
61
|
+
- lib/mybatis/cli.rb
|
62
|
+
- lib/mybatis/util/context.rb
|
63
|
+
- lib/mybatis/util/folder.rb
|
64
|
+
- lib/mybatis/util/generate.rb
|
65
|
+
- lib/mybatis/util/string_ext.rb
|
66
|
+
- lib/mybatis/version.rb
|
67
|
+
- mybatis-cli.gemspec
|
68
|
+
homepage: https://github.com/typ0520/mybatis-cli
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.4.7
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: mybatis command line tool.
|
92
|
+
test_files: []
|