tcms 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9024662a4b3870e14e724a1873e8067322da240
4
- data.tar.gz: 0e7e2545339d311f6737d740e6746f876e6d840d
3
+ metadata.gz: 3c1684dd1cae1511dfb287f353c9a90e10a75266
4
+ data.tar.gz: 20770f6ed599a9a35dacc0fd790cbb9a0146089d
5
5
  SHA512:
6
- metadata.gz: a39dfd700b47cb02bfbd0ff93877f54f933cd69ad6556857d9cec85bdd9a08ceb8b777966255123d392bcfc4f3f4963663958dc3da69902d0aebcf5c44563c07
7
- data.tar.gz: 895806482edcf6587d99d4543fe94fd8b34b0a9b77320a7833900e817c26ea1d6a51480ac517781443eeeaeff8fb57afe0e9fe61ce04dc8492f34aae583dac7a
6
+ metadata.gz: a60630f5782d697b1b78658a21c7ebabe30eb6348ea383947dd1a6e33a7b61e6ee39e680b6e3de3f3a33e6757d18f2385c4183bdfab1b893b6fd8415ee72e862
7
+ data.tar.gz: 4291327663cab55a846de1e130d97959cc8e9fcc5e74108405b6bd154f86587ab9af65860329baa6e4781577a282154e3dc0ccb220a6d5e594f145a505441714
@@ -1,10 +1,14 @@
1
1
  require 'yaml'
2
- require 'rest_client'
2
+ require 'httpclient'
3
3
  require 'rake'
4
4
  require 'pathname'
5
5
  require 'json'
6
6
  require 'fileutils'
7
7
  require_relative "tcms/version.rb"
8
+ require_relative "tcms/publisher.rb"
9
+ require_relative "tcms/helper.rb"
10
+
11
+
8
12
 
9
13
  module Tcms
10
14
  PROJECT_FILE = "project.yml"
@@ -19,19 +23,19 @@ module Tcms
19
23
  files.each do |file|
20
24
  file_path = "#{file}/assets.yml"
21
25
 
22
- unless File.exist? file_path
26
+ unless File.exist? file_path
23
27
  puts "#{file}/ 下无assets.yml配置,请配置素材远程频道和目录.."
24
- next
28
+ next
25
29
  end
26
30
  file_config = self.read_config_file file_path
27
31
  if File.directory? file
28
32
  FileList.new(file+'/**/*').each do |f|
29
33
  unless File.directory? f
30
- self.upload_file f,file_config
34
+ self.upload_file f,file_config
31
35
  end
32
36
  end
33
37
  elsif File.exist? file
34
- self.upload_file file,file_config
38
+ self.upload_file file,file_config
35
39
  else
36
40
  puts "#{file} :无此文件"
37
41
  end
@@ -39,7 +43,7 @@ module Tcms
39
43
  end
40
44
 
41
45
  #上传单个文件
42
- def self.upload_file file,config
46
+ def self.upload_file file,config
43
47
 
44
48
  file_name = file.sub(config["folder"]+'/','')
45
49
 
@@ -54,26 +58,51 @@ module Tcms
54
58
  file_content = file_content.encode(config["remote_encoding"],"UTF-8",:invalid=>:replace,:undef=>:replace)
55
59
 
56
60
  upload_file_path = config["folder"]+'/__upload__'+file_name
57
- tmp_file = File.new(upload_file_path,'w+')
61
+ tmp_file = File.new(upload_file_path,'w+')
58
62
  tmp_file.puts file_content
59
63
  tmp_file.close
60
64
  end
