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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tcms/version.rb +1 -1
  3. data/lib/tcms.rb +24 -7
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 279413908020f60acaa2d58b5f7c57bfe06249d1
4
- data.tar.gz: 40061af7efb609f13cf407f1bf4f6f91a0cc6295
3
+ metadata.gz: 430e5ea036cee1adbc410416499684431cc185f7
4
+ data.tar.gz: c55736027e835baa4da61c8550db594f5df3ef3a
5
5
  SHA512:
6
- metadata.gz: e57eb7aed2c5a0927cbe4d03bedd149b832f768158bd662835af63020c59c92597ba6a35b8514558c7bdb94514aebbb7d4c20981cb877f3c21041b77ab29c05a
7
- data.tar.gz: 4e9eb35d5c5977a93e549228c12f71c294ee4b0976553c874733bd56e53ef65d3c8caa7a8cbe4d848dd56e3a3a241e57e2b6aa42a51880918065dcc0676d4d26
6
+ metadata.gz: c8a0a265caa29e98ee0eb1e28bcf45ce26733678dc49577b892925557498feab806ef8e49ca46a7badf62ba55dbe433c4c5a711c9d8d4117a4193cd8bdbbda0d
7
+ data.tar.gz: 3a41fdc7dea50c3ce1efd8e56588fa5768c3be59ef55cca04d4319d555356e1c2f903deb354d025532ed917e54997e281b3e835997dc3e6af8090453fbc680ed
data/lib/tcms/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tcms
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
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
- remote_path = config["remotepath"]+'/'+file.sub(config["folder"]+'/','')
49
- puts remote_path+"::"
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
- file_content = File.read(file)
54
- if config["remote_encoding"]
55
- file_content = file_content.encode(config["remote_encoding"],"UTF-8",:invalid=>:replace,:undef=>:replace)
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
- response = RestClient.post(upload_path,{:NEW_FILE=>file_content,:multipart=>true}){|response,request,result|
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
- self.upload_file f,pages
118
+ unless f.include? '__upload__'
119
+ self.upload_file f,pages
120
+ end
104
121
  end
105
122
  end
106
123
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'bertwang'"