tes-request 0.7 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +2 -2
- data/lib/tes/request/client.rb +14 -14
- data/lib/tes/request/version.rb +1 -1
- data/tes-request.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dd957de5812e55a337c9b095dffa7ad80a64a98
|
4
|
+
data.tar.gz: 8ac21c83d116729acb7999adc568a4abbcd09a84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 737463005aaaf4908a45fdbce18a78e0720013264e4f8a5d6bb59ddf9fc0598ff9daa4a53cef5a9d79c2a3b1a52e3900656446d34f477d18776f8b5569019196
|
7
|
+
data.tar.gz: 7ff8fe4b8e42967fd1eec73dd4b1e677c5f68179abc6ec555cfd976edc75002a9741ed885fbf6a598b1d73bfd287e1f072389040f94ed8c20c636470679b6145
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -35,7 +35,7 @@ This code of conduct applies both within project spaces and in public spaces
|
|
35
35
|
when an individual is representing the project or its community.
|
36
36
|
|
37
37
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
-
reported by contacting a project maintainer at
|
38
|
+
reported by contacting a project maintainer at wuhuizuo@126.com. All
|
39
39
|
complaints will be reviewed and investigated and will result in a response that
|
40
40
|
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
41
|
obligated to maintain confidentiality with regard to the reporter of an
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Tes::Request
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/
|
3
|
+
[![Build Status](https://travis-ci.org/NightProgrammers/tes-request.svg)](https://travis-ci.org/NightProgrammers/tes-request)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/tes-request.svg)](https://rubygems.org/gems/tes-request)
|
5
5
|
|
6
6
|
TES(Test Env Service) request profile struct, manager lib and request tools
|
@@ -86,7 +86,7 @@ $ tes-client
|
|
86
86
|
|
87
87
|
## Contributing
|
88
88
|
|
89
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
89
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/NightProgrammers/tes-request.
|
90
90
|
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
91
91
|
|
92
92
|
## License
|
data/lib/tes/request/client.rb
CHANGED
@@ -24,7 +24,7 @@ module Tes
|
|
24
24
|
# @param [Array<String>] asks
|
25
25
|
# @return [Hash]
|
26
26
|
def request_env(user, asks)
|
27
|
-
res = @driver.post('
|
27
|
+
res = @driver.post('env', body: {user: user, ask: asks.join("\n")}.to_json)
|
28
28
|
ret = parse_res res
|
29
29
|
|
30
30
|
if ret.is_a?(Hash) and
|
@@ -32,7 +32,7 @@ module Tes
|
|
32
32
|
ret[:data].is_a?(Hash) and
|
33
33
|
ret[:data][:res].is_a?(Hash)
|
34
34
|
res_hash = ret[:data][:res]
|
35
|
-
res_hash.keys.each {
|
35
|
+
res_hash.keys.each {|k| res_hash[k.to_s] = res_hash.delete(k)}
|
36
36
|
ret[:data][:res] = res_hash
|
37
37
|
end
|
38
38
|
|
@@ -42,19 +42,19 @@ module Tes
|
|
42
42
|
# @param [String] id resource id
|
43
43
|
# @param [String] user lock/using username
|
44
44
|
# @param [1,0] lock need lock? `false` == shared using
|
45
|
-
def request_res(id, user, lock=1)
|
46
|
-
res = @driver.post("
|
45
|
+
def request_res(id, user, lock = 1)
|
46
|
+
res = @driver.post("res/#{id}/lock", body: {user: user, lock: lock})
|
47
47
|
parse_res res
|
48
48
|
end
|
49
49
|
|
50
50
|
def release_res(id, user)
|
51
|
-
res = @driver.post("
|
51
|
+
res = @driver.post("res/#{id}/release", body: {user: user})
|
52
52
|
parse_res res
|
53
53
|
end
|
54
54
|
|
55
55
|
def release_all_res(user)
|
56
|
-
res_list = parse_res @driver.get('
|
57
|
-
res_list[:data].select {
|
56
|
+
res_list = parse_res @driver.get('res')
|
57
|
+
res_list[:data].select {|_k, c| c[:users] && c[:users].include?(user)}.each do |id, _c|
|
58
58
|
release_res(id, user)
|
59
59
|
end
|
60
60
|
end
|
@@ -66,7 +66,7 @@ module Tes
|
|
66
66
|
raise(fail_msg)
|
67
67
|
else
|
68
68
|
res_body = res.body
|
69
|
-
if res.http_header['Content-Type'].any? {
|
69
|
+
if res.http_header['Content-Type'].any? {|h| h =~ /application\/json/i}
|
70
70
|
res_body = JSON.parse(res_body, :symbolize_names => true) rescue res_body
|
71
71
|
end
|
72
72
|
res_body
|
@@ -75,7 +75,7 @@ module Tes
|
|
75
75
|
end
|
76
76
|
|
77
77
|
class ClientBin
|
78
|
-
def self.exit_usage(program, exit_code=2)
|
78
|
+
def self.exit_usage(program, exit_code = 2)
|
79
79
|
puts <<EOF
|
80
80
|
Usage:
|
81
81
|
% #{program} {TesWebUrl} {User} request_res {ResourceId} [1|0] # Request Specified Resource
|
@@ -88,7 +88,7 @@ EOF
|
|
88
88
|
|
89
89
|
def initialize(tes_url, user)
|
90
90
|
driver = HTTPClient.new(base_url: tes_url)
|
91
|
-
driver.ssl_config.verify_mode= OpenSSL::SSL::VERIFY_NONE
|
91
|
+
driver.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
92
92
|
@client = Client.new(driver)
|
93
93
|
@user = user
|
94
94
|
end
|
@@ -117,7 +117,7 @@ EOF
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
-
def request_res(res_id, lock=0)
|
120
|
+
def request_res(res_id, lock = 0)
|
121
121
|
ret = @client.request_res(res_id, @user, lock)
|
122
122
|
|
123
123
|
msg_suffix = "Request resource:(id: #{res_id}, user: #{@user}, lock: #{lock})."
|
@@ -135,11 +135,11 @@ EOF
|
|
135
135
|
ret[:success]
|
136
136
|
end
|
137
137
|
|
138
|
-
def release_pool(saved_env_file=nil)
|
138
|
+
def release_pool(saved_env_file = nil)
|
139
139
|
if saved_env_file and File.exists?(saved_env_file)
|
140
140
|
env_pool_info = YAML.load_file(saved_env_file)
|
141
141
|
locks = env_pool_info[:lockes]
|
142
|
-
locks.each {
|
142
|
+
locks.each {|lock| @client.release_res(lock, @user)} if locks
|
143
143
|
puts "[Info] Release env done(user: #{@user}, file: #{saved_env_file})."
|
144
144
|
else
|
145
145
|
@client.release_all_res(@user)
|
@@ -150,7 +150,7 @@ EOF
|
|
150
150
|
end
|
151
151
|
|
152
152
|
# request env pool
|
153
|
-
def request_pool(profile_file, save_file, timeout_secs=0)
|
153
|
+
def request_pool(profile_file, save_file, timeout_secs = 0)
|
154
154
|
File.exists?(profile_file) || raise(ArgumentError, "[ ER ] File not found:#{profile_file}")
|
155
155
|
|
156
156
|
asks = File.readlines(profile_file).map!(&:strip).compact
|
data/lib/tes/request/version.rb
CHANGED
data/tes-request.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{Request libs and bins for TES(Test Env Service)}
|
13
13
|
spec.description = %q{Provide Tes-Client, Tes-Provider to use public Logic and data struct}
|
14
|
-
spec.homepage = 'https://github.com/
|
14
|
+
spec.homepage = 'https://github.com/NightProgrammers/tes-request'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tes-request
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wuhuizuo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: java-properties
|
@@ -111,7 +111,7 @@ files:
|
|
111
111
|
- lib/tes/request/rspec/profile_parser.rb
|
112
112
|
- lib/tes/request/version.rb
|
113
113
|
- tes-request.gemspec
|
114
|
-
homepage: https://github.com/
|
114
|
+
homepage: https://github.com/NightProgrammers/tes-request
|
115
115
|
licenses:
|
116
116
|
- MIT
|
117
117
|
metadata:
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.6.
|
135
|
+
rubygems_version: 2.6.14
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Request libs and bins for TES(Test Env Service)
|