simple-rss 1.3.2 → 2.0.0
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/LICENSE +79 -7
- data/README.markdown +1 -1
- data/Rakefile +134 -136
- data/lib/simple-rss.rb +273 -154
- data/simple-rss.gemspec +4 -5
- data/test/base/array_tags_test.rb +37 -0
- data/test/base/base_test.rb +76 -77
- data/test/base/empty_tag_test.rb +56 -0
- data/test/base/encoding_test.rb +87 -0
- data/test/base/feed_attributes_test.rb +26 -0
- data/test/base/item_attributes_test.rb +26 -0
- data/test/data/atom_with_entry_attrs.xml +13 -0
- data/test/data/atom_with_feed_attrs.xml +13 -0
- data/test/data/media_rss.xml +465 -0
- data/test/data/rss20_utf8.xml +61 -0
- data/test/data/rss20_with_channel_attrs.xml +13 -0
- data/test/data/rss20_with_item_attrs.xml +13 -0
- data/test/test_helper.rb +10 -3
- metadata +14 -8
- data/install.rb +0 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d7399eb7c1eee38cca3bd3de50a18cdedbf85b1aeb8536688b628abca814cab
|
|
4
|
+
data.tar.gz: 7a27767cd9be24307344430c311507859ac825d7845ea9e703985355dd3ccfa3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e01cdc590e4fdac9d0be8df7307491b8f67e8b68422d7970b589b72e52872f8dab23935a6225b05993f4adf614f4641d24e0a23538daf7ed512969d1104a84f
|
|
7
|
+
data.tar.gz: 3568cebc46ca358c7d3a49b0615d49592ed7698e5fcb0c60a3a392c1904de4d4fb7d03fec3ac1d5270ada6c8679737c3a91b880e8dfb91d7aaa69bbfc1f9dab4
|
data/LICENSE
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 2.1, February 1999
|
|
3
3
|
|
|
4
4
|
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
|
5
|
-
|
|
5
|
+
<https://fsf.org/>
|
|
6
6
|
Everyone is permitted to copy and distribute verbatim copies
|
|
7
7
|
of this license document, but changing it is not allowed.
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
as the successor of the GNU Library Public License, version 2, hence
|
|
11
11
|
the version number 2.1.]
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Preamble
|
|
14
14
|
|
|
15
15
|
The licenses for most software are designed to take away your
|
|
16
16
|
freedom to share and change it. By contrast, the GNU General Public
|
|
@@ -112,7 +112,7 @@ modification follow. Pay close attention to the difference between a
|
|
|
112
112
|
former contains code derived from the library, whereas the latter must
|
|
113
113
|
be combined with the library in order to run.
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
116
116
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
117
117
|
|
|
118
118
|
0. This License Agreement applies to any software library or other
|
|
@@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
|
|
|
146
146
|
on the Library (independent of the use of the Library in a tool for
|
|
147
147
|
writing it). Whether that is true depends on what the Library does
|
|
148
148
|
and what the program that uses the Library does.
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
1. You may copy and distribute verbatim copies of the Library's
|
|
151
151
|
complete source code as you receive it, in any medium, provided that
|
|
152
152
|
you conspicuously and appropriately publish on each copy an
|
|
@@ -426,4 +426,76 @@ the Free Software Foundation.
|
|
|
426
426
|
14. If you wish to incorporate parts of the Library into other free
|
|
427
427
|
programs whose distribution conditions are incompatible with these,
|
|
428
428
|
write to the author to ask for permission. For software which is
|
|
429
|
-
copyrighted by
|
|
429
|
+
copyrighted by the Free Software Foundation, write to the Free
|
|
430
|
+
Software Foundation; we sometimes make exceptions for this. Our
|
|
431
|
+
decision will be guided by the two goals of preserving the free status
|
|
432
|
+
of all derivatives of our free software and of promoting the sharing
|
|
433
|
+
and reuse of software generally.
|
|
434
|
+
|
|
435
|
+
NO WARRANTY
|
|
436
|
+
|
|
437
|
+
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
|
438
|
+
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
|
439
|
+
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
|
440
|
+
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
|
441
|
+
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
|
442
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
443
|
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
|
444
|
+
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
|
445
|
+
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
446
|
+
|
|
447
|
+
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
|
448
|
+
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
|
449
|
+
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
|
450
|
+
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
|
451
|
+
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
|
452
|
+
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
|
453
|
+
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
|
454
|
+
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
|
455
|
+
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
456
|
+
DAMAGES.
|
|
457
|
+
|
|
458
|
+
END OF TERMS AND CONDITIONS
|
|
459
|
+
|
|
460
|
+
How to Apply These Terms to Your New Libraries
|
|
461
|
+
|
|
462
|
+
If you develop a new library, and you want it to be of the greatest
|
|
463
|
+
possible use to the public, we recommend making it free software that
|
|
464
|
+
everyone can redistribute and change. You can do so by permitting
|
|
465
|
+
redistribution under these terms (or, alternatively, under the terms of the
|
|
466
|
+
ordinary General Public License).
|
|
467
|
+
|
|
468
|
+
To apply these terms, attach the following notices to the library. It is
|
|
469
|
+
safest to attach them to the start of each source file to most effectively
|
|
470
|
+
convey the exclusion of warranty; and each file should have at least the
|
|
471
|
+
"copyright" line and a pointer to where the full notice is found.
|
|
472
|
+
|
|
473
|
+
<one line to give the library's name and a brief idea of what it does.>
|
|
474
|
+
Copyright (C) <year> <name of author>
|
|
475
|
+
|
|
476
|
+
This library is free software; you can redistribute it and/or
|
|
477
|
+
modify it under the terms of the GNU Lesser General Public
|
|
478
|
+
License as published by the Free Software Foundation; either
|
|
479
|
+
version 2.1 of the License, or (at your option) any later version.
|
|
480
|
+
|
|
481
|
+
This library is distributed in the hope that it will be useful,
|
|
482
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
483
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
484
|
+
Lesser General Public License for more details.
|
|
485
|
+
|
|
486
|
+
You should have received a copy of the GNU Lesser General Public
|
|
487
|
+
License along with this library; if not, see <https://www.gnu.org/licenses/>.
|
|
488
|
+
|
|
489
|
+
Also add information on how to contact you by electronic and paper mail.
|
|
490
|
+
|
|
491
|
+
You should also get your employer (if you work as a programmer) or your
|
|
492
|
+
school, if any, to sign a "copyright disclaimer" for the library, if
|
|
493
|
+
necessary. Here is a sample; alter the names:
|
|
494
|
+
|
|
495
|
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
|
496
|
+
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
|
497
|
+
|
|
498
|
+
<signature of Moe Ghoul>, 1 April 1990
|
|
499
|
+
Moe Ghoul, President of Vice
|
|
500
|
+
|
|
501
|
+
That's all there is to it!
|
data/README.markdown
CHANGED
|
@@ -17,7 +17,7 @@ The API is similar to Ruby's standard RSS parser:
|
|
|
17
17
|
require 'simple-rss'
|
|
18
18
|
require 'open-uri'
|
|
19
19
|
|
|
20
|
-
rss = SimpleRSS.parse open('http://slashdot.org/
|
|
20
|
+
rss = SimpleRSS.parse open('http://rss.slashdot.org/Slashdot/slashdot/to')
|
|
21
21
|
|
|
22
22
|
rss.channel.title # => "Slashdot"
|
|
23
23
|
rss.channel.link # => "http://slashdot.org/"
|
data/Rakefile
CHANGED
|
@@ -1,54 +1,53 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "bundler/setup"
|
|
3
|
+
require "rake"
|
|
4
|
+
require "rake/testtask"
|
|
5
|
+
require "rdoc/task"
|
|
6
|
+
require "rubygems/package_task"
|
|
7
|
+
require "./lib/simple-rss"
|
|
8
8
|
|
|
9
9
|
PKG_VERSION = SimpleRSS::VERSION
|
|
10
|
-
PKG_NAME = "simple-rss"
|
|
11
|
-
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
|
12
|
-
RUBY_FORGE_PROJECT = "simple-rss"
|
|
13
|
-
RUBY_FORGE_USER = ENV[
|
|
14
|
-
RELEASE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
|
10
|
+
PKG_NAME = "simple-rss".freeze
|
|
11
|
+
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}".freeze
|
|
12
|
+
RUBY_FORGE_PROJECT = "simple-rss".freeze
|
|
13
|
+
RUBY_FORGE_USER = ENV["RUBY_FORGE_USER"] || "cardmagic"
|
|
14
|
+
RELEASE_NAME = "#{PKG_NAME}-#{PKG_VERSION}".freeze
|
|
15
15
|
|
|
16
16
|
PKG_FILES = FileList[
|
|
17
17
|
"lib/*", "bin/*", "test/**/*", "[A-Z]*", "Rakefile", "html/**/*"
|
|
18
18
|
]
|
|
19
19
|
|
|
20
20
|
desc "Default Task"
|
|
21
|
-
task :
|
|
21
|
+
task default: [:test]
|
|
22
22
|
|
|
23
23
|
# Run the unit tests
|
|
24
24
|
desc "Run all unit tests"
|
|
25
|
-
Rake::TestTask.new("test")
|
|
26
|
-
t.libs << [
|
|
27
|
-
t.pattern =
|
|
25
|
+
Rake::TestTask.new("test") do |t|
|
|
26
|
+
t.libs << %w[lib test]
|
|
27
|
+
t.pattern = "test/*/*_test.rb"
|
|
28
28
|
t.verbose = true
|
|
29
|
-
|
|
29
|
+
end
|
|
30
30
|
|
|
31
31
|
# Make a console, useful when working on tests
|
|
32
32
|
desc "Generate a test console"
|
|
33
33
|
task :console do
|
|
34
|
-
|
|
34
|
+
verbose(false) { sh "irb -I lib/ -r 'simple-rss'" }
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# Genereate the RDoc documentation
|
|
38
38
|
desc "Create documentation"
|
|
39
|
-
Rake::RDocTask.new("doc")
|
|
39
|
+
Rake::RDocTask.new("doc") do |rdoc|
|
|
40
40
|
rdoc.title = "Simple RSS - A Flexible RSS and Atom reader for Ruby"
|
|
41
|
-
rdoc.rdoc_dir =
|
|
42
|
-
rdoc.rdoc_files.include(
|
|
43
|
-
rdoc.rdoc_files.include(
|
|
44
|
-
|
|
41
|
+
rdoc.rdoc_dir = "html"
|
|
42
|
+
rdoc.rdoc_files.include("README.markdown")
|
|
43
|
+
rdoc.rdoc_files.include("lib/*.rb")
|
|
44
|
+
end
|
|
45
45
|
|
|
46
46
|
# Genereate the package
|
|
47
47
|
spec = Gem::Specification.new do |s|
|
|
48
|
-
|
|
49
48
|
#### Basic information.
|
|
50
49
|
|
|
51
|
-
s.name =
|
|
50
|
+
s.name = "simple-rss"
|
|
52
51
|
s.version = PKG_VERSION
|
|
53
52
|
s.summary = <<-EOF
|
|
54
53
|
A simple, flexible, extensible, and liberal RSS and Atom reader for Ruby. It is designed to be backwards compatible with the standard RSS parser, but will never do RSS generation.
|
|
@@ -63,7 +62,7 @@ spec = Gem::Specification.new do |s|
|
|
|
63
62
|
|
|
64
63
|
#### Load-time details: library and application (you will need one or both).
|
|
65
64
|
|
|
66
|
-
s.require_path =
|
|
65
|
+
s.require_path = "lib"
|
|
67
66
|
|
|
68
67
|
#### Author and project details.
|
|
69
68
|
|
|
@@ -79,130 +78,129 @@ end
|
|
|
79
78
|
|
|
80
79
|
desc "Report code statistics (KLOCs, etc) from the application"
|
|
81
80
|
task :stats do
|
|
82
|
-
require
|
|
81
|
+
require "code_statistics"
|
|
83
82
|
CodeStatistics.new(
|
|
84
|
-
[
|
|
85
|
-
[
|
|
83
|
+
%w[Library lib],
|
|
84
|
+
%w[Units test]
|
|
86
85
|
).to_s
|
|
87
86
|
end
|
|
88
87
|
|
|
89
88
|
desc "Publish new documentation"
|
|
90
89
|
task :publish do
|
|
91
|
-
|
|
90
|
+
Rake::RubyForgePublisher.new("simple-rss", "cardmagic").upload
|
|
92
91
|
end
|
|
93
92
|
|
|
94
|
-
|
|
95
93
|
desc "Publish the release files to RubyForge."
|
|
96
|
-
task :
|
|
94
|
+
task upload: [:package] do
|
|
97
95
|
files = ["gem", "tar.gz", "zip"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
|
|
98
96
|
|
|
99
|
-
if RUBY_FORGE_PROJECT
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
97
|
+
if RUBY_FORGE_PROJECT
|
|
98
|
+
require "net/http"
|
|
99
|
+
require "open-uri"
|
|
100
|
+
|
|
101
|
+
project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
|
|
102
|
+
project_data = open(project_uri, &:read)
|
|
103
|
+
group_id = project_data[/[?&]group_id=(\d+)/, 1]
|
|
104
|
+
raise "Couldn't get group id" unless group_id
|
|
105
|
+
|
|
106
|
+
# This echos password to shell which is a bit sucky
|
|
107
|
+
if ENV["RUBY_FORGE_PASSWORD"]
|
|
108
|
+
password = ENV["RUBY_FORGE_PASSWORD"]
|
|
109
|
+
else
|
|
110
|
+
print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
|
|
111
|
+
password = STDIN.gets.chomp
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
|
115
|
+
data = [
|
|
116
|
+
"login=1",
|
|
117
|
+
"form_loginname=#{RUBY_FORGE_USER}",
|
|
118
|
+
"form_pw=#{password}"
|
|
119
|
+
].join("&")
|
|
120
|
+
http.post("/account/login.php", data)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
cookie = login_response["set-cookie"]
|
|
124
|
+
raise "Login failed" unless cookie
|
|
125
|
+
headers = { "Cookie" => cookie }
|
|
126
|
+
|
|
127
|
+
release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
|
|
128
|
+
release_data = open(release_uri, headers, &:read)
|
|
129
|
+
package_id = release_data[/[?&]package_id=(\d+)/, 1]
|
|
130
|
+
raise "Couldn't get package id" unless package_id
|
|
131
|
+
|
|
132
|
+
first_file = true
|
|
133
|
+
release_id = ""
|
|
134
|
+
|
|
135
|
+
files.each do |filename|
|
|
136
|
+
basename = File.basename(filename)
|
|
137
|
+
file_ext = File.extname(filename)
|
|
138
|
+
file_data = File.open(filename, "rb", &:read)
|
|
139
|
+
|
|
140
|
+
puts "Releasing #{basename}..."
|
|
141
|
+
|
|
142
|
+
release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
|
143
|
+
release_date = Time.now.strftime("%Y-%m-%d %H:%M")
|
|
144
|
+
type_map = {
|
|
145
|
+
".zip" => "3000",
|
|
146
|
+
".tgz" => "3110",
|
|
147
|
+
".gz" => "3110",
|
|
148
|
+
".gem" => "1400"
|
|
149
|
+
}; type_map.default = "9999"
|
|
150
|
+
type = type_map[file_ext]
|
|
151
|
+
boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
|
|
152
|
+
|
|
153
|
+
query_hash = if first_file
|
|
154
|
+
{
|
|
155
|
+
"group_id" => group_id,
|
|
156
|
+
"package_id" => package_id,
|
|
157
|
+
"release_name" => RELEASE_NAME,
|
|
158
|
+
"release_date" => release_date,
|
|
159
|
+
"type_id" => type,
|
|
160
|
+
"processor_id" => "8000", # Any
|
|
161
|
+
"release_notes" => "",
|
|
162
|
+
"release_changes" => "",
|
|
163
|
+
"preformatted" => "1",
|
|
164
|
+
"submit" => "1"
|
|
165
|
+
}
|
|
166
|
+
else
|
|
167
|
+
{
|
|
168
|
+
"group_id" => group_id,
|
|
169
|
+
"release_id" => release_id,
|
|
170
|
+
"package_id" => package_id,
|
|
171
|
+
"step2" => "1",
|
|
172
|
+
"type_id" => type,
|
|
173
|
+
"processor_id" => "8000", # Any
|
|
174
|
+
"submit" => "Add This File"
|
|
175
|
+
}
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
query = "?" + query_hash.map do |(name, value)|
|
|
179
|
+
[name, URI.encode(value)].join("=")
|
|
180
|
+
end.join("&")
|
|
181
|
+
|
|
182
|
+
data = [
|
|
183
|
+
"--" + boundary,
|
|
184
|
+
"Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
|
|
185
|
+
"Content-Type: application/octet-stream",
|
|
186
|
+
"Content-Transfer-Encoding: binary",
|
|
187
|
+
"", file_data, ""
|
|
188
|
+
].join("\x0D\x0A")
|
|
189
|
+
|
|
190
|
+
release_headers = headers.merge(
|
|
191
|
+
"Content-Type" => "multipart/form-data; boundary=#{boundary}"
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
|
|
195
|
+
http.post(target + query, data, release_headers)
|
|
114
196
|
end
|
|
115
197
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"form_loginname=#{RUBY_FORGE_USER}",
|
|
120
|
-
"form_pw=#{password}"
|
|
121
|
-
].join("&")
|
|
122
|
-
http.post("/account/login.php", data)
|
|
198
|
+
if first_file
|
|
199
|
+
release_id = release_response.body[/release_id=(\d+)/, 1]
|
|
200
|
+
raise("Couldn't get release id") unless release_id
|
|
123
201
|
end
|
|
124
202
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
headers = { "Cookie" => cookie }
|
|
128
|
-
|
|
129
|
-
release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
|
|
130
|
-
release_data = open(release_uri, headers) { |data| data.read }
|
|
131
|
-
package_id = release_data[/[?&]package_id=(\d+)/, 1]
|
|
132
|
-
raise "Couldn't get package id" unless package_id
|
|
133
|
-
|
|
134
|
-
first_file = true
|
|
135
|
-
release_id = ""
|
|
136
|
-
|
|
137
|
-
files.each do |filename|
|
|
138
|
-
basename = File.basename(filename)
|
|
139
|
-
file_ext = File.extname(filename)
|
|
140
|
-
file_data = File.open(filename, "rb") { |file| file.read }
|
|
141
|
-
|
|
142
|
-
puts "Releasing #{basename}..."
|
|
143
|
-
|
|
144
|
-
release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
|
145
|
-
release_date = Time.now.strftime("%Y-%m-%d %H:%M")
|
|
146
|
-
type_map = {
|
|
147
|
-
".zip" => "3000",
|
|
148
|
-
".tgz" => "3110",
|
|
149
|
-
".gz" => "3110",
|
|
150
|
-
".gem" => "1400"
|
|
151
|
-
}; type_map.default = "9999"
|
|
152
|
-
type = type_map[file_ext]
|
|
153
|
-
boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
|
|
154
|
-
|
|
155
|
-
query_hash = if first_file then
|
|
156
|
-
{
|
|
157
|
-
"group_id" => group_id,
|
|
158
|
-
"package_id" => package_id,
|
|
159
|
-
"release_name" => RELEASE_NAME,
|
|
160
|
-
"release_date" => release_date,
|
|
161
|
-
"type_id" => type,
|
|
162
|
-
"processor_id" => "8000", # Any
|
|
163
|
-
"release_notes" => "",
|
|
164
|
-
"release_changes" => "",
|
|
165
|
-
"preformatted" => "1",
|
|
166
|
-
"submit" => "1"
|
|
167
|
-
}
|
|
168
|
-
else
|
|
169
|
-
{
|
|
170
|
-
"group_id" => group_id,
|
|
171
|
-
"release_id" => release_id,
|
|
172
|
-
"package_id" => package_id,
|
|
173
|
-
"step2" => "1",
|
|
174
|
-
"type_id" => type,
|
|
175
|
-
"processor_id" => "8000", # Any
|
|
176
|
-
"submit" => "Add This File"
|
|
177
|
-
}
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
query = "?" + query_hash.map do |(name, value)|
|
|
181
|
-
[name, URI.encode(value)].join("=")
|
|
182
|
-
end.join("&")
|
|
183
|
-
|
|
184
|
-
data = [
|
|
185
|
-
"--" + boundary,
|
|
186
|
-
"Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
|
|
187
|
-
"Content-Type: application/octet-stream",
|
|
188
|
-
"Content-Transfer-Encoding: binary",
|
|
189
|
-
"", file_data, ""
|
|
190
|
-
].join("\x0D\x0A")
|
|
191
|
-
|
|
192
|
-
release_headers = headers.merge(
|
|
193
|
-
"Content-Type" => "multipart/form-data; boundary=#{boundary}"
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
|
|
197
|
-
http.post(target + query, data, release_headers)
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
if first_file then
|
|
201
|
-
release_id = release_response.body[/release_id=(\d+)/, 1]
|
|
202
|
-
raise("Couldn't get release id") unless release_id
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
first_file = false
|
|
206
|
-
end
|
|
203
|
+
first_file = false
|
|
204
|
+
end
|
|
207
205
|
end
|
|
208
206
|
end
|