zotplus-rakehelper 0.0.17 → 0.0.18
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 +117 -118
- data/lib/zotplus-rakehelper/version.rb +1 -1
- 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: c65ab8621660299971f02621d43bdd8965ed12da
|
4
|
+
data.tar.gz: 4bbdaf05e9a21c64b3c0d1c7fcf7c88e4de48ea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aed7dce7e600fb46d67a99bf52fc4281f42753681a3cf016a88e84158aeedea8de636e63ac34b043f5707eecffc1a7107e6aca48aca1d825d371b762061475d4
|
7
|
+
data.tar.gz: 5ab90061fcb229e81111b529cacae883e2ecc6c72c5a44ef4c373c4c8c3de1c818b35841608239005ec68d611902d2dee67cd8ca9cfb563fc4e8bd817cb13744
|
data/Gemfile.lock
CHANGED
data/lib/zotplus-rakehelper.rb
CHANGED
@@ -1,126 +1,125 @@
|
|
1
1
|
require 'typhoeus'
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'zip'
|
4
|
+
require 'rake'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
}
|
86
|
-
else
|
87
|
-
zipfile.add(file, file)
|
88
|
-
end
|
6
|
+
SOURCES ||= []
|
7
|
+
ZIPFILES ||= []
|
8
|
+
|
9
|
+
%w{chrome test/import test/export resource defaults chrome.manifest install.rdf bootstrap.js}
|
10
|
+
.collect{|f| File.directory?(f) ? Dir["#{f}/**/*"] : f}.flatten
|
11
|
+
.select{|f| File.file?(f)}
|
12
|
+
.collect{|f| f.sub(/\.pegjs$/, '.js')}
|
13
|
+
.reject{|f| f =~ /[~]$/ || f =~ /\.swp$/}
|
14
|
+
.each{|source| SOURCES << source }
|
15
|
+
|
16
|
+
ID = Nokogiri::XML(File.open('install.rdf')).at('//em:id').inner_text
|
17
|
+
EXTENSION = ID.gsub(/@.*/, '')
|
18
|
+
RELEASE = Nokogiri::XML(File.open('install.rdf')).at('//em:version').inner_text
|
19
|
+
XPI = "zotero-#{EXTENSION}-#{RELEASE}.xpi"
|
20
|
+
|
21
|
+
def geturl(url)
|
22
|
+
response = Typhoeus.get(url, {followlocation: true})
|
23
|
+
raise "Request failed" unless response.success?
|
24
|
+
return response.body
|
25
|
+
end
|
26
|
+
|
27
|
+
def download(url, file)
|
28
|
+
puts "Downloading #{url} to #{file}"
|
29
|
+
target = File.open(file, 'wb')
|
30
|
+
request = Typhoeus::Request.new(url, {followlocation: true})
|
31
|
+
request.on_headers do |response|
|
32
|
+
raise "Request failed: #{response.code.to_s}" unless response.code == 200 # response.success?
|
33
|
+
end
|
34
|
+
request.on_body do |chunk|
|
35
|
+
target.write(chunk)
|
36
|
+
end
|
37
|
+
request.on_complete do |response|
|
38
|
+
target.close
|
39
|
+
throw "download failed" unless response.success?
|
40
|
+
end
|
41
|
+
request.run
|
42
|
+
end
|
43
|
+
|
44
|
+
task 'README.md' => ['install.rdf', "www/#{EXTENSION}/index.md"] do |t|
|
45
|
+
puts "Updating #{t.name}"
|
46
|
+
|
47
|
+
md = open(t.source).read
|
48
|
+
md.sub!(/^---(.|\n)+---\n/, '')
|
49
|
+
md.gsub!(/{% include ([^\s]+) %}/){ open("www/_includes/#{$1}").read }
|
50
|
+
md.gsub!(/\[([^!\]]+)\]\(([^\)]+)\)/) {
|
51
|
+
title = $1
|
52
|
+
url = $2
|
53
|
+
url = "/#{EXTENSION}/#{url}" unless url =~ /^https?:/ || url =~ /^\//
|
54
|
+
url = "https://zotplus.github.io#{url}" unless url =~ /^https?:/
|
55
|
+
"[#{title}](#{url})"
|
56
|
+
}
|
57
|
+
open(t.name, 'w'){|f| f.write(md) }
|
58
|
+
end
|
59
|
+
|
60
|
+
task 'update.rdf' => 'install.rdf' do
|
61
|
+
rdf = Nokogiri::XML(File.open(t.name))
|
62
|
+
rdf.at('//em:version').content = RELEASE
|
63
|
+
rdf.at('//RDF:Description')['about'] = "urn:mozilla:extension:#{ID}"
|
64
|
+
rdf.xpath('//em:updateLink').each{|link| link.content = "https://zotplus.github.io/#{EXTENSION}/#{XPI}" }
|
65
|
+
rdf.xpath('//em:updateInfoURL').each{|link| link.content = "https://zotplus.github.io/#{EXTENSION}" }
|
66
|
+
File.open(t.name) {|f| rdf.write_xml_to f}
|
67
|
+
end
|
68
|
+
|
69
|
+
task :debugbridge
|
70
|
+
update = Nokogiri::XML(geturl('http://zotplus.github.io/debug-bridge/update.rdf')).at('//em:updateLink').inner_text
|
71
|
+
debug_bridge = Dir['tmp/zotero-debug-bridge-*.xpi']
|
72
|
+
debug_bridge.each{|f| File.unlink(f)} if debug_bridge.size != 1 || update.sub(/.*\//, '') != File.basename(debug_bridge[0])
|
73
|
+
download(update, "tmp/#{update.sub(/.*\//, '')}") unless File.file?("tmp/#{update.sub(/.*\//, '')}")
|
74
|
+
end
|
75
|
+
|
76
|
+
task XPI => SOURCES + ['install/rdf'] do
|
77
|
+
Dir["*.xpi"].each{|f| File.unlink(f) }
|
78
|
+
|
79
|
+
Zip::File.open(XPI, 'w') do |zipfile|
|
80
|
+
ZIPFILES.each{|file|
|
81
|
+
if file.is_a?(Hash)
|
82
|
+
file.each_pair{|name, contents|
|
83
|
+
zipfile.get_output_stream(name){|f|
|
84
|
+
f.write(contents)
|
85
|
+
}
|
89
86
|
}
|
87
|
+
else
|
88
|
+
zipfile.add(file, file)
|
90
89
|
end
|
91
|
-
|
92
|
-
|
93
|
-
def bump(what=:patch)
|
94
|
-
release = @release.split('.').collect{|n| Integer(n)}
|
95
|
-
release = case what
|
96
|
-
when :major then [release[0] + 1, 0, 0]
|
97
|
-
when :minor then [release[0], release[1] + 1, 0]
|
98
|
-
when :patch then [release[0], release[1], release[2] + 1]
|
99
|
-
else raise "Unexpected release increase #{what.inspect}"
|
100
|
-
end
|
101
|
-
release = release.collect{|n| n.to_s}.join('.')
|
102
|
-
|
103
|
-
open("www/_includes/#{@extension}-version.html", 'w'){|f| f.write(release) }
|
104
|
-
|
105
|
-
|
106
|
-
install_rdf = Nokogiri::XML(File.open('install.rdf'))
|
107
|
-
install_rdf.at('//em:version').content = release
|
108
|
-
install_rdf.at('//em:updateURL').content = "https://zotplus.github.io/#{@extension}/update.rdf"
|
109
|
-
File.open('install.rdf','wb') {|f| install_rdf.write_xml_to f}
|
110
|
-
puts `git add install.rdf`
|
111
|
-
puts `/bin/sh -lc rake`
|
112
|
-
puts `/bin/sh -lc rake README.md #{update_rdf}`
|
113
|
-
puts "Release set to #{release}. Please publish."
|
114
|
-
|
115
|
-
FileUtils.cp('update.rdf', "www/#{@extension}/update.rdf")
|
116
|
-
Dir['*.xpi'].each{|f| FileUtils.cp(f, "www/#{@extension}/#{f}") }
|
117
|
-
end
|
118
|
-
|
119
|
-
def publish
|
120
|
-
system "git commit -am #{@release}"
|
121
|
-
system "git tag #{@release}"
|
122
|
-
system "git push"
|
123
|
-
system "cd www; rake publish"
|
124
|
-
end
|
90
|
+
}
|
125
91
|
end
|
126
92
|
end
|
93
|
+
|
94
|
+
task :bump, :what do |t, args|
|
95
|
+
EXTENSION.bump((args[:what] || 'patch').intern)
|
96
|
+
release = RELEASE.split('.').collect{|n| Integer(n)}
|
97
|
+
release = case (args[:what] || 'patch').intern
|
98
|
+
when :major then [release[0] + 1, 0, 0]
|
99
|
+
when :minor then [release[0], release[1] + 1, 0]
|
100
|
+
when :patch then [release[0], release[1], release[2] + 1]
|
101
|
+
else raise "Unexpected release increase #{what.inspect}"
|
102
|
+
end
|
103
|
+
release = release.collect{|n| n.to_s}.join('.')
|
104
|
+
|
105
|
+
open("www/_includes/#{EXTENSION}-version.html", 'w'){|f| f.write(release) }
|
106
|
+
|
107
|
+
install_rdf = Nokogiri::XML(File.open('install.rdf'))
|
108
|
+
install_rdf.at('//em:version').content = release
|
109
|
+
install_rdf.at('//em:updateURL').content = "https://zotplus.github.io/#{EXTENSION}/update.rdf"
|
110
|
+
File.open('install.rdf','wb') {|f| install_rdf.write_xml_to f}
|
111
|
+
puts `git add install.rdf`
|
112
|
+
puts `/bin/sh -lc rake`
|
113
|
+
puts `/bin/sh -lc rake README.md update.rdf`
|
114
|
+
puts "Release set to #{release}. Please publish."
|
115
|
+
|
116
|
+
FileUtils.cp('update.rdf', "www/#{EXTENSION}/update.rdf")
|
117
|
+
Dir['*.xpi'].each{|f| FileUtils.cp(f, "www/#{EXTENSION}/#{f}") }
|
118
|
+
end
|
119
|
+
|
120
|
+
task :publish => XPI
|
121
|
+
system "git commit -am #{RELEASE}"
|
122
|
+
system "git tag #{RELEASE}"
|
123
|
+
system "git push"
|
124
|
+
system "cd www; rake publish"
|
125
|
+
end
|