61
-
62
- response = RestClient.post(upload_path,:NEW_FILE=>File.new(upload_file_path))
63
- if [200].include? response.code
64
- puts '--上传成功!'
65
- site = config["site"]
66
- domain = 'qq.com'
67
-
68
- #业务修正
69
- if site.match 'mat1' then domain = "gtimg.com/#{config["channel"]}" end
70
- if site.match 'pingjs' then site = 'rss' end
71
-
72
- url = "http://#{site}.#{domain}/#{remote_path}"
73
- puts '--远程地址:'+url
74
- else
75
- raise response
65
+ #puts upload_path
66
+ #puts File.read(upload_file_path)
67
+ File.open(upload_file_path) do |file|
68
+ body = {"NEW_FILE"=>file}
69
+ clnt = HTTPClient.new
70
+ res = clnt.post(upload_path, body)
71
+ #puts res.body.downcase
72
+ if res.status == 200
73
+ puts '--上传成功!'
74
+ site = config["site"]
75
+ domain = 'qq.com'
76
+
77
+ #业务修正
78
+ if site.match 'mat1' then domain = "gtimg.com/#{config["channel"]}" end
79
+ if site.match 'pingjs' then site = 'rss' end
80
+
81
+ url = "http://#{site}.#{domain}/#{remote_path}"
82
+ puts '--远程地址:'+url
83
+ else
84
+ raise res
85
+ end
76
86
  end
87
+
88
+ #response = RestClient.post upload_path,{:NEW_FILE=>File.new(upload_file_path,'rb')}
89
+ #
90
+ # if [200].include? response.code
91
+ # puts response
92
+ # #puts '--上传成功!'
93
+ # site = config["site"]
94
+ # domain = 'qq.com'
95
+ #
96
+ # #业务修正
97
+ # if site.match 'mat1' then domain = "gtimg.com/#{config["channel"]}" end
98
+ # if site.match 'pingjs' then site = 'rss' end
99
+ #
100
+ # url = "http://#{site}.#{domain}/#{remote_path}"
101
+ # puts '--远程地址:'+url
102
+ # else
103
+ # raise response
104
+ # end
105
+ #
77
106
  rescue Exception => e
78
107
  puts ''
79
108
  puts "(>_<)..."
@@ -119,7 +148,7 @@ module Tcms
119
148
 
120
149
  def self.build_project type
121
150
  unless type then type = 'dev' end
122
- unless ['dev','test','rel','release'].include? type
151
+ unless ['dev','test','rel','release'].include? type
123
152
  puts '未知命令选项,请选择[dev,test,release].'
124
153
  return
125
154
  end
@@ -140,7 +169,7 @@ module Tcms
140
169
  @template_config.each do |key,value|
141
170
  if value.respond_to? :has_key? and value.has_key? "_data_from_url"
142
171
  puts "获取献上接口数据#{value}.."
143
- response = RestClient.get value["_data_from_url"],{:accept=>:json}
172
+ response = RestClient.get value["_data_from_url"],{:accept=>:json}
144
173
  @template_config[key] = JSON.parse(response)
145
174
 
146
175
  if @template_config[key].is_a?(Hash)
@@ -160,7 +189,7 @@ module Tcms
160
189
  end
161
190
  end
162
191
 
163
- def self.create_project
192
+ def self.create_project
164
193
  template_folder = Pathname.new(File.dirname(__FILE__)).realpath.parent.to_s+"/template"
165
194
  if File.exist? 'project.yml'
166
195
  puts '已存在配置文件project.yml'
@@ -3,7 +3,7 @@ require 'erb'
3
3
  require 'json'
4
4
  require 'pathname'
5
5
 
6
- require "helper"
6
+ require_relative "helper.rb"
7
7
 
8
8
  module Tcms
9
9
  class Publisher
@@ -1,3 +1,3 @@
1
1
  module Tcms
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  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.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'bertwang'"
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.9'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.9.6
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,29 +24,20 @@ dependencies:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0.9'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.9.6
33
27
  - !ruby/object:Gem::Dependency
34
- name: rest-client
28
+ name: httpclient
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: '0.9'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 0.9.2
33
+ version: '2.6'
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
46
37
  requirements:
47
38
  - - "~>"
48
39
  - !ruby/object:Gem::Version
49
- version: '0.9'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 0.9.2
40
+ version: '2.6'
53
41
  - !ruby/object:Gem::Dependency
54
42
  name: rake
55
43
  requirement: !ruby/object:Gem::Requirement