bigkeeper 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE.md +20 -0
- data/.gitignore +50 -0
- data/.travis.yml +17 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/CONTRIBUTING.md +70 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +114 -0
- data/LICENSE +21 -0
- data/README.md +109 -0
- data/Rakefile +2 -0
- data/big_keeper.gemspec +47 -0
- data/bin/big +14 -0
- data/bin/setup +8 -0
- data/docs/en-US/FEATURE.md +0 -0
- data/docs/en-US/README.md +50 -0
- data/docs/zh-CN/BIGKEEPER_FILE.md +62 -0
- data/docs/zh-CN/FEATURE&HOTFIX.md +121 -0
- data/docs/zh-CN/PODFILE.md +43 -0
- data/docs/zh-CN/README.md +107 -0
- data/docs/zh-CN/RECOMMEND.md +22 -0
- data/docs/zh-CN/RELEASE.md +43 -0
- data/lib/big_keeper.rb +295 -0
- data/lib/big_keeper/command/feature&hotfix/delete.rb +33 -0
- data/lib/big_keeper/command/feature&hotfix/finish.rb +56 -0
- data/lib/big_keeper/command/feature&hotfix/pull.rb +24 -0
- data/lib/big_keeper/command/feature&hotfix/push.rb +25 -0
- data/lib/big_keeper/command/feature&hotfix/rebase.rb +27 -0
- data/lib/big_keeper/command/feature&hotfix/start.rb +67 -0
- data/lib/big_keeper/command/feature&hotfix/switch.rb +47 -0
- data/lib/big_keeper/command/feature&hotfix/update.rb +69 -0
- data/lib/big_keeper/command/pod/podfile.rb +69 -0
- data/lib/big_keeper/command/release/home.rb +66 -0
- data/lib/big_keeper/command/release/module.rb +106 -0
- data/lib/big_keeper/model/gitflow_type.rb +31 -0
- data/lib/big_keeper/model/operate_type.rb +19 -0
- data/lib/big_keeper/model/podfile_model.rb +33 -0
- data/lib/big_keeper/model/podfile_type.rb +44 -0
- data/lib/big_keeper/service/git_service.rb +186 -0
- data/lib/big_keeper/service/module_service.rb +124 -0
- data/lib/big_keeper/service/stash_service.rb +45 -0
- data/lib/big_keeper/util/bigkeeper_parser.rb +198 -0
- data/lib/big_keeper/util/git_operator.rb +142 -0
- data/lib/big_keeper/util/gitflow_operator.rb +51 -0
- data/lib/big_keeper/util/info_plist_operator.rb +46 -0
- data/lib/big_keeper/util/logger.rb +40 -0
- data/lib/big_keeper/util/pod_operator.rb +15 -0
- data/lib/big_keeper/util/podfile_detector.rb +108 -0
- data/lib/big_keeper/util/podfile_module.rb +64 -0
- data/lib/big_keeper/util/podfile_operator.rb +166 -0
- data/lib/big_keeper/util/xcode_operator.rb +13 -0
- data/lib/big_keeper/version.rb +3 -0
- data/resources/banner.png +0 -0
- data/resources/keynote/big-keeper-readme-example.key +0 -0
- data/resources/keynote/big-keeper-readme-feature.key +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.001.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.002.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.003.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.004.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.005.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.006.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.007.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.008.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.009.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.010.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.011.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.012.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.013.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-feature/big-keeper-readme-feature.014.jpeg +0 -0
- data/resources/keynote/big-keeper-readme-release.key +0 -0
- data/resources/readme/big-keeper-readme.001.png +0 -0
- data/resources/readme/big-keeper-readme.002.png +0 -0
- data/resources/readme/big-keeper-readme.003.png +0 -0
- data/resources/readme/big-keeper-readme.004.png +0 -0
- data/resources/readme/big-keeper-readme.005.png +0 -0
- data/resources/readme/big-keeper-readme.006.png +0 -0
- data/resources/readme/big-keeper-readme.007.png +0 -0
- data/resources/readme/big-keeper-readme.008.png +0 -0
- data/resources/readme/big-keeper-readme.009.png +0 -0
- data/resources/readme/big-keeper-readme.010.png +0 -0
- data/resources/readme/big-keeper-readme.011.png +0 -0
- data/resources/readme/big-keeper-readme.012.png +0 -0
- metadata +311 -0
@@ -0,0 +1,198 @@
|
|
1
|
+
require 'big_keeper/util/logger'
|
2
|
+
|
3
|
+
# Bigkeeper module
|
4
|
+
module BigKeeper
|
5
|
+
def self.version(name)
|
6
|
+
BigkeeperParser.parse_version(name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.user(name)
|
10
|
+
BigkeeperParser.parse_user(name)
|
11
|
+
yield if block_given?
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.home(name, params)
|
15
|
+
BigkeeperParser.parse_home(name, params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.pod(name, params)
|
19
|
+
BigkeeperParser.parse_pod(name, params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.modules
|
23
|
+
BigkeeperParser.parse_modules
|
24
|
+
yield if block_given?
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.source(name)
|
28
|
+
BigkeeperParser.parse_source(name)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Bigkeeper file parser
|
32
|
+
class BigkeeperParser
|
33
|
+
@@config = {}
|
34
|
+
@@current_user = ''
|
35
|
+
|
36
|
+
def self.parse(bigkeeper)
|
37
|
+
if @@config.empty?
|
38
|
+
|
39
|
+
Logger.error("Can't find a Bigkeeper file in current directory.") if !BigkeeperParser.definitely_exists?(bigkeeper)
|
40
|
+
|
41
|
+
content = File.read bigkeeper
|
42
|
+
content.gsub!(/version\s/, 'BigKeeper::version ')
|
43
|
+
content.gsub!(/user\s/, 'BigKeeper::user ')
|
44
|
+
content.gsub!(/home\s/, 'BigKeeper::home ')
|
45
|
+
content.gsub!(/pod\s/, 'BigKeeper::pod ')
|
46
|
+
content.gsub!(/modules\s/, 'BigKeeper::modules ')
|
47
|
+
content.gsub!(/source\s/, 'BigKeeper::source ')
|
48
|
+
eval content
|
49
|
+
# p @@config
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.definitely_exists? path
|
54
|
+
folder = File.dirname path
|
55
|
+
filename = File.basename path
|
56
|
+
# Unlike Ruby IO, ls, and find -f, this technique will fail to locate the file if the case is wrong:
|
57
|
+
not %x( find "#{folder}" -name "#{filename}" ).empty?
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.parse_version(name)
|
61
|
+
@@config[:version] = name
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.parse_source(name)
|
65
|
+
sources = []
|
66
|
+
sources << @@config[:source]
|
67
|
+
sources << name
|
68
|
+
@@config[:source] = sources
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.parse_user(name)
|
72
|
+
@@current_user = name
|
73
|
+
users = @@config[:users]
|
74
|
+
users = {} if users.nil?
|
75
|
+
users[name] = {}
|
76
|
+
@@config[:users] = users
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.parse_home(name, params)
|
80
|
+
@@config[:home] = params
|
81
|
+
@@config[:name] = name
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.parse_pod(name, params)
|
85
|
+
if params[:path]
|
86
|
+
parse_user_pod(name, params)
|
87
|
+
elsif params[:git]
|
88
|
+
parse_modules_pod(name, params)
|
89
|
+
else
|
90
|
+
Logger.error(%(There should be ':path =>' or ':git =>' for pod #{name}))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.parse_user_pod(name, params)
|
95
|
+
users = @@config[:users]
|
96
|
+
user = users[@@current_user]
|
97
|
+
pods = user[:pods]
|
98
|
+
pods = {} if pods.nil?
|
99
|
+
pods[name] = params
|
100
|
+
user[:pods] = pods
|
101
|
+
@@config[:users] = users
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.parse_modules_pod(name, params)
|
105
|
+
modules = @@config[:modules]
|
106
|
+
modules[name] = params
|
107
|
+
@@config[:modules] = modules
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.parse_modules
|
111
|
+
modules = @@config[:modules]
|
112
|
+
modules = {} if modules.nil?
|
113
|
+
@@config[:modules] = modules
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.version
|
117
|
+
@@config[:version]
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.home_name
|
121
|
+
@@config[:name]
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.home_git()
|
125
|
+
@@config[:home][:git]
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.home_pulls()
|
129
|
+
@@config[:home][:pulls]
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.sourcemodule_path
|
133
|
+
if @@config[:source] == nil
|
134
|
+
return ""
|
135
|
+
else
|
136
|
+
@@config[:source].join(",").reverse.chop.reverse
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.module_full_path(home_path, user_name, module_name)
|
141
|
+
if @@config[:users] \
|
142
|
+
&& @@config[:users][user_name] \
|
143
|
+
&& @@config[:users][user_name][:pods] \
|
144
|
+
&& @@config[:users][user_name][:pods][module_name] \
|
145
|
+
&& @@config[:users][user_name][:pods][module_name][:path]
|
146
|
+
@@config[:users][user_name][:pods][module_name][:path]
|
147
|
+
else
|
148
|
+
File.expand_path("#{home_path}/../#{module_name}")
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.module_path(user_name, module_name)
|
153
|
+
if @@config[:users] \
|
154
|
+
&& @@config[:users][user_name] \
|
155
|
+
&& @@config[:users][user_name][:pods] \
|
156
|
+
&& @@config[:users][user_name][:pods][module_name] \
|
157
|
+
&& @@config[:users][user_name][:pods][module_name][:path]
|
158
|
+
@@config[:users][user_name][:pods][module_name][:path]
|
159
|
+
else
|
160
|
+
"../#{module_name}"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.module_git(module_name)
|
165
|
+
@@config[:modules][module_name][:git]
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.module_pulls(module_name)
|
169
|
+
@@config[:modules][module_name][:pulls]
|
170
|
+
end
|
171
|
+
|
172
|
+
def self.verify_modules(modules)
|
173
|
+
modules.each do |item|
|
174
|
+
Logger.error("Can not find module #{item} in Bigkeeper file") unless @@config[:modules][item]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def self.module_names
|
179
|
+
@@config[:modules].keys
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.config
|
183
|
+
@@config
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# BigkeeperParser.parse('/Users/mmoaay/Documents/eleme/BigKeeperMain/Bigkeeper')
|
188
|
+
# BigkeeperParser.parse('/Users/mmoaay/Documents/eleme/BigKeeperMain/Bigkeeper')
|
189
|
+
#
|
190
|
+
# p BigkeeperParser.home_git()
|
191
|
+
# p BigkeeperParser.home_pulls()
|
192
|
+
# p BigkeeperParser.module_path('perry', 'BigKeeperModular')
|
193
|
+
# p BigkeeperParser.module_path('', 'BigKeeperModular')
|
194
|
+
# p BigkeeperParser.module_git('BigKeeperModular')
|
195
|
+
# pulls = BigkeeperParser.module_pulls('BigKeeperModular')
|
196
|
+
# `open #{pulls}`
|
197
|
+
# p BigkeeperParser.module_names
|
198
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
require 'big_keeper/util/logger'
|
2
|
+
|
3
|
+
module BigKeeper
|
4
|
+
# Operator for got
|
5
|
+
class GitOperator
|
6
|
+
def current_branch(path)
|
7
|
+
Dir.chdir(path) do
|
8
|
+
`git rev-parse --abbrev-ref HEAD`.chop
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def has_remote_branch(path, branch_name)
|
13
|
+
has_branch = false
|
14
|
+
IO.popen("cd #{path}; git branch -r") do |io|
|
15
|
+
io.each do |line|
|
16
|
+
has_branch = true if line.include? branch_name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
has_branch
|
20
|
+
end
|
21
|
+
|
22
|
+
def has_local_branch(path, branch_name)
|
23
|
+
has_branch = false
|
24
|
+
IO.popen("cd #{path}; git branch") do |io|
|
25
|
+
io.each do |line|
|
26
|
+
has_branch = true if line.include? branch_name
|
27
|
+
end
|
28
|
+
end
|
29
|
+
has_branch
|
30
|
+
end
|
31
|
+
|
32
|
+
def has_branch(path, branch_name)
|
33
|
+
has_branch = false
|
34
|
+
IO.popen("cd #{path}; git branch -a") do |io|
|
35
|
+
io.each do |line|
|
36
|
+
has_branch = true if line.include? branch_name
|
37
|
+
end
|
38
|
+
end
|
39
|
+
has_branch
|
40
|
+
end
|
41
|
+
|
42
|
+
def checkout(path, branch_name)
|
43
|
+
Dir.chdir(path) do
|
44
|
+
IO.popen("git checkout #{branch_name}") do |io|
|
45
|
+
io.each do |line|
|
46
|
+
Logger.error("Checkout #{branch_name} failed.") if line.include? 'error'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def fetch(path)
|
53
|
+
Dir.chdir(path) do
|
54
|
+
`git fetch origin`
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def rebase(path, branch_name)
|
59
|
+
Dir.chdir(path) do
|
60
|
+
`git rebase origin/#{branch_name}`
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def clone(path, git_base)
|
65
|
+
Dir.chdir(path) do
|
66
|
+
`git clone #{git_base}`
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def commit(path, message)
|
71
|
+
Dir.chdir(path) do
|
72
|
+
`git add .`
|
73
|
+
`git commit -m "#{message}"`
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def push_to_remote(path, branch_name)
|
78
|
+
Dir.chdir(path) do
|
79
|
+
`git push -u origin #{branch_name}`
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def pull(path)
|
84
|
+
Dir.chdir(path) do
|
85
|
+
`git pull`
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def has_commits(path, branch_name)
|
90
|
+
has_commits = false
|
91
|
+
IO.popen("cd #{path}; git log --branches --not --remotes") do |io|
|
92
|
+
io.each do |line|
|
93
|
+
has_commits = true if line.include? branch_name
|
94
|
+
end
|
95
|
+
end
|
96
|
+
has_commits
|
97
|
+
end
|
98
|
+
|
99
|
+
def has_changes(path)
|
100
|
+
has_changes = true
|
101
|
+
clear_flag = 'nothing to commit, working tree clean'
|
102
|
+
IO.popen("cd #{path}; git status") do |io|
|
103
|
+
io.each do |line|
|
104
|
+
has_changes = false if line.include? clear_flag
|
105
|
+
end
|
106
|
+
end
|
107
|
+
has_changes
|
108
|
+
end
|
109
|
+
|
110
|
+
def dicard(path)
|
111
|
+
Dir.chdir(path) do
|
112
|
+
`git checkout . && git clean -xdf`
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def del_local(path, branch_name)
|
117
|
+
Dir.chdir(path) do
|
118
|
+
`git branch -D #{branch_name}`
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def del_remote(path, branch_name)
|
123
|
+
Dir.chdir(path) do
|
124
|
+
`git push origin --delete #{branch_name}`
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def user
|
129
|
+
`git config user.name`.chop
|
130
|
+
end
|
131
|
+
|
132
|
+
def tag(path, version)
|
133
|
+
Dir.chdir(path) do
|
134
|
+
`git tag -a #{version} -m "release: V #{version}" master`
|
135
|
+
`git push --tags`
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# p GitOperator.new.user
|
141
|
+
# BigStash::StashOperator.new("/Users/mmoaay/Documents/eleme/BigKeeperMain").list
|
142
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'big_keeper/model/gitflow_type'
|
2
|
+
|
3
|
+
module BigKeeper
|
4
|
+
# Operator for gitflow
|
5
|
+
class GitflowOperator
|
6
|
+
def start(path, name, type)
|
7
|
+
Dir.chdir(path) do
|
8
|
+
gitflow_type_name = GitflowType.name(type)
|
9
|
+
`git flow #{gitflow_type_name} start #{name}`
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def verify_git_flow_command
|
14
|
+
has_git_flow_command = false
|
15
|
+
IO.popen('command -v git-flow') do |io|
|
16
|
+
io.each do |line|
|
17
|
+
has_git_flow_command = true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
has_git_flow_command
|
21
|
+
end
|
22
|
+
|
23
|
+
def verify_git_flow(path)
|
24
|
+
has_git_flow = false
|
25
|
+
Dir.chdir(path) do
|
26
|
+
clear_flag = 'Already initialized for gitflow'
|
27
|
+
IO.popen('git flow init -d') do |io|
|
28
|
+
io.each do |line|
|
29
|
+
if line.include? clear_flag
|
30
|
+
has_git_flow = true
|
31
|
+
break
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
has_git_flow
|
37
|
+
end
|
38
|
+
|
39
|
+
def finish_release(path, release_name)
|
40
|
+
Dir.chdir(path) do
|
41
|
+
p `git checkout master`
|
42
|
+
p `git merge release/#{release_name}`
|
43
|
+
p `git push`
|
44
|
+
p `git checkout develop`
|
45
|
+
p `git merge release/#{release_name}`
|
46
|
+
p `git push`
|
47
|
+
p `git branch -d release/#{release_name}`
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'plist' # gem install plist
|
3
|
+
require 'big_stash/stash_operator'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
module BigKeeper
|
7
|
+
# Operator for Info.plist
|
8
|
+
class InfoPlistOperator
|
9
|
+
def change_version_build(path, version)
|
10
|
+
if find_infoPlist_filePath(path) == ''
|
11
|
+
raise %(Not find be Info.plist at #{path})
|
12
|
+
end
|
13
|
+
info_plist_path = find_infoPlist_filePath(path)
|
14
|
+
result = Plist.parse_xml(info_plist_path)
|
15
|
+
result['CFBundleVersion'] = getBuildVersion(version, result['CFBundleShortVersionString'], result['CFBundleVersion']).to_s
|
16
|
+
result['CFBundleShortVersionString'] = version.to_s
|
17
|
+
Plist::Emit.save_plist(result, info_plist_path)
|
18
|
+
puts %Q('Version has changed to #{version}')
|
19
|
+
end
|
20
|
+
|
21
|
+
# Find Info.plist file path
|
22
|
+
# @return [String] pathName of info.plist
|
23
|
+
def find_infoPlist_filePath(path)
|
24
|
+
paths = Pathname.new(path).children.select { |pn| pn.extname == '.xcodeproj' }
|
25
|
+
xcodePath = paths[0].to_s.split('/')[-1]
|
26
|
+
projectName = xcodePath.split('.')[0]
|
27
|
+
projectPath = ''
|
28
|
+
Pathname.new("#{path}/#{projectName}").children.select { |pn|
|
29
|
+
if pn.to_s == "#{path}/#{projectName}/Info.plist"
|
30
|
+
projectPath = "#{path}/#{projectName}/Info.plist"
|
31
|
+
end
|
32
|
+
}
|
33
|
+
projectPath
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def getBuildVersion(build_string, old_build_string, old_build_version)
|
38
|
+
if build_string == old_build_string
|
39
|
+
return old_build_version.to_i + 1
|
40
|
+
else
|
41
|
+
version_arr = build_string.split('.')
|
42
|
+
return version_arr[0].to_i * 1000 + version_arr[1].to_i * 100 + version_arr[2].to_i * 10
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
module BigKeeper
|
4
|
+
DEFAULT_LOG = 1
|
5
|
+
HIGHLIGHT_LOG = 2
|
6
|
+
ERROR_LOG = 3
|
7
|
+
WARNING_LOG = 4
|
8
|
+
|
9
|
+
class Logger
|
10
|
+
|
11
|
+
def self.log_with_type(sentence,type)
|
12
|
+
case type
|
13
|
+
when DEFAULT_LOG then puts sentence.to_s.colorize(:default)
|
14
|
+
when HIGHLIGHT_LOG then puts sentence.to_s.colorize(:green)
|
15
|
+
when ERROR_LOG then raise sentence.to_s.colorize(:red)
|
16
|
+
when WARNING_LOG then puts sentence.to_s.colorize(:yellow)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.default(sentence)
|
21
|
+
puts sentence.to_s.colorize(:default)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.highlight(sentence)
|
25
|
+
puts sentence.to_s.colorize(:green)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.error(sentence)
|
29
|
+
raise sentence.to_s.colorize(:red)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.warning(sentence)
|
33
|
+
puts sentence.to_s.colorize(:yellow)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.separator
|
37
|
+
puts "- - - - - - - - - - - - - - - - - - - - - - - - - - -".colorize(:light_blue)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|