zotplus-rakehelper 0.0.17 → 0.0.18

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: 1c2d6bf82e6aceb24a74078d332ef7d909b461a0
4
- data.tar.gz: b1ea6c229ec350d59c5f6cf999b84b2d0e65b1e7
3
+ metadata.gz: c65ab8621660299971f02621d43bdd8965ed12da
4
+ data.tar.gz: 4bbdaf05e9a21c64b3c0d1c7fcf7c88e4de48ea1
5
5
  SHA512:
6
- metadata.gz: e978515308f9378298219c68cf34bd630e88a8c58b5402488705c90388200e54069b633e5831815b329d7f4de33af49a6aee0e19cdb8a7151158736319a068fa
7
- data.tar.gz: 87f4283ce3e4dfe536d063012d47df290bb21f8cf61de528d4fae1213ac17a045bef4b9fa49f166779dfd7b9ef248bfa2b11bd37f7a489cbc82d9dd345bfac61
6
+ metadata.gz: aed7dce7e600fb46d67a99bf52fc4281f42753681a3cf016a88e84158aeedea8de636e63ac34b043f5707eecffc1a7107e6aca48aca1d825d371b762061475d4
7
+ data.tar.gz: 5ab90061fcb229e81111b529cacae883e2ecc6c72c5a44ef4c373c4c8c3de1c818b35841608239005ec68d611902d2dee67cd8ca9cfb563fc4e8bd817cb13744
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zotplus-rakehelper (0.0.17)
4
+ zotplus-rakehelper (0.0.18)
5
5
  nokogiri
6
6
  rake
7
7
  rubyzip (>= 1.0.0)
@@ -1,126 +1,125 @@
1
1
  require 'typhoeus'
2
2
  require 'nokogiri'
3
3
  require 'zip'
4
+ require 'rake'
4
5
 
5
- module ZotPlus
6
- class RakeHelper
7
- def initialize(extrasources=[])
8
- @sources = %w{chrome test/import test/export resource defaults chrome.manifest install.rdf bootstrap.js}
9
- .collect{|f| File.directory?(f) ? Dir["#{f}/**/*"] : f}.flatten
10
- .select{|f| File.file?(f)}
11
- .collect{|f| f.sub(/\.pegjs$/, '.js')}
12
- .reject{|f| f =~ /[~]$/ || f =~ /\.swp$/} + extrasources
13
- @id = Nokogiri::XML(File.open('install.rdf')).at('//em:id').inner_text
14
- @extension = @id.gsub(/@.*/, '')
15
- @release = Nokogiri::XML(File.open('install.rdf')).at('//em:version').inner_text
16
- @xpi = "zotero-#{@extension}-#{@release}.xpi"
17
- end
18
- attr_reader :id, :extension, :release, :update_rdf, :sources, :xpi
19
-
20
- def geturl(url)
21
- response = Typhoeus.get(url, {followlocation: true})
22
- raise "Request failed" unless response.success?
23
- return response.body
24
- end
25
-
26
- def download(url, file)
27
- puts "Downloading #{url} to #{file}"
28
- target = File.open(file, 'wb')
29
- request = Typhoeus::Request.new(url, {followlocation: true})
30
- request.on_headers do |response|
31
- raise "Request failed: #{response.code.to_s}" unless response.code == 200 # response.success?
32
- end
33
- request.on_body do |chunk|
34
- target.write(chunk)
35
- end
36
- request.on_complete do |response|
37
- target.close
38
- throw "download failed" unless response.success?
39
- end
40
- request.run
41
- end
42
-
43
- def make_readme
44
- puts "Updating README.md"
45
-
46
- md = open("www/#{@extension}/index.md").read
47
- md.sub!(/^---(.|\n)+---\n/, '')
48
- md.gsub!(/{% include ([^\s]+) %}/){ open("www/_includes/#{$1}").read }
49
- md.gsub!(/\[([^!\]]+)\]\(([^\)]+)\)/) {
50
- title = $1
51
- url = $2
52
- url = "/#{@extension}/#{url}" unless url =~ /^https?:/ || url =~ /^\//
53
- url = "https://zotplus.github.io#{url}" unless url =~ /^https?:/
54
- "[#{title}](#{url})"
55
- }
56
- open('README.md', 'w'){|f| f.write(md) }
57
- end
58
-
59
- def make_update_rdf
60
- rdf = Nokogiri::XML(File.open('update.rdf'))
61
- rdf.at('//em:version').content = @release
62
- rdf.at('//RDF:Description')['about'] = "urn:mozilla:extension:#{@id}"
63
- rdf.xpath('//em:updateLink').each{|link| link.content = "https://zotplus.github.io/#{@extension}/#{File.basename(xpi)}" }
64
- rdf.xpath('//em:updateInfoURL').each{|link| link.content = "https://zotplus.github.io/#{@extension}" }
65
- File.open('update.rdf','wb') {|f| rdf.write_xml_to f}
66
- end
67
-
68
- def get_debugbridge
69
- update = Nokogiri::XML(geturl('http://zotplus.github.io/debug-bridge/update.rdf')).at('//em:updateLink').inner_text
70
- debug_bridge = Dir['tmp/zotero-debug-bridge-*.xpi']
71
- debug_bridge.each{|f| File.unlink(f)} if debug_bridge.size != 1 || update.sub(/.*\//, '') != File.basename(debug_bridge[0])
72
- download(update, "tmp/#{update.sub(/.*\//, '')}") unless File.file?("tmp/#{update.sub(/.*\//, '')}")
73
- end
74
-
75
- def build(filelist)
76
- Dir["#{File.dirname(xpi)}/*.xpi"].each{|f| File.unlink(f) }
77
-
78
- Zip::File.open(xpi, 'w') do |zipfile|
79
- filelist.each{|file|
80
- if file.is_a?(Hash)
81
- file.each_pair{|name, contents|
82
- zipfile.get_output_stream(name){|f|
83
- f.write(contents)
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
- end
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
@@ -1,5 +1,5 @@
1
1
  module ZotPlus
2
2
  class RakeHelper
3
- VERSION = "0.0.17"
3
+ VERSION = "0.0.18"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zotplus-rakehelper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emiliano Heyns