image_optim_pack 0.5.0.20170830 → 0.5.0.20170831

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: f81e543474ef77214d96151e635afa958a39c92b
4
- data.tar.gz: adba475c0d994b81ca253b7eb5a24e0e55c334ab
3
+ metadata.gz: ee92e0df607ff89c425b06527be70b51f32a0ded
4
+ data.tar.gz: 9c95407e8a1619787ebc93adea3781154f31864a
5
5
  SHA512:
6
- metadata.gz: a66554e0873d899a8afc5ee18a57fcf96b7f19eca1c55d58ceabae74929a4e244a9d1333ec4762e20ee2a16253bfde60c202ab3a29f0a8f96968cfe328a4cf82
7
- data.tar.gz: 0c4027b85d605cc33403a6507e36e777f60e82436c56e17f7bf3b5c794d1917e991a2832eb21e596f2d771afc19d99eaeda998f483ab33fdbaaaa159f47b395b
6
+ metadata.gz: fdca27029f7d84cab18497d146abcc0b18d590feb4407f1d9e71143dec08cf3603e63349e06dd0c556617130576f5602b9522414078ac53883101bcc56ea1729
7
+ data.tar.gz: 127551232bb05760c9ef0df1ee9085403f37cfc2654034e07e224e6ae2e54036c7e34312bb3834c2144fc8ebc04543c9c374afe15369f72262a319ee096b9738
data/.rubocop.yml CHANGED
@@ -61,9 +61,6 @@ Style/Semicolon:
61
61
  Style/SignalException:
62
62
  EnforcedStyle: semantic
63
63
 
64
- Style/SpecialGlobalVars:
65
- Enabled: false
66
-
67
64
  Style/SymbolArray:
68
65
  Enabled: false
69
66
 
data/CHANGELOG.markdown CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## unreleased
4
4
 
5
+ ## v0.5.0.20170831 (2017-08-31)
6
+
7
+ * pngcrush 1.8.13 [@toy](https://github.com/toy)
8
+
5
9
  ## v0.5.0.20170830 (2017-08-30)
6
10
 
7
11
  * libpng 1.6.32 [@toy](https://github.com/toy)
data/Makefile CHANGED
@@ -12,7 +12,7 @@ LIBMOZJPEG_VER := 3.1
12
12
  LIBPNG_VER := 1.6.32
13
13
  LIBZ_VER := 1.2.11
14
14
  OPTIPNG_VER := 0.7.6
15
- PNGCRUSH_VER := 1.8.12
15
+ PNGCRUSH_VER := 1.8.13
16
16
  PNGQUANT_VER := 2.10.2
17
17
 
18
18
  # ====== CONSTANTS ======
@@ -193,14 +193,10 @@ test :
193
193
  $(call check_bin,pngquant,--help,$(PNGQUANT_VER))
194
194
  .PHONY : test
195
195
 
196
- livecheck :; @$(foreach archive,$(ARCHIVES),script/livecheck $(call downcase,$(archive)) $($(archive)_VER);)
196
+ livecheck :; @script/livecheck
197
197
  .PHONY : livecheck
198
198
 
199
- Makefile.updated :
200
- cat Makefile | script/update_versions > Makefile.updated
201
-
202
- update-versions : Makefile.updated
203
- mv Makefile.updated Makefile
199
+ update-versions :; @script/livecheck --update
204
200
  .PHONY : update-versions
205
201
 
206
202
  # ====== CLEAN ======
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'image_optim_pack'
5
- s.version = '0.5.0.20170830'
5
+ s.version = '0.5.0.20170831'
6
6
  s.summary = %q{Precompiled binaries for image_optim: advpng, gifsicle, jhead, jpeg-recompress, jpegoptim, jpegtran, optipng, pngcrush, pngquant}
7
7
  s.homepage = "http://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
data/script/livecheck CHANGED
@@ -1,82 +1,173 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Get latest version of tools
4
-
5
3
  require 'yaml'
6
4
  require 'uri'
7
5
  require 'net/http'
6
+ require 'openssl'
8
7
  require 'rubygems/version'
8
+ require 'fspath'
9
+
10
+ # Fetch and compare latest tool/library versions
11
+ class Livecheck
12
+ # Commands
13
+ class Cli
14
+ VERSION_REGEXP = /^([A-Z]+)_VER *:= *(.*)$/
15
+
16
+ def initialize(args)
17
+ @update = args.delete('--update')
18
+ abort '--update is the only supported option' unless args.empty?
19
+ end
20
+
21
+ def run
22
+ dump_changes
23
+
24
+ return unless @update
25
+ return unless livechecks.any?(&:changed?)
26
+
27
+ update_changelog
28
+ update_makefile
29
+ end
30
+
31
+ private
32
+
33
+ def dump_changes
34
+ livechecks.each do |lc|
35
+ next unless lc.changed?
36
+ puts "#{lc.name_n_latest_version} (current: #{lc.current_version})"
37
+ end
38
+ end
9
39
 
10
- # Compare versions including libjpeg ones (9b <=> 9)
11
- class Version
12
- include Comparable
40
+ def update_changelog
41
+ changelog = FSPath('CHANGELOG.markdown')
42
+ lines = changelog.readlines
43
+ lines.insert(4, "\n") if lines[4] =~ /^## /
44
+ lines.insert(4, changelog_entry)
45
+ write(changelog, lines.join(''))
46
+ end
47
+
48
+ def update_makefile
49
+ content = makefile.read.gsub(VERSION_REGEXP) do
50
+ livecheck = livechecks_by_name[Regexp.last_match[1].downcase]
51
+ "#{livecheck.name.upcase}_VER := #{livecheck.latest_version}"
52
+ end
53
+ write(makefile, content)
54
+ end
55
+
56
+ def makefile
57
+ FSPath('Makefile')
58
+ end
59
+
60
+ def livechecks
61
+ @livechecks ||= makefile.read.scan(VERSION_REGEXP).map do |name, version|
62
+ Livecheck.new(name.downcase, version)
63
+ end
64
+ end
65
+
66
+ def livechecks_by_name
67
+ @livechecks_by_name ||= Hash[livechecks.map{ |lc| [lc.name, lc] }]
68
+ end
69
+
70
+ def changelog_entry
71
+ github_user = `git config github.user`.strip
72
+ changed = livechecks.select(&:changed?)
73
+ %W[
74
+ *
75
+ #{to_sentence(changed.map(&:name_n_latest_version))}
76
+ [@#{github_user}](https://github.com/#{github_user})
77
+ ].join(' ') + "\n"
78
+ end
13
79
 
14
- attr_reader :string, :parsed
15
- alias_method :to_s, :string
80
+ def to_sentence(array)
81
+ case array.length
82
+ when 0 then ''
83
+ when 1 then array[0].to_s
84
+ else "#{array[0...-1].join(', ')} and #{array[-1]}"
85
+ end
86
+ end
16
87
 
17
- def initialize(string)
18
- @string = string
19
- @parsed = begin
20
- Gem::Version.new(string)
21
- rescue ArgumentError
22
- nil
88
+ def write(path, data)
89
+ path.temp_file(path.dirname) do |io|
90
+ io.write data
91
+ io.path.rename(path)
92
+ end
93
+ warn "Wrote #{path}"
23
94
  end
24
95
  end
25
96
 
26
- def <=>(other)
27
- if parsed && other.parsed
28
- parsed <=> other.parsed
29
- else
30
- string <=> other.string
97
+ # Compare versions including libjpeg ones (9b <=> 9)
98
+ class Version
99
+ include Comparable
100
+
101
+ attr_reader :string, :parsed
102
+ alias_method :to_s, :string
103
+
104
+ def initialize(string)
105
+ @string = string
106
+ @parsed = begin
107
+ Gem::Version.new(string)
108
+ rescue ArgumentError
109
+ nil
110
+ end
111
+ end
112
+
113
+ def <=>(other)
114
+ if parsed && other.parsed
115
+ parsed <=> other.parsed
116
+ else
117
+ string <=> other.string
118
+ end
31
119
  end
32
120
  end
33
- end
34
121
 
35
- bare = ARGV.delete('--bare')
122
+ CONFIG = YAML.load(DATA).freeze
36
123
 
37
- unless [1, 2].include?(ARGV.length)
38
- abort 'expected project name and optional current version'
39
- end
124
+ attr_reader :name, :current_version
40
125
 
41
- def version(string)
42
- Version.new(string)
43
- end
126
+ def initialize(name, current_version)
127
+ @name = name
128
+ @current_version = Version.new(current_version)
129
+ @fetcher = Thread.new{ fetch_versions.last }
130
+ end
131
+
132
+ def latest_version
133
+ @fetcher.value
134
+ end
44
135
 
45
- def get(url)
46
- uri = URI(url)
136
+ def changed?
137
+ latest_version != current_version
138
+ end
47
139
 
48
- http = Net::HTTP.new(uri.host, uri.port)
49
- http.use_ssl = (uri.scheme == 'https')
140
+ def name_n_latest_version
141
+ "#{name} #{latest_version}"
142
+ end
50
143
 
51
- request = Net::HTTP::Get.new(uri.request_uri)
52
- http.request(request).body
53
- end
144
+ private
54
145
 
55
- name = ARGV[0].downcase
56
- config = YAML.load(DATA)[name]
57
- abort "Livecheck for #{name} was not defined" unless config
58
-
59
- url = config['url']
60
- version_regex = Regexp.new(config['regexp'])
61
- current_version = ARGV[1] && version(ARGV[1])
62
-
63
- data = get(url)
64
- versions = data.scan(version_regex).uniq.map{ |match| version(match[0]) }
65
- abort "No versions found for #{name} in data:\n#{data}" if versions.empty?
66
-
67
- latest_version = versions.max
68
- case
69
- when bare
70
- print latest_version
71
- when current_version
72
- if latest_version != current_version
73
- sign = latest_version > current_version ? '>' : '<'
74
- puts "#{name} #{latest_version} #{sign} #{current_version}"
146
+ def config
147
+ CONFIG[name] || fail(ArgumentError, "Livecheck for #{name} not defined")
148
+ end
149
+
150
+ def get(url)
151
+ uri = URI(url)
152
+ http = Net::HTTP.new(uri.host, uri.port)
153
+ http.use_ssl = (uri.scheme == 'https')
154
+ http.request_get(uri.request_uri).body
155
+ end
156
+
157
+ def fetch_versions
158
+ body = get(config['url'])
159
+
160
+ version_regex = Regexp.new(config['regexp'])
161
+
162
+ versions = body.scan(version_regex).map{ |match| Version.new(*match) }.sort
163
+ fail "No versions found for #{name} in body:\n#{body}" if versions.empty?
164
+
165
+ versions
75
166
  end
76
- else
77
- puts "#{name} #{latest_version}"
78
167
  end
79
168
 
169
+ Livecheck::Cli.new(ARGV).run
170
+
80
171
  __END__
81
172
  advancecomp:
82
173
  url: https://github.com/amadvance/advancecomp/releases.atom
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_optim_pack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.20170830
4
+ version: 0.5.0.20170831
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Kuchin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-29 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: image_optim
@@ -135,7 +135,6 @@ files:
135
135
  - lib/image_optim_pack.rb
136
136
  - script/livecheck
137
137
  - script/run
138
- - script/update_versions
139
138
  - spec/image_optim/pack_spec.rb
140
139
  - spec/image_optim_spec.rb
141
140
  - spec/spec_helper.rb
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Feed Makefile to this script to set all variables XXX_VER to latest versions
4
-
5
- ARGF.map do |line|
6
- if (name = line[/^([A-Z]+)_VER *:= *.*/, 1])
7
- Thread.new do
8
- version = `script/livecheck --bare #{name}`.strip
9
- abort unless $?.success?
10
- "#{name}_VER := #{version}\n"
11
- end
12
- else
13
- line
14
- end
15
- end.each do |out|
16
- if out.respond_to?(:value)
17
- $stderr << out.value unless $stdout.tty?
18
- $stdout << out.value
19
- else
20
- $stdout << out
21
- end
22
- end