image_optim_pack 0.5.0.20170830-amd64-freebsd → 0.5.0.20170831-amd64-freebsd

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28261d7734760187fe82a8686ce88c24625d7957
4
- data.tar.gz: c37592a4ec43c52f74c29eb498c3ec3e1438b641
3
+ metadata.gz: b621272fd5a4e5619d47d2ad6caca61e6e714583
4
+ data.tar.gz: 450b4a2e3ff1881ffeee3ef03c451fed197e2066
5
5
  SHA512:
6
- metadata.gz: 4321a2115822c6aad9f8bc1b69f627459c89a66dca55620af51ab63f2aad56c51d7f7d562ab649809f7ab928f630d760ce384477a5021314fbbdac82d1234f7f
7
- data.tar.gz: a106eb890e86461ec15e9be673bcdd90d0154b27af4dc5baeb5a86830c24c2a140bdf8262ea0c3ab5e42df41ffd3bd9c0a78a408bc395f3837309bdd1fa846db
6
+ metadata.gz: a99fa378d7c292d5cd64d452ea0e16599d8d3d80b99afe62bd131833def86b0c7190c288a1bb87c5cc2197b201d349d6d739cd0ef4c8ee9dcdf5b8cd7a865ba7
7
+ data.tar.gz: c0cb5f15616b9d3bd4a233f0caceff71ce0522aae3d95871344f4b26ad8f6a6883270e9ee2a86f55310b4e18f623e73decf8dae78d2ba6682e5bccbae7635368
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
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: amd64-freebsd
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