oily_png 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c2c45f77de934d139cc78eadddf854af7889500
4
+ data.tar.gz: 192166b7e91148d078853b5c89b64a7e11f9b4ed
5
+ SHA512:
6
+ metadata.gz: db684810f478ab4849534bbe68108c5f68410954c89570045425be01e73bf7012430ba393444ebdd60f3a08b35bdb7455c0e1ac3efc3871e41565338eb7d9eb5
7
+ data.tar.gz: 67de9ecf90494bbbca1a7226046110f2a1e5fb4d970aa7751911f4535192e4a65e87f618d422fdb35173be4ee9c09dc21f4b0028f1c477ee31dead29d434de05
@@ -4,8 +4,9 @@ rvm:
4
4
  - 1.8.7
5
5
  - 1.9.2
6
6
  - 1.9.3
7
- - ruby-head
7
+ - 2.0.0
8
8
  - ree
9
+ - ruby-head
9
10
  - rbx-18mode
10
11
  - rbx-19mode
11
12
  matrix:
data/Gemfile CHANGED
@@ -1,11 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
+ gemspec
2
3
 
3
- if ENV['CHUNKY_PNG']
4
- gem 'chunky_png', :path => ENV['CHUNKY_PNG']
5
- gem 'oily_png', :path => File.dirname(__FILE__)
6
- gem 'rake'
7
- gem 'rake-compiler'
8
- gem 'rspec'
9
- else
10
- gemspec
11
- end
4
+ gem 'chunky_png', :path => ENV['CHUNKY_PNG'] if ENV['CHUNKY_PNG']
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Willem van Bergen
1
+ Copyright (c) 2010-2013 Willem van Bergen
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -24,4 +24,3 @@ ChunkyPNG API.
24
24
  License: MIT (see LICENSE)
25
25
 
26
26
  This C module is written by Willem van Bergen with help from Dirkjan Bussink.
27
-
data/Rakefile CHANGED
@@ -1,15 +1,19 @@
1
- Dir['tasks/*.rake'].each { |file| load(file) }
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rake/extensiontask"
2
4
 
3
- require 'rake/extensiontask'
5
+ Dir['tasks/*.rake'].each { |file| load(file) }
4
6
 
5
- gem_management_tasks = GithubGem::RakeTasks.new(:gem)
6
- Rake::ExtensionTask.new('oily_png', gem_management_tasks.gemspec) do |ext|
7
+ Rake::ExtensionTask.new('oily_png') do |ext|
7
8
  ext.lib_dir = File.join('lib', 'oily_png')
9
+ ext.config_options = '--with-cflags="-std=c99"'
10
+ end
11
+
12
+ RSpec::Core::RakeTask.new(:spec) do |task|
13
+ task.pattern = "./spec/**/*_spec.rb"
14
+ task.rspec_opts = ['--color']
8
15
  end
9
16
 
10
17
  Rake::Task['spec'].prerequisites << :compile
11
- Rake::Task['spec:basic'].prerequisites << :compile
12
- Rake::Task['spec:rcov'].prerequisites << :compile
13
- Rake::Task['spec:specdoc'].prerequisites << :compile
14
18
 
15
19
  task :default => [:spec]
@@ -23,7 +23,7 @@
23
23
  #define UNUSED_PARAMETER(param) (void) param
24
24
 
25
25
  // Type definitions
26
- typedef unsigned int PIXEL; // Pixels use 32 bits unsigned integers
26
+ typedef uint32_t PIXEL; // Pixels use 32 bits unsigned integers
27
27
  typedef unsigned char BYTE; // Bytes use 8 bits unsigned integers
28
28
 
29
29
 
@@ -173,9 +173,9 @@ VALUE oily_png_canvas_resample_bilinear_bang(VALUE self, VALUE v_new_width, VALU
173
173
  long index = 0;
174
174
  long x, y;
175
175
  long y1, y2, x1, x2;
176
- uint32_t y_residue, x_residue;
177
- uint32_t pixel_11, pixel_21, pixel_12, pixel_22;
178
- uint32_t pixel_top, pixel_bot;
176
+ PIXEL y_residue, x_residue;
177
+ PIXEL pixel_11, pixel_21, pixel_12, pixel_22;
178
+ PIXEL pixel_top, pixel_bot;
179
179
  for (y = 0; y < new_height; y++) {
180
180
  y1 = index_y[y] < 0 ? 0 : index_y[y];
181
181
  y2 = y1+1 >= self_height ? self_height-1 : y1+1;
@@ -1,9 +1,6 @@
1
1
  require 'chunky_png'
2
2
 
3
3
  module OilyPNG
4
-
5
- VERSION = "1.1.0"
6
-
7
4
  def self.included(base)
8
5
  base::Canvas.send(:extend, OilyPNG::PNGDecoding)
9
6
  base::Canvas.send(:include, OilyPNG::PNGEncoding)
@@ -16,6 +13,7 @@ module OilyPNG
16
13
  end
17
14
  end
18
15
 
16
+ require 'oily_png/version'
19
17
  require 'oily_png/oily_png'
20
18
  require 'oily_png/canvas'
21
19
 
@@ -0,0 +1,3 @@
1
+ module OilyPNG
2
+ VERSION = "1.1.1"
3
+ end
@@ -1,17 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'oily_png/version'
6
+
1
7
  Gem::Specification.new do |s|
2
8
  s.name = 'oily_png'
3
9
  s.rubyforge_project = s.name
4
-
10
+
5
11
  # Do not change the version and date fields by hand. This will be done
6
12
  # automatically by the gem release script.
7
- s.version = "1.1.0"
8
- s.date = "2013-02-15"
13
+ s.version = OilyPNG::VERSION
9
14
 
10
15
  s.summary = "Native mixin to speed up ChunkyPNG"
11
16
  s.description = <<-EOT
12
17
  This Ruby C extenstion defines a module that can be included into ChunkyPNG to improve its speed.
13
18
  EOT
14
19
 
20
+ s.license = 'MIT'
15
21
  s.authors = ['Willem van Bergen']
16
22
  s.email = ['willem@railsdoctors.com']
17
23
  s.homepage = 'http://wiki.github.com/wvanbergen/oily_png'
@@ -19,7 +25,7 @@ Gem::Specification.new do |s|
19
25
  s.extensions = ["ext/oily_png/extconf.rb"]
20
26
  s.require_paths = ["lib", "ext"]
21
27
 
22
- s.add_runtime_dependency('chunky_png', '~> 1.2.7')
28
+ s.add_runtime_dependency('chunky_png', '~> 1.3.0')
23
29
 
24
30
  s.add_development_dependency('rake')
25
31
  s.add_development_dependency('rake-compiler')
@@ -28,8 +34,6 @@ Gem::Specification.new do |s|
28
34
  s.rdoc_options << '--title' << s.name << '--main' << 'README.rdoc' << '--line-numbers' << '--inline-source'
29
35
  s.extra_rdoc_files = ['README.rdoc']
30
36
 
31
- # Do not change the files and test_files fields by hand. This will be done
32
- # automatically by the gem release script.
33
- s.files = %w(.gitignore .infinity_test .travis.yml Gemfile LICENSE README.rdoc Rakefile ext/oily_png/color.c ext/oily_png/color.h ext/oily_png/extconf.rb ext/oily_png/oily_png_ext.c ext/oily_png/oily_png_ext.h ext/oily_png/operations.c ext/oily_png/operations.h ext/oily_png/png_decoding.c ext/oily_png/png_decoding.h ext/oily_png/png_encoding.c ext/oily_png/png_encoding.h ext/oily_png/resampling.c ext/oily_png/resampling.h lib/oily_png.rb lib/oily_png/canvas.rb oily_png.gemspec spec/color_spec.rb spec/decoding_spec.rb spec/encoding_spec.rb spec/operations_spec.rb spec/resampling_spec.rb spec/resources/basi0g01.png spec/resources/basi0g02.png spec/resources/basi0g04.png spec/resources/basi0g08.png spec/resources/basi0g16.png spec/resources/basi2c08.png spec/resources/basi2c16.png spec/resources/basi3p01.png spec/resources/basi3p02.png spec/resources/basi3p04.png spec/resources/basi3p08.png spec/resources/basi4a08.png spec/resources/basi4a16.png spec/resources/basi6a08.png spec/resources/basi6a16.png spec/resources/basn0g01.png spec/resources/basn0g02.png spec/resources/basn0g04.png spec/resources/basn0g08.png spec/resources/basn0g16.png spec/resources/basn2c08.png spec/resources/basn2c16.png spec/resources/basn3p01.png spec/resources/basn3p02.png spec/resources/basn3p04.png spec/resources/basn3p08.png spec/resources/basn4a08.png spec/resources/basn4a16.png spec/resources/basn6a08.png spec/resources/basn6a16.png spec/resources/composited.png spec/resources/gray.png spec/resources/interlaced.png spec/resources/nonsquare.png spec/resources/operations.png spec/resources/replaced.png spec/resources/s01i3p01.png spec/resources/s01n3p01.png spec/resources/s02i3p01.png spec/resources/s02n3p01.png spec/resources/s03i3p01.png spec/resources/s03n3p01.png spec/resources/s04i3p01.png spec/resources/s04n3p01.png spec/resources/s05i3p02.png spec/resources/s05n3p02.png spec/resources/s06i3p02.png spec/resources/s06n3p02.png spec/resources/s07i3p02.png spec/resources/s07n3p02.png spec/resources/s08i3p02.png spec/resources/s08n3p02.png spec/resources/s09i3p02.png spec/resources/s09n3p02.png spec/resources/s32i3p04.png spec/resources/s32n3p04.png spec/resources/s33i3p04.png spec/resources/s33n3p04.png spec/resources/s34i3p04.png spec/resources/s34n3p04.png spec/resources/s35i3p04.png spec/resources/s35n3p04.png spec/resources/s36i3p04.png spec/resources/s36n3p04.png spec/resources/s37i3p04.png spec/resources/s37n3p04.png spec/resources/s38i3p04.png spec/resources/s38n3p04.png spec/resources/s39i3p04.png spec/resources/s39n3p04.png spec/resources/s40i3p04.png spec/resources/s40n3p04.png spec/resources/square.png spec/resources/tbbn1g04.png spec/resources/tbbn2c16.png spec/resources/tbbn3p08.png spec/resources/tbgn2c16.png spec/resources/tbgn3p08.png spec/resources/tbrn2c08.png spec/resources/tbwn1g16.png spec/resources/tbwn3p08.png spec/resources/tbyn3p08.png spec/resources/tp0n1g08.png spec/resources/tp0n2c08.png spec/resources/tp0n3p08.png spec/resources/tp1n3p08.png spec/spec_helper.rb tasks/github-gem.rake tasks/testing.rake)
34
- s.test_files = %w(spec/color_spec.rb spec/decoding_spec.rb spec/encoding_spec.rb spec/operations_spec.rb spec/resampling_spec.rb)
37
+ s.files = `git ls-files`.split($/)
38
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
35
39
  end
metadata CHANGED
@@ -1,64 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oily_png
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
5
- prerelease:
4
+ version: 1.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Willem van Bergen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-15 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: chunky_png
16
- requirement: &70329825895620 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 1.2.7
19
+ version: 1.3.0
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70329825895620
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.0
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: rake
27
- requirement: &70329825894740 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *70329825894740
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rake-compiler
38
- requirement: &70329825892520 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - ">="
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *70329825892520
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: rspec
49
- requirement: &70329825890860 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ~>
59
+ - - "~>"
53
60
  - !ruby/object:Gem::Version
54
61
  version: '2'
55
62
  type: :development
56
63
  prerelease: false
57
- version_requirements: *70329825890860
58
- description: ! ' This Ruby C extenstion defines a module that can be included into
59
- ChunkyPNG to improve its speed.
60
-
61
- '
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ description: |2
70
+ This Ruby C extenstion defines a module that can be included into ChunkyPNG to improve its speed.
62
71
  email:
63
72
  - willem@railsdoctors.com
64
73
  executables: []
@@ -67,9 +76,8 @@ extensions:
67
76
  extra_rdoc_files:
68
77
  - README.rdoc
69
78
  files:
70
- - .gitignore
71
- - .infinity_test
72
- - .travis.yml
79
+ - ".gitignore"
80
+ - ".travis.yml"
73
81
  - Gemfile
74
82
  - LICENSE
75
83
  - README.rdoc
@@ -89,6 +97,7 @@ files:
89
97
  - ext/oily_png/resampling.h
90
98
  - lib/oily_png.rb
91
99
  - lib/oily_png/canvas.rb
100
+ - lib/oily_png/version.rb
92
101
  - oily_png.gemspec
93
102
  - spec/color_spec.rb
94
103
  - spec/decoding_spec.rb
@@ -182,38 +191,37 @@ files:
182
191
  - spec/resources/tp0n3p08.png
183
192
  - spec/resources/tp1n3p08.png
184
193
  - spec/spec_helper.rb
185
- - tasks/github-gem.rake
186
194
  - tasks/testing.rake
187
195
  homepage: http://wiki.github.com/wvanbergen/oily_png
188
- licenses: []
196
+ licenses:
197
+ - MIT
198
+ metadata: {}
189
199
  post_install_message:
190
200
  rdoc_options:
191
- - --title
201
+ - "--title"
192
202
  - oily_png
193
- - --main
203
+ - "--main"
194
204
  - README.rdoc
195
- - --line-numbers
196
- - --inline-source
205
+ - "--line-numbers"
206
+ - "--inline-source"
197
207
  require_paths:
198
208
  - lib
199
209
  - ext
200
210
  required_ruby_version: !ruby/object:Gem::Requirement
201
- none: false
202
211
  requirements:
203
- - - ! '>='
212
+ - - ">="
204
213
  - !ruby/object:Gem::Version
205
214
  version: '0'
206
215
  required_rubygems_version: !ruby/object:Gem::Requirement
207
- none: false
208
216
  requirements:
209
- - - ! '>='
217
+ - - ">="
210
218
  - !ruby/object:Gem::Version
211
219
  version: '0'
212
220
  requirements: []
213
221
  rubyforge_project: oily_png
214
- rubygems_version: 1.8.16
222
+ rubygems_version: 2.2.0
215
223
  signing_key:
216
- specification_version: 3
224
+ specification_version: 4
217
225
  summary: Native mixin to speed up ChunkyPNG
218
226
  test_files:
219
227
  - spec/color_spec.rb
@@ -221,3 +229,90 @@ test_files:
221
229
  - spec/encoding_spec.rb
222
230
  - spec/operations_spec.rb
223
231
  - spec/resampling_spec.rb
232
+ - spec/resources/basi0g01.png
233
+ - spec/resources/basi0g02.png
234
+ - spec/resources/basi0g04.png
235
+ - spec/resources/basi0g08.png
236
+ - spec/resources/basi0g16.png
237
+ - spec/resources/basi2c08.png
238
+ - spec/resources/basi2c16.png
239
+ - spec/resources/basi3p01.png
240
+ - spec/resources/basi3p02.png
241
+ - spec/resources/basi3p04.png
242
+ - spec/resources/basi3p08.png
243
+ - spec/resources/basi4a08.png
244
+ - spec/resources/basi4a16.png
245
+ - spec/resources/basi6a08.png
246
+ - spec/resources/basi6a16.png
247
+ - spec/resources/basn0g01.png
248
+ - spec/resources/basn0g02.png
249
+ - spec/resources/basn0g04.png
250
+ - spec/resources/basn0g08.png
251
+ - spec/resources/basn0g16.png
252
+ - spec/resources/basn2c08.png
253
+ - spec/resources/basn2c16.png
254
+ - spec/resources/basn3p01.png
255
+ - spec/resources/basn3p02.png
256
+ - spec/resources/basn3p04.png
257
+ - spec/resources/basn3p08.png
258
+ - spec/resources/basn4a08.png
259
+ - spec/resources/basn4a16.png
260
+ - spec/resources/basn6a08.png
261
+ - spec/resources/basn6a16.png
262
+ - spec/resources/composited.png
263
+ - spec/resources/gray.png
264
+ - spec/resources/interlaced.png
265
+ - spec/resources/nonsquare.png
266
+ - spec/resources/operations.png
267
+ - spec/resources/replaced.png
268
+ - spec/resources/s01i3p01.png
269
+ - spec/resources/s01n3p01.png
270
+ - spec/resources/s02i3p01.png
271
+ - spec/resources/s02n3p01.png
272
+ - spec/resources/s03i3p01.png
273
+ - spec/resources/s03n3p01.png
274
+ - spec/resources/s04i3p01.png
275
+ - spec/resources/s04n3p01.png
276
+ - spec/resources/s05i3p02.png
277
+ - spec/resources/s05n3p02.png
278
+ - spec/resources/s06i3p02.png
279
+ - spec/resources/s06n3p02.png
280
+ - spec/resources/s07i3p02.png
281
+ - spec/resources/s07n3p02.png
282
+ - spec/resources/s08i3p02.png
283
+ - spec/resources/s08n3p02.png
284
+ - spec/resources/s09i3p02.png
285
+ - spec/resources/s09n3p02.png
286
+ - spec/resources/s32i3p04.png
287
+ - spec/resources/s32n3p04.png
288
+ - spec/resources/s33i3p04.png
289
+ - spec/resources/s33n3p04.png
290
+ - spec/resources/s34i3p04.png
291
+ - spec/resources/s34n3p04.png
292
+ - spec/resources/s35i3p04.png
293
+ - spec/resources/s35n3p04.png
294
+ - spec/resources/s36i3p04.png
295
+ - spec/resources/s36n3p04.png
296
+ - spec/resources/s37i3p04.png
297
+ - spec/resources/s37n3p04.png
298
+ - spec/resources/s38i3p04.png
299
+ - spec/resources/s38n3p04.png
300
+ - spec/resources/s39i3p04.png
301
+ - spec/resources/s39n3p04.png
302
+ - spec/resources/s40i3p04.png
303
+ - spec/resources/s40n3p04.png
304
+ - spec/resources/square.png
305
+ - spec/resources/tbbn1g04.png
306
+ - spec/resources/tbbn2c16.png
307
+ - spec/resources/tbbn3p08.png
308
+ - spec/resources/tbgn2c16.png
309
+ - spec/resources/tbgn3p08.png
310
+ - spec/resources/tbrn2c08.png
311
+ - spec/resources/tbwn1g16.png
312
+ - spec/resources/tbwn3p08.png
313
+ - spec/resources/tbyn3p08.png
314
+ - spec/resources/tp0n1g08.png
315
+ - spec/resources/tp0n2c08.png
316
+ - spec/resources/tp0n3p08.png
317
+ - spec/resources/tp1n3p08.png
318
+ - spec/spec_helper.rb
@@ -1,23 +0,0 @@
1
- infinity_test do
2
-
3
- use :rubies => %w(1.8.6 1.8.7 1.9.2 ree rbx), :test_framework => :rspec
4
-
5
- before(:each_ruby) do |environment|
6
- environment.system('bundle install')
7
- environment.system('rake compile')
8
- end
9
-
10
- after(:each_ruby) do |environment|
11
- environment.system("rake clean_and_clobber_without_verbose")
12
- end
13
-
14
- heuristics do
15
- add("^ext/*/(.*)\.c") do |file|
16
- run :all => :tests
17
- end
18
-
19
- add("^ext/*/(.*)\.h") do |file|
20
- run :all => :tests
21
- end
22
- end
23
- end
@@ -1,367 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'rake/tasklib'
4
- require 'date'
5
- require 'set'
6
-
7
- module GithubGem
8
-
9
- # Detects the gemspc file of this project using heuristics.
10
- def self.detect_gemspec_file
11
- FileList['*.gemspec'].first
12
- end
13
-
14
- # Detects the main include file of this project using heuristics
15
- def self.detect_main_include
16
- if File.exist?(File.expand_path("../lib/#{File.basename(detect_gemspec_file, '.gemspec').gsub(/-/, '/')}.rb", detect_gemspec_file))
17
- "lib/#{File.basename(detect_gemspec_file, '.gemspec').gsub(/-/, '/')}.rb"
18
- elsif FileList['lib/*.rb'].length == 1
19
- FileList['lib/*.rb'].first
20
- else
21
- nil
22
- end
23
- end
24
-
25
- class RakeTasks
26
-
27
- include Rake::DSL if Rake.const_defined?('DSL')
28
-
29
- attr_reader :gemspec, :modified_files
30
- attr_accessor :gemspec_file, :task_namespace, :main_include, :root_dir, :spec_pattern, :test_pattern, :remote, :remote_branch, :local_branch
31
-
32
- # Initializes the settings, yields itself for configuration
33
- # and defines the rake tasks based on the gemspec file.
34
- def initialize(task_namespace = :gem)
35
- @gemspec_file = GithubGem.detect_gemspec_file
36
- @task_namespace = task_namespace
37
- @main_include = GithubGem.detect_main_include
38
- @modified_files = Set.new
39
- @root_dir = Dir.pwd
40
- @test_pattern = 'test/**/*_test.rb'
41
- @spec_pattern = 'spec/**/*_spec.rb'
42
- @local_branch = 'master'
43
- @remote = 'origin'
44
- @remote_branch = 'master'
45
-
46
- yield(self) if block_given?
47
-
48
- load_gemspec!
49
- define_tasks!
50
- end
51
-
52
- protected
53
-
54
- def git
55
- @git ||= ENV['GIT'] || 'git'
56
- end
57
-
58
- # Define Unit test tasks
59
- def define_test_tasks!
60
- require 'rake/testtask'
61
-
62
- namespace(:test) do
63
- Rake::TestTask.new(:basic) do |t|
64
- t.pattern = test_pattern
65
- t.verbose = true
66
- t.libs << 'test'
67
- end
68
- end
69
-
70
- desc "Run all unit tests for #{gemspec.name}"
71
- task(:test => ['test:basic'])
72
- end
73
-
74
- # Defines RSpec tasks
75
- def define_rspec_tasks!
76
- require 'rspec/core/rake_task'
77
-
78
- namespace(:spec) do
79
- desc "Verify all RSpec examples for #{gemspec.name}"
80
- RSpec::Core::RakeTask.new(:basic) do |t|
81
- t.pattern = spec_pattern
82
- end
83
-
84
- desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
85
- RSpec::Core::RakeTask.new(:specdoc) do |t|
86
- t.pattern = spec_pattern
87
- t.rspec_opts = ['--format', 'documentation', '--color']
88
- end
89
-
90
- desc "Run RCov on specs for #{gemspec.name}"
91
- RSpec::Core::RakeTask.new(:rcov) do |t|
92
- t.pattern = spec_pattern
93
- t.rcov = true
94
- t.rcov_opts = ['--exclude', '"spec/*,gems/*"', '--rails']
95
- end
96
- end
97
-
98
- desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
99
- task(:spec => ['spec:specdoc'])
100
- end
101
-
102
- # Defines the rake tasks
103
- def define_tasks!
104
-
105
- define_test_tasks! if has_tests?
106
- define_rspec_tasks! if has_specs?
107
-
108
- namespace(@task_namespace) do
109
- desc "Updates the filelist in the gemspec file"
110
- task(:manifest) { manifest_task }
111
-
112
- desc "Builds the .gem package"
113
- task(:build => :manifest) { build_task }
114
-
115
- desc "Sets the version of the gem in the gemspec"
116
- task(:set_version => [:check_version, :check_current_branch]) { version_task }
117
- task(:check_version => :fetch_origin) { check_version_task }
118
-
119
- task(:fetch_origin) { fetch_origin_task }
120
- task(:check_current_branch) { check_current_branch_task }
121
- task(:check_clean_status) { check_clean_status_task }
122
- task(:check_not_diverged => :fetch_origin) { check_not_diverged_task }
123
-
124
- checks = [:check_current_branch, :check_clean_status, :check_not_diverged, :check_version]
125
- checks.unshift('spec:basic') if has_specs?
126
- checks.unshift('test:basic') if has_tests?
127
- # checks.push << [:check_rubyforge] if gemspec.rubyforge_project
128
-
129
- desc "Perform all checks that would occur before a release"
130
- task(:release_checks => checks)
131
-
132
- release_tasks = [:release_checks, :set_version, :build, :github_release, :gemcutter_release]
133
- # release_tasks << [:rubyforge_release] if gemspec.rubyforge_project
134
-
135
- desc "Release a new version of the gem using the VERSION environment variable"
136
- task(:release => release_tasks) { release_task }
137
-
138
- namespace(:release) do
139
- desc "Release the next version of the gem, by incrementing the last version segment by 1"
140
- task(:next => [:next_version] + release_tasks) { release_task }
141
-
142
- desc "Release the next version of the gem, using a patch increment (0.0.1)"
143
- task(:patch => [:next_patch_version] + release_tasks) { release_task }
144
-
145
- desc "Release the next version of the gem, using a minor increment (0.1.0)"
146
- task(:minor => [:next_minor_version] + release_tasks) { release_task }
147
-
148
- desc "Release the next version of the gem, using a major increment (1.0.0)"
149
- task(:major => [:next_major_version] + release_tasks) { release_task }
150
- end
151
-
152
- # task(:check_rubyforge) { check_rubyforge_task }
153
- # task(:rubyforge_release) { rubyforge_release_task }
154
- task(:gemcutter_release) { gemcutter_release_task }
155
- task(:github_release => [:commit_modified_files, :tag_version]) { github_release_task }
156
- task(:tag_version) { tag_version_task }
157
- task(:commit_modified_files) { commit_modified_files_task }
158
-
159
- task(:next_version) { next_version_task }
160
- task(:next_patch_version) { next_version_task(:patch) }
161
- task(:next_minor_version) { next_version_task(:minor) }
162
- task(:next_major_version) { next_version_task(:major) }
163
-
164
- desc "Updates the gem release tasks with the latest version on Github"
165
- task(:update_tasks) { update_tasks_task }
166
- end
167
- end
168
-
169
- # Updates the files list and test_files list in the gemspec file using the list of files
170
- # in the repository and the spec/test file pattern.
171
- def manifest_task
172
- # Load all the gem's files using "git ls-files"
173
- repository_files = `#{git} ls-files`.split("\n")
174
- test_files = Dir[test_pattern] + Dir[spec_pattern]
175
-
176
- update_gemspec(:files, repository_files)
177
- update_gemspec(:test_files, repository_files & test_files)
178
- end
179
-
180
- # Builds the gem
181
- def build_task
182
- sh "gem build -q #{gemspec_file}"
183
- Dir.mkdir('pkg') unless File.exist?('pkg')
184
- sh "mv #{gemspec.name}-#{gemspec.version}.gem pkg/#{gemspec.name}-#{gemspec.version}.gem"
185
- end
186
-
187
- def newest_version
188
- `#{git} tag`.split("\n").map { |tag| tag.split('-').last }.compact.map { |v| Gem::Version.new(v) }.max || Gem::Version.new('0.0.0')
189
- end
190
-
191
- def next_version(increment = nil)
192
- next_version = newest_version.segments
193
- increment_index = case increment
194
- when :micro then 3
195
- when :patch then 2
196
- when :minor then 1
197
- when :major then 0
198
- else next_version.length - 1
199
- end
200
-
201
- next_version[increment_index] ||= 0
202
- next_version[increment_index] = next_version[increment_index].succ
203
- ((increment_index + 1)...next_version.length).each { |i| next_version[i] = 0 }
204
-
205
- Gem::Version.new(next_version.join('.'))
206
- end
207
-
208
- def next_version_task(increment = nil)
209
- ENV['VERSION'] = next_version(increment).version
210
- puts "Releasing version #{ENV['VERSION']}..."
211
- end
212
-
213
- # Updates the version number in the gemspec file, the VERSION constant in the main
214
- # include file and the contents of the VERSION file.
215
- def version_task
216
- update_gemspec(:version, ENV['VERSION']) if ENV['VERSION']
217
- update_gemspec(:date, Date.today)
218
-
219
- update_version_file(gemspec.version)
220
- update_version_constant(gemspec.version)
221
- end
222
-
223
- def check_version_task
224
- raise "#{ENV['VERSION']} is not a valid version number!" if ENV['VERSION'] && !Gem::Version.correct?(ENV['VERSION'])
225
- proposed_version = Gem::Version.new((ENV['VERSION'] || gemspec.version).dup)
226
- raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version >= proposed_version
227
- end
228
-
229
- # Checks whether the current branch is not diverged from the remote branch
230
- def check_not_diverged_task
231
- raise "The current branch is diverged from the remote branch!" if `#{git} rev-list HEAD..#{remote}/#{remote_branch}`.split("\n").any?
232
- end
233
-
234
- # Checks whether the repository status ic clean
235
- def check_clean_status_task
236
- raise "The current working copy contains modifications" if `#{git} ls-files -m`.split("\n").any?
237
- end
238
-
239
- # Checks whether the current branch is correct
240
- def check_current_branch_task
241
- raise "Currently not on #{local_branch} branch!" unless `#{git} branch`.split("\n").detect { |b| /^\* / =~ b } == "* #{local_branch}"
242
- end
243
-
244
- # Fetches the latest updates from Github
245
- def fetch_origin_task
246
- sh git, 'fetch', remote
247
- end
248
-
249
- # Commits every file that has been changed by the release task.
250
- def commit_modified_files_task
251
- really_modified = `#{git} ls-files -m #{modified_files.entries.join(' ')}`.split("\n")
252
- if really_modified.any?
253
- really_modified.each { |file| sh git, 'add', file }
254
- sh git, 'commit', '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
255
- end
256
- end
257
-
258
- # Adds a tag for the released version
259
- def tag_version_task
260
- sh git, 'tag', '-a', "#{gemspec.name}-#{gemspec.version}", '-m', "Released #{gemspec.name} gem version #{gemspec.version}."
261
- end
262
-
263
- # Pushes the changes and tag to github
264
- def github_release_task
265
- sh git, 'push', '--tags', remote, remote_branch
266
- end
267
-
268
- def gemcutter_release_task
269
- sh "gem", 'push', "pkg/#{gemspec.name}-#{gemspec.version}.gem"
270
- end
271
-
272
- # Gem release task.
273
- # All work is done by the task's dependencies, so just display a release completed message.
274
- def release_task
275
- puts
276
- puts "Release successful."
277
- end
278
-
279
- private
280
-
281
- # Checks whether this project has any RSpec files
282
- def has_specs?
283
- FileList[spec_pattern].any?
284
- end
285
-
286
- # Checks whether this project has any unit test files
287
- def has_tests?
288
- FileList[test_pattern].any?
289
- end
290
-
291
- # Loads the gemspec file
292
- def load_gemspec!
293
- @gemspec = eval(File.read(@gemspec_file))
294
- end
295
-
296
- # Updates the VERSION file with the new version
297
- def update_version_file(version)
298
- if File.exists?('VERSION')
299
- File.open('VERSION', 'w') { |f| f << version.to_s }
300
- modified_files << 'VERSION'
301
- end
302
- end
303
-
304
- # Updates the VERSION constant in the main include file if it exists
305
- def update_version_constant(version)
306
- if main_include && File.exist?(main_include)
307
- file_contents = File.read(main_include)
308
- if file_contents.sub!(/^(\s+VERSION\s*=\s*)[^\s].*$/) { $1 + version.to_s.inspect }
309
- File.open(main_include, 'w') { |f| f << file_contents }
310
- modified_files << main_include
311
- end
312
- end
313
- end
314
-
315
- # Updates an attribute of the gemspec file.
316
- # This function will open the file, and search/replace the attribute using a regular expression.
317
- def update_gemspec(attribute, new_value, literal = false)
318
-
319
- unless literal
320
- new_value = case new_value
321
- when Array then "%w(#{new_value.join(' ')})"
322
- when Hash, String then new_value.inspect
323
- when Date then new_value.strftime('%Y-%m-%d').inspect
324
- else raise "Cannot write value #{new_value.inspect} to gemspec file!"
325
- end
326
- end
327
-
328
- spec = File.read(gemspec_file)
329
- regexp = Regexp.new('^(\s+\w+\.' + Regexp.quote(attribute.to_s) + '\s*=\s*)[^\s].*$')
330
- if spec.sub!(regexp) { $1 + new_value }
331
- File.open(gemspec_file, 'w') { |f| f << spec }
332
- modified_files << gemspec_file
333
-
334
- # Reload the gemspec so the changes are incorporated
335
- load_gemspec!
336
-
337
- # Also mark the Gemfile.lock file as changed because of the new version.
338
- modified_files << 'Gemfile.lock' if File.exist?(File.join(root_dir, 'Gemfile.lock'))
339
- end
340
- end
341
-
342
- # Updates the tasks file using the latest file found on Github
343
- def update_tasks_task
344
- require 'net/https'
345
- require 'uri'
346
-
347
- uri = URI.parse('https://raw.github.com/wvanbergen/github-gem/master/tasks/github-gem.rake')
348
- http = Net::HTTP.new(uri.host, uri.port)
349
- http.use_ssl = true
350
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
351
- response = http.request(Net::HTTP::Get.new(uri.path))
352
-
353
- if Net::HTTPSuccess === response
354
- open(__FILE__, "w") { |file| file.write(response.body) }
355
- relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
356
- if `#{git} ls-files -m #{relative_file}`.split("\n").any?
357
- sh git, 'add', relative_file
358
- sh git, 'commit', '-m', "Updated to latest gem release management tasks."
359
- else
360
- puts "Release managament tasks already are at the latest version."
361
- end
362
- else
363
- raise "Download failed with HTTP status #{response.code}!"
364
- end
365
- end
366
- end
367
- end