zotplus-rakehelper 0.0.111 → 0.0.112
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/lib/zotplus-rakehelper.rb +15 -40
- 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: 21611eb9b4a4448fc369293fc4428055e88ab137
|
4
|
+
data.tar.gz: e40eb07daa18b9bac9209044fa2a9990aa311322
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94e430424799c9bd94a29fe33d6d63e25d106b36cf9d9ab28955b2c7f8f010ba223af37ccd3d575588f180f690bc5cb44b856e8eca0270f11394abafdd0ae3f2
|
7
|
+
data.tar.gz: eb92f0434e3b02ff7667ae3113236f8ce62a855ddd036e006ffb3f8e2b018046882f524673b47770fecaa0d77e670d36987897004b1831b25ebead14a613bd0b
|
data/lib/zotplus-rakehelper.rb
CHANGED
@@ -7,6 +7,7 @@ require 'fileutils'
|
|
7
7
|
require 'open-uri'
|
8
8
|
require 'ostruct'
|
9
9
|
require 'httparty'
|
10
|
+
require 'open-uri'
|
10
11
|
|
11
12
|
ID = Nokogiri::XML(File.open('install.rdf')).at('//em:id').inner_text
|
12
13
|
EXTENSION = ID.gsub(/@.*/, '')
|
@@ -14,45 +15,6 @@ RELEASE = Nokogiri::XML(File.open('install.rdf')).at('//em:version').inner_text
|
|
14
15
|
XPI = "zotero-#{EXTENSION}-#{RELEASE}.xpi"
|
15
16
|
NODEBIN="node_modules/.bin"
|
16
17
|
|
17
|
-
def etag_fetch(url, file)
|
18
|
-
tmp = Dir["#{file}.*.tmp"]
|
19
|
-
if tmp.size == 0
|
20
|
-
target = "#{file}.0.tmp"
|
21
|
-
etag = '0'
|
22
|
-
else
|
23
|
-
target = tmp[0]
|
24
|
-
etag = target.split('.')[-2]
|
25
|
-
end
|
26
|
-
|
27
|
-
response = HTTParty.head(url, headers: {'If-None-Match' => "\"#{etag}\""})
|
28
|
-
return target if response.code == 304
|
29
|
-
throw "Unexpected status code #{response.code}" unless response.code >= 200 && response.code < 300
|
30
|
-
|
31
|
-
target = "#{file}.#{response.headers['ETag'].gsub('"', '')}.tmp"
|
32
|
-
|
33
|
-
response = HTTParty.get(url)
|
34
|
-
open(target, 'w'){|f| f.write(response.body)}
|
35
|
-
|
36
|
-
Dir["#{file}.*.tmp"].each{|f| File.unlink(f) unless f == target }
|
37
|
-
return target
|
38
|
-
end
|
39
|
-
|
40
|
-
rule 'README.md' => [ proc{|t| etag_fetch("https://raw.githubusercontent.com/ZotPlus/ZotPlus.github.io/master/#{EXTENSION}/index.md", t) } ] do |t|
|
41
|
-
STDERR.puts "Updating #{t.name}"
|
42
|
-
|
43
|
-
md = open(t.source).read
|
44
|
-
md.sub!(/^---(.|\n)+---\n/, '')
|
45
|
-
md.gsub!(/{% include ([^\s]+) %}/){ RELEASE }
|
46
|
-
md.gsub!(/\[([^!\]]+)\]\(([^\)]+)\)/) {
|
47
|
-
title = $1
|
48
|
-
url = $2
|
49
|
-
url = "/#{EXTENSION}/#{url}" unless url =~ /^https?:/ || url =~ /^\//
|
50
|
-
url = "https://zotplus.github.io#{url}" unless url =~ /^https?:/
|
51
|
-
"[#{title}](#{url})"
|
52
|
-
}
|
53
|
-
open(t.name, 'w'){|f| f.write(md) }
|
54
|
-
end
|
55
|
-
|
56
18
|
task :default => XPI do
|
57
19
|
end
|
58
20
|
|
@@ -100,7 +62,20 @@ task :bump, :what do |t, args|
|
|
100
62
|
install_rdf.at('//em:version').content = release
|
101
63
|
install_rdf.at('//em:updateURL').content = "https://zotplus.github.io/#{EXTENSION}/update.rdf"
|
102
64
|
File.open('install.rdf','w') {|f| install_rdf.write_xml_to f}
|
103
|
-
|
65
|
+
|
66
|
+
md = open("https://raw.githubusercontent.com/ZotPlus/ZotPlus.github.io/master/#{EXTENSION}/index.md").read
|
67
|
+
md.sub!(/^---(.|\n)+---\n/, '')
|
68
|
+
md.gsub!(/{% include ([^\s]+) %}/){ release }
|
69
|
+
md.gsub!(/\[([^!\]]+)\]\(([^\)]+)\)/) {
|
70
|
+
title = $1
|
71
|
+
url = $2
|
72
|
+
url = "/#{EXTENSION}/#{url}" unless url =~ /^https?:/ || url =~ /^\//
|
73
|
+
url = "https://zotplus.github.io#{url}" unless url =~ /^https?:/
|
74
|
+
"[#{title}](#{url})"
|
75
|
+
}
|
76
|
+
open('README.md', 'w'){|f| f.write(md) }
|
77
|
+
|
78
|
+
sh "git add install.rdf README.md"
|
104
79
|
sh "git commit -m 'release: zotero-#{EXTENSION}-#{release}.xpi'"
|
105
80
|
sh "git tag #{release}"
|
106
81
|
end
|