zotplus-rakehelper 0.0.35 → 0.0.47
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/Gemfile.lock +1 -1
- data/lib/zotplus-rakehelper.rb +61 -23
- data/lib/zotplus-rakehelper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e1837201152a2f2e4ac8d1f61698befaf1e8e4
|
4
|
+
data.tar.gz: 9bc9ddfd4ceee2d52d05bfec475d199ad09737c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 162789ee4724b5a03bf2220382ec8349576ae47b9c52732657f595ab57c3220e4176829759b977b6c9b510aed9432a40eb47ff9d643fb6b9dd563fba3d0f0879
|
7
|
+
data.tar.gz: 7d8603e3d8e425029cf85c6043f98dabc821de009f362131bc8ba105ae62f94fa75eeeb0ae8080afa2a323016f5e77d26cad0fafd44c2c03420b477e68b019bf
|
data/Gemfile.lock
CHANGED
data/lib/zotplus-rakehelper.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
require 'typhoeus'
|
2
1
|
require 'nokogiri'
|
3
2
|
require 'zip'
|
4
3
|
require 'rake'
|
5
4
|
require 'rickshaw'
|
5
|
+
require 'uri'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'open-uri'
|
8
|
+
require 'ostruct'
|
6
9
|
|
7
10
|
SOURCES ||= []
|
8
11
|
|
@@ -47,13 +50,6 @@ task 'update.rdf' => [XPI, 'install.rdf'] do |t|
|
|
47
50
|
File.open(t.name, 'w') {|f| rdf.write_xml_to f}
|
48
51
|
end
|
49
52
|
|
50
|
-
task :debugbridge do
|
51
|
-
update = Nokogiri::XML(ZotPlus::RakeHelper.geturl('http://zotplus.github.io/debug-bridge/update.rdf')).at('//em:updateLink').inner_text
|
52
|
-
debug_bridge = Dir['tmp/zotero-debug-bridge-*.xpi']
|
53
|
-
debug_bridge.each{|f| File.unlink(f)} if debug_bridge.size != 1 || update.sub(/.*\//, '') != File.basename(debug_bridge[0])
|
54
|
-
ZotPlus::RakeHelper.download(update, "tmp/#{update.sub(/.*\//, '')}") unless File.file?("tmp/#{update.sub(/.*\//, '')}")
|
55
|
-
end
|
56
|
-
|
57
53
|
task XPI => SOURCES + ['install.rdf'] do
|
58
54
|
puts "Building #{XPI}"
|
59
55
|
Dir["*.xpi"].each{|f| File.unlink(f) }
|
@@ -107,27 +103,69 @@ end
|
|
107
103
|
|
108
104
|
module ZotPlus
|
109
105
|
class RakeHelper
|
106
|
+
|
110
107
|
def self.geturl(url)
|
111
|
-
|
112
|
-
|
113
|
-
return response.body
|
108
|
+
return open(url).read
|
109
|
+
#OpenURI::HTTPError
|
114
110
|
end
|
115
111
|
|
116
112
|
def self.download(url, file)
|
117
113
|
puts "Downloading #{url} to #{file}"
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
114
|
+
FileUtils.mkdir_p File.dirname(file)
|
115
|
+
|
116
|
+
data = open(url)
|
117
|
+
File.open(file, 'wb'){|f| f.write(data.read) }
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.resolvexpi(source)
|
121
|
+
if source =~ /update\.rdf$/
|
122
|
+
update_rdf = Nokogiri::XML(self.geturl(source))
|
123
|
+
update_rdf.remove_namespaces!
|
124
|
+
url = update_rdf.at('//updateLink').inner_text
|
125
|
+
elsif source =~ /^https:\/\/addons\.mozilla\.org\//
|
126
|
+
page = self.geturl(source)
|
127
|
+
page = Nokogiri::HTML(page)
|
128
|
+
url = page.at_css('p.install-button').at_css('a')['href']
|
129
|
+
|
130
|
+
url = URI.join(source, url ).to_s if url !~ /^http/
|
131
|
+
|
132
|
+
return self.resolvexpi(url) if url =~ /\/contribute\/roadblock\//
|
133
|
+
|
134
|
+
# AMO uses redirects, so I can't write the file to the final name just yet
|
135
|
+
final_uri = nil
|
136
|
+
open(url) do |h|
|
137
|
+
final_uri = h.base_uri
|
138
|
+
end
|
139
|
+
url = final_uri.to_s
|
140
|
+
elsif source =~ /^file:/ || source =~ /\.xpi(\?|$)/
|
141
|
+
url = source
|
142
|
+
else
|
143
|
+
throw "Unsupported XPI source #{source}"
|
129
144
|
end
|
130
|
-
|
145
|
+
|
146
|
+
return OpenStruct.new(url: url, xpi: url.sub(/.*\//, '').sub(/\?.*$/, ''))
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.getxpis(sources, dir)
|
150
|
+
installed = Dir["#{dir}/*.xpi"].collect{|f| File.basename(f) }
|
151
|
+
|
152
|
+
sources = sources.collect{|s| self.resolvexpi(s) }
|
153
|
+
|
154
|
+
(installed - sources.collect{|s| s.xpi}).each{|xpi|
|
155
|
+
puts "Removing #{xpi}"
|
156
|
+
File.unlink("#{dir}/#{xpi}")
|
157
|
+
}
|
158
|
+
sources.reject{|s| installed.include?(s.xpi) && s.url !~ /^file:/ }.each{|s|
|
159
|
+
if s.url =~ /^file:/
|
160
|
+
puts "Copying #{s.xpi}"
|
161
|
+
path = s.url.sub(/^file:/, '')
|
162
|
+
FileUtils.cp(path, "#{dir}/#{s.xpi}")
|
163
|
+
else
|
164
|
+
puts "Downloading #{s.xpi}"
|
165
|
+
self.download(s.url, "#{dir}/#{s.xpi}")
|
166
|
+
end
|
167
|
+
}
|
131
168
|
end
|
132
169
|
end
|
170
|
+
|
133
171
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zotplus-rakehelper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.47
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emiliano Heyns
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|