tcms 1.0.5 → 1.0.6
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 +4 -4
- data/lib/tcms/version.rb +1 -1
- data/lib/tcms.rb +24 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 430e5ea036cee1adbc410416499684431cc185f7
|
4
|
+
data.tar.gz: c55736027e835baa4da61c8550db594f5df3ef3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8a0a265caa29e98ee0eb1e28bcf45ce26733678dc49577b892925557498feab806ef8e49ca46a7badf62ba55dbe433c4c5a711c9d8d4117a4193cd8bdbbda0d
|
7
|
+
data.tar.gz: 3a41fdc7dea50c3ce1efd8e56588fa5768c3be59ef55cca04d4319d555356e1c2f903deb354d025532ed917e54997e281b3e835997dc3e6af8090453fbc680ed
|
data/lib/tcms/version.rb
CHANGED
data/lib/tcms.rb
CHANGED
@@ -3,6 +3,7 @@ require 'rest_client'
|
|
3
3
|
require 'rake'
|
4
4
|
require 'pathname'
|
5
5
|
require 'json'
|
6
|
+
require 'fileutils'
|
6
7
|
|
7
8
|
begin
|
8
9
|
tcms_lib_path = Pathname.new(File.dirname(__FILE__)).realpath.to_s
|
@@ -45,17 +46,27 @@ module Tcms
|
|
45
46
|
|
46
47
|
#上传单个文件
|
47
48
|
def self.upload_file file,config
|
48
|
-
|
49
|
-
|
49
|
+
|
50
|
+
file_name = file.sub(config["folder"]+'/','')
|
51
|
+
|
52
|
+
remote_path = config["remotepath"]+'/'+file_name
|
50
53
|
puts "正在上传#{file}"
|
51
54
|
upload_path = "#{UPLOAD_CGI}?site=#{config["site"]}&channel=#{config["channel"]}&remotepath=#{remote_path}"
|
55
|
+
upload_file_path = file
|
56
|
+
|
52
57
|
begin
|
53
|
-
|
54
|
-
|
55
|
-
file_content = file_content.encode(config["
|
58
|
+
if config["remote_encode"] != 'UTF-8'
|
59
|
+
file_content = File.read(file)
|
60
|
+
file_content = file_content.encode(config["remote_encode"],"UTF-8",:invalid=>:replace,:undef=>:replace)
|
61
|
+
|
62
|
+
upload_file_path = config["folder"]+'/__upload__'+file_name
|
63
|
+
tmp_file = File.new(upload_file_path,'w+')
|
64
|
+
tmp_file.puts file_content
|
65
|
+
tmp_file.close
|
56
66
|
end
|
57
67
|
|
58
|
-
|
68
|
+
puts upload_file_path+"::xxxx"
|
69
|
+
response = RestClient.post(upload_path,:NEW_FILE=>File.new(upload_file_path)){|response,request,result|
|
59
70
|
if [200].include? response.code
|
60
71
|
puts '--上传成功!'+response.description
|
61
72
|
site = config["site"]
|
@@ -74,6 +85,10 @@ module Tcms
|
|
74
85
|
puts "(>_<)..."
|
75
86
|
puts "#{file}上传失败!"+ e.message
|
76
87
|
puts ''
|
88
|
+
ensure
|
89
|
+
if upload_file_path.include? '__upload__'
|
90
|
+
File.delete upload_file_path
|
91
|
+
end
|
77
92
|
end
|
78
93
|
end
|
79
94
|
|
@@ -100,7 +115,9 @@ module Tcms
|
|
100
115
|
FileList.new(pages['folder']+"/**/*").each do |f|
|
101
116
|
unless File.directory? f
|
102
117
|
if f.include? 'htm'
|
103
|
-
|
118
|
+
unless f.include? '__upload__'
|
119
|
+
self.upload_file f,pages
|
120
|
+
end
|
104
121
|
end
|
105
122
|
end
|
106
123
|
end
|