lhj-tools 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/command/config/info.rb +54 -23
- data/lib/lhj/command/init.rb +11 -3
- data/lib/lhj/command/view.rb +69 -53
- data/lib/lhj/command/yapi/formatters/template/yapi.erb +3 -3
- data/lib/lhj/command/yapi.rb +7 -1
- data/lib/lhj/tools/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: d53d84a79a0bde89e0f6f4299cd74bec6f34b50bb4ae9534047a1981e8ecf481
|
4
|
+
data.tar.gz: 5c11e01ef959b491a5bd03e8f737de5a68cd0b6dffba586015291717c71a1b39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60619bab6cafe45d4717c97d70fba34921dd79f2e21327bcfcdc155a76cc86a2341cef50c7506ed65980c610a2d97eb1b8d79c82641dd01faf077f581ac2d2e5
|
7
|
+
data.tar.gz: 95b1acbb95b7342da7bb4c946b7506c7572d619374f39906b0c6804e691f38e2388ed567c37b06b4c451e4aeb382d48fd13c5a90ae1fa6bcde9253104b092e94
|
@@ -3,29 +3,44 @@ require 'lhj/config'
|
|
3
3
|
|
4
4
|
module Lhj
|
5
5
|
class Command
|
6
|
+
# config
|
6
7
|
class Config < Command
|
8
|
+
def initialize(argv)
|
9
|
+
@cli = HighLine.new
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def show_config
|
14
|
+
config_arr = Dir.glob("#{config_dir}/**/*.yml")
|
15
|
+
config_arr.each_index { |i| puts "#{i}.#{File.basename(config_arr[i])}".yellow }
|
16
|
+
idx = ask_which_one
|
17
|
+
config_file = config_arr[idx]
|
18
|
+
handle_yaml(config_file)
|
19
|
+
end
|
20
|
+
|
21
|
+
def handle_yaml(file)
|
22
|
+
'子类实现'
|
23
|
+
end
|
24
|
+
|
25
|
+
def handle
|
26
|
+
show_config
|
27
|
+
end
|
28
|
+
|
29
|
+
def config_dir
|
30
|
+
Lhj::Config.instance.home_dir
|
31
|
+
end
|
32
|
+
|
33
|
+
def print_table(title, table_rows)
|
34
|
+
table = Terminal::Table.new title: title, headings: %w[键 值], rows: table_rows
|
35
|
+
puts table
|
36
|
+
end
|
37
|
+
|
7
38
|
# show config info
|
8
39
|
class Info < Config
|
9
40
|
self.summary = '查看配置信息'
|
10
41
|
|
11
|
-
def initialize(argv)
|
12
|
-
@cli = HighLine.new
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
def handle
|
17
|
-
show_config
|
18
|
-
end
|
19
|
-
|
20
|
-
def show_config
|
21
|
-
config_arr = Dir.glob("#{config_dir}/**/*.yml")
|
22
|
-
config_arr.each_index { |i| puts "#{i}.#{File.basename(config_arr[i])}".yellow }
|
23
|
-
idx = ask_which_one
|
24
|
-
config_file = config_arr[idx]
|
25
|
-
show_yaml(config_file)
|
26
|
-
end
|
27
42
|
|
28
|
-
def
|
43
|
+
def handle_yaml(file)
|
29
44
|
table_rows = []
|
30
45
|
content = YAML.load_file(file)
|
31
46
|
|
@@ -49,17 +64,33 @@ module Lhj
|
|
49
64
|
print_table(title, table_rows) if table_rows.count.positive?
|
50
65
|
end
|
51
66
|
|
52
|
-
def
|
53
|
-
|
54
|
-
puts table
|
67
|
+
def ask_which_one
|
68
|
+
@cli.ask('查看哪个配置: '.green).strip.to_i
|
55
69
|
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class Update < Config
|
56
73
|
|
57
74
|
def ask_which_one
|
58
|
-
@cli.ask('
|
75
|
+
@cli.ask('更新哪个配置: '.green).strip.to_i
|
59
76
|
end
|
60
77
|
|
61
|
-
def
|
62
|
-
|
78
|
+
def handle_yaml(file)
|
79
|
+
table_rows = []
|
80
|
+
content = YAML.load_file(file)
|
81
|
+
|
82
|
+
if content.is_a?(Hash)
|
83
|
+
content.each do |key, value|
|
84
|
+
table_rows << [key, value]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
title = File.basename(file).to_s
|
89
|
+
print_table(title, table_rows) if table_rows.count.positive?
|
90
|
+
|
91
|
+
cmd = ['open']
|
92
|
+
cmd << file
|
93
|
+
Actions.sh(cmd.join(' '))
|
63
94
|
end
|
64
95
|
end
|
65
96
|
end
|
data/lib/lhj/command/init.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'faraday'
|
2
3
|
require 'faraday_middleware'
|
3
4
|
require 'net/http'
|
@@ -23,7 +24,10 @@ module Lhj
|
|
23
24
|
|
24
25
|
def validate!
|
25
26
|
super
|
26
|
-
|
27
|
+
unless @url
|
28
|
+
path = File.join(target_folder, 'config_file.yml')
|
29
|
+
help! '配置url必须输入' unless File.exist?(path)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
def initialize(argv)
|
@@ -33,8 +37,12 @@ module Lhj
|
|
33
37
|
|
34
38
|
def handle
|
35
39
|
FileUtils.mkdir_p(target_folder) unless File.exist?(target_folder)
|
36
|
-
|
37
|
-
|
40
|
+
if @url
|
41
|
+
file_path = file_name_from_url(@url)
|
42
|
+
save_url_to_file(@url, file_path)
|
43
|
+
else
|
44
|
+
file_path = File.join(target_folder, 'config_file.yml')
|
45
|
+
end
|
38
46
|
content = YAML.load_file(file_path)
|
39
47
|
download_file(content) if content.is_a?(Array)
|
40
48
|
end
|
data/lib/lhj/command/view.rb
CHANGED
@@ -47,102 +47,118 @@ module Lhj
|
|
47
47
|
print_value
|
48
48
|
end
|
49
49
|
|
50
|
+
def puts_d(str)
|
51
|
+
puts str.blue
|
52
|
+
end
|
53
|
+
|
54
|
+
def puts_i(str)
|
55
|
+
puts str.blue
|
56
|
+
end
|
57
|
+
|
58
|
+
def puts_l(str)
|
59
|
+
puts str.blue
|
60
|
+
end
|
61
|
+
|
62
|
+
def puts_v(str)
|
63
|
+
puts str.blue
|
64
|
+
end
|
65
|
+
|
50
66
|
def print_declare
|
51
67
|
names.each do |name|
|
52
|
-
|
53
|
-
|
68
|
+
puts_d '///'
|
69
|
+
puts_d "@property (nonatomic, strong) #{type} *#{name};"
|
54
70
|
end
|
55
71
|
end
|
56
72
|
|
57
73
|
def print_instance
|
58
74
|
names.each do |name|
|
59
|
-
|
60
|
-
|
61
|
-
|
75
|
+
puts_i "-(#{type} *)#{name}"
|
76
|
+
puts_i '{'
|
77
|
+
puts_i " if(!_#{name}){"
|
62
78
|
print_alloc(name)
|
63
|
-
|
79
|
+
puts_i " _#{name}.translatesAutoresizingMaskIntoConstraints = NO;"
|
64
80
|
print_property(name)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
81
|
+
puts_i ' }'
|
82
|
+
puts_i " return _#{name};"
|
83
|
+
puts_i '}'
|
84
|
+
puts_i "\n"
|
69
85
|
end
|
70
86
|
end
|
71
87
|
|
72
88
|
def print_alloc(name)
|
73
89
|
case type
|
74
90
|
when 'UIImageView'
|
75
|
-
|
91
|
+
puts_i " _#{name} = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"xxxx\"]];"
|
76
92
|
when 'UIButton'
|
77
|
-
|
93
|
+
puts_i " _#{name} = [UIButton buttonWithType:UIButtonTypeCustom];"
|
78
94
|
when 'UITableView'
|
79
|
-
|
95
|
+
puts_i " _#{name} = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];"
|
80
96
|
else
|
81
|
-
|
97
|
+
puts_i " _#{name} = [[#{type} alloc] init];"
|
82
98
|
end
|
83
99
|
end
|
84
100
|
|
85
101
|
def print_property(name)
|
86
102
|
case type
|
87
103
|
when 'UILabel'
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
104
|
+
puts_i " _#{name}.textColor = kSetCOLOR(0x333333);"
|
105
|
+
puts_i " _#{name}.text = @\"xxxxxxxx\";"
|
106
|
+
puts_i " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
|
107
|
+
puts_i " _#{name}.textAlignment = NSTextAlignmentCenter;"
|
92
108
|
when 'UIImageView'
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
109
|
+
puts_i " _#{name}.backgroundColor = kBackgroundColor;"
|
110
|
+
puts_i " _#{name}.contentMode = UIViewContentModeScaleAspectFit;"
|
111
|
+
puts_i " _#{name}.clipsToBounds = YES;"
|
112
|
+
puts_i " _#{name}.layer.cornerRadius = 6.0f;"
|
113
|
+
puts_i " _#{name}.layer.borderColor = kLineColor.CGColor;"
|
114
|
+
puts_i " _#{name}.layer.borderWidth = 0.5;"
|
99
115
|
when 'UITextField'
|
100
|
-
|
101
|
-
|
116
|
+
puts_i " _#{name}.textColor = kSetCOLOR(0x333333);"
|
117
|
+
puts_i " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
|
102
118
|
when 'UIView'
|
103
|
-
|
119
|
+
puts_i " _#{name}.backgroundColor = kBackgroundColor;"
|
104
120
|
when 'UIStackView'
|
105
|
-
|
106
|
-
|
121
|
+
puts_i " _#{name}.axis = UILayoutConstraintAxisHorizontal;"
|
122
|
+
puts_i " _#{name}.distribution = UIStackViewDistributionFillEqually;"
|
107
123
|
when 'UITableView'
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
124
|
+
puts_i " _#{name}.backgroundColor = kBackgroundColor;"
|
125
|
+
puts_i " _#{name}.delegate = self;"
|
126
|
+
puts_i " _#{name}.delegate = self;"
|
127
|
+
puts_i " _#{name}.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
|
128
|
+
puts_i " _#{name}.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
|
129
|
+
puts_i " _#{name}.separatorStyle = UITableViewCellSeparatorStyleNone;"
|
114
130
|
when 'UIButton'
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
131
|
+
puts_i " _#{name}.backgroundColor = kBackgroundColor;"
|
132
|
+
puts_i " [_#{name} setTitle:@\"xxx\" forState:UIControlStateNormal];"
|
133
|
+
puts_i " [_#{name} setTitleColor:kSetCOLOR(0x999999) forState:UIControlStateNormal];"
|
134
|
+
puts_i " _#{name}.titleLabel.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightRegular];"
|
135
|
+
puts_i " [_#{name} setImage:[UIImage imageNamed:@\"xx\"] forState:UIControlStateNormal];"
|
136
|
+
puts_i " [_#{name} setImage:[UIImage imageNamed:@\"xx\"] forState:UIControlStateSelected];"
|
137
|
+
puts_i " [_#{name} addTarget:self action:@selector(actionHandler:) forControlEvents:UIControlEventTouchUpInside];"
|
122
138
|
end
|
123
139
|
end
|
124
140
|
|
125
141
|
def print_layout
|
126
142
|
names.each do |name|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
143
|
+
puts_l "[contentView addSubview:self.#{name}];"
|
144
|
+
puts_l "[self.#{name}.leadingAnchor constraintEqualToAnchor:contentView.leadingAnchor constant:0].active = YES;"
|
145
|
+
puts_l "[self.#{name}.trailingAnchor constraintEqualToAnchor:contentView.trailingAnchor constant:0].active = YES;"
|
146
|
+
puts_l "[self.#{name}.topAnchor constraintEqualToAnchor:contentView.topAnchor].active = YES;"
|
147
|
+
puts_l "[self.#{name}.bottomAnchor constraintEqualToAnchor:contentView.bottomAnchor].active = YES;"
|
148
|
+
puts_l "[self.#{name}.widthAnchor constraintEqualToConstant:80].active = YES;"
|
149
|
+
puts_l "[self.#{name}.heightAnchor constraintEqualToConstant:80].active = YES;"
|
134
150
|
if type.eql?('UILabel')
|
135
|
-
|
136
|
-
|
151
|
+
puts_l "[self.#{name} setContentHuggingPriority:300 forAxis:UILayoutConstraintAxisHorizontal];"
|
152
|
+
puts_l "[self.#{name} setContentCompressionResistancePriority:300 forAxis:UILayoutConstraintAxisHorizontal];"
|
137
153
|
end
|
138
|
-
|
154
|
+
puts_l "\n\n"
|
139
155
|
end
|
140
156
|
end
|
141
157
|
|
142
158
|
def print_value
|
143
159
|
names.each do |name|
|
144
160
|
if type.eql?('UILabel')
|
145
|
-
|
161
|
+
puts_v "self.#{name}.text = @\"xxxxx\";"
|
146
162
|
end
|
147
163
|
end
|
148
164
|
end
|
@@ -5,21 +5,21 @@
|
|
5
5
|
static NSString * const <%= @path_key %> = @"<%= @path %>";
|
6
6
|
|
7
7
|
<% if @method == 'GET' -%>
|
8
|
-
+(void)get<%= @path_name %>:(<%= @param_model_name %> *)param callback:(void (^)(
|
8
|
+
+(void)get<%= @path_name %>:(<%= @param_model_name %> *)param callback:(void (^)(<% unless @result_model_name.empty? -%><%= @result_model_name %> *model, <% end -%>MLResponseMessage *response))callback
|
9
9
|
{
|
10
10
|
[MLNetworkingManager getWithUrl:<%= @path_key %> params:params response:^(MLResponseMessage *responseMessage) {
|
11
11
|
<%= @model_template %>
|
12
12
|
}];
|
13
13
|
}
|
14
14
|
<% elsif @method == 'JSON' -%>
|
15
|
-
+(void)postJson<%= @path_name %>:(<%= @param_model_name %> *)param callback:(void (^)(
|
15
|
+
+(void)postJson<%= @path_name %>:(<%= @param_model_name %> *)param callback:(void (^)(<% unless @result_model_name.empty? -%><%= @result_model_name %> *model, <% end -%>MLResponseMessage *response))callback
|
16
16
|
{
|
17
17
|
[MLNetworkingManager requestJsonWithUrl:<%= @path_key %> httpMedth:kRequestMethodPOST params:param response:^(MLResponseMessage *responseMessage) {
|
18
18
|
<%= @model_template %>
|
19
19
|
}];
|
20
20
|
}
|
21
21
|
<% else -%>
|
22
|
-
+(void)
|
22
|
+
+(void)post<%= @path_name %>:(<%= @param_model_name %> *)param callback:(void (^)(<% unless @result_model_name.empty? -%><%= @result_model_name %> *model, <% end -%>MLResponseMessage *response))callback
|
23
23
|
{
|
24
24
|
[MLNetworkingManager postWithUrl:<%= @path_key %> params:params response:^(MLResponseMessage *response) {
|
25
25
|
<%= @model_template %>
|
data/lib/lhj/command/yapi.rb
CHANGED
@@ -59,7 +59,11 @@ module Lhj
|
|
59
59
|
def process(config_file)
|
60
60
|
load_config(config_file)
|
61
61
|
res_body = req_api_model
|
62
|
-
|
62
|
+
unless res_body['errcode'].to_i.zero?
|
63
|
+
puts '请修改 ~/.lhj/yapi.yml文件的对应的__wpkreporterwid_,_yapi_token,_yapi_uid这三个值'.red
|
64
|
+
return
|
65
|
+
end
|
66
|
+
return unless res_body && !res_body.empty?
|
63
67
|
|
64
68
|
# 1.print request result
|
65
69
|
print_res_body_model(res_body)
|
@@ -322,6 +326,8 @@ module Lhj
|
|
322
326
|
end
|
323
327
|
puts_h '@end'
|
324
328
|
puts "\n\n"
|
329
|
+
|
330
|
+
@param_model_name = 'MLParamModel' if @param_model_name.empty?
|
325
331
|
end
|
326
332
|
|
327
333
|
def print_http_method(data)
|
data/lib/lhj/tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhj-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|