gd2-ffij 0.2.0 → 0.3.0

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: fa7d138e9bc1811d93f29940223d4ef351cb386e
4
- data.tar.gz: d5d2045cd120680ca95fb4b0fe45f5faab48145b
3
+ metadata.gz: 6aa4ff4f4aa7e5c580dd3c9d464c8c1df57a98a5
4
+ data.tar.gz: 211bf9eef3b61bffe85ec4a2e5a2a97affe26bad
5
5
  SHA512:
6
- metadata.gz: 9874c2866d83776849d4208176df0f0068505cc50b226eea321ace4ae9cfbc06ca0b7f75184e14a3ea332a7dbdf013a069bf9b8439305e061c89e694ece8acf8
7
- data.tar.gz: 792e63569a789cf97722e116b1c65907c7ffee7fa332abe0481d2db952a7297ad5b0c57aab2b0036a1e047527c4c019fb28acac3cb76fcf7260a343dcf858555
6
+ metadata.gz: b7ed5a027a534a36f2b144392aa8e1f1f56e2a3c2e230d31f4d31409353ab8d7a6d7a9846d12d024ccc9d9b892219e8a4e27a48d2a4b7cc641cdfcc3e7efde88
7
+ data.tar.gz: 3b5973311c1080fe04273a0dd4923589f9192b1265fe3e5b2fe607acb648af87001fd7fc54cd72a35a02664a26c23c5db60595182d404f1aabbc9e254092a411
@@ -0,0 +1,20 @@
1
+ dist: precise
2
+ cache: bundler
3
+ sudo: false
4
+ language: ruby
5
+ rvm:
6
+ - 2.4.2
7
+ - 2.3.5
8
+ - 2.2.8
9
+ - rbx-3
10
+ - jruby-head
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: rbx-3
14
+ - rvm: jruby-head
15
+ addons:
16
+ apt:
17
+ packages:
18
+ - libgd2-noxpm
19
+ before_install:
20
+ - wget -q -O - https://www.mongodb.org/static/pgp/server-3.2.pub | sudo apt-key add -
data/COPYRIGHT CHANGED
@@ -16,7 +16,7 @@ See https://github.com/dark-panda/gd2-ffij/issues/10 ("Consider moving back to
16
16
  BSD now that FFI is back to BSD?") for details.
17
17
 
18
18
 
19
- Subsequent code added and modified to create gd2-ffij copyright (C) 2010-2015
19
+ Subsequent code added and modified to create gd2-ffij copyright (C) 2010-2017
20
20
  J Smith <dark.panda@gmail.com> and published under the MIT license as follows:
21
21
 
22
22
  Permission is hereby granted, free of charge, to any person
data/Gemfile CHANGED
@@ -19,7 +19,7 @@ if RUBY_VERSION >= '1.9'
19
19
  gem 'guard-minitest'
20
20
  end
21
21
 
22
- if File.exists?('Gemfile.local')
22
+ if File.exist?('Gemfile.local')
23
23
  instance_eval File.read('Gemfile.local')
24
24
  end
25
25
 
data/Guardfile CHANGED
@@ -11,7 +11,7 @@ guard 'minitest', :test_folders => 'test', :test_file_patterns => '*_tests.rb' d
11
11
  end
12
12
  end
13
13
 
14
- if File.exists?('Guardfile.local')
14
+ if File.exist?('Guardfile.local')
15
15
  instance_eval File.read('Guardfile.local')
16
16
  end
17
17
 
data/Rakefile CHANGED
@@ -12,11 +12,14 @@ version = GD2::VERSION
12
12
 
13
13
  desc 'Test GD2 interface'
14
14
  Rake::TestTask.new(:test) do |t|
15
+ t.libs << "#{File.dirname(__FILE__)}/test"
15
16
  t.test_files = FileList['test/**/*_tests.rb']
16
17
  t.verbose = !!ENV['VERBOSE_TESTS']
17
18
  t.warning = !!ENV['WARNINGS']
18
19
  end
19
20
 
21
+ task :default => :test
22
+
20
23
  desc 'Build docs'
21
24
  Rake::RDocTask.new do |t|
22
25
  t.title = "gd2-ffij #{version}"
@@ -1,4 +1,4 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
  #
3
3
  # See COPYRIGHT for license details.
4
4
 
@@ -1,4 +1,4 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
  #
3
3
  # See COPYRIGHT for license details.
4
4
 
@@ -1,4 +1,4 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
  #
3
3
  # See COPYRIGHT for license details.
4
4
 
@@ -1,4 +1,4 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
  #
3
3
  # See COPYRIGHT for license details.
4
4
 
@@ -1,4 +1,4 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
  #
3
3
  # See COPYRIGHT for license details.
4
4
 
@@ -1,4 +1,4 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
  #
3
3
  # See COPYRIGHT for license details.
4
4
 
@@ -44,6 +44,7 @@ module GD2
44
44
  #
45
45
  class Image
46
46
  class UnrecognizedImageTypeError < StandardError; end
47
+ class MemoryAllocationError < StandardError; end
47
48
 
48
49
  attr_reader :image_ptr #:nodoc:
49
50
 
@@ -138,7 +139,7 @@ module GD2
138
139
  # part of the image. Use options :x, :y, :width, and :height to specify the
139
140
  # part of the image to import.
140
141
  def self.import(filename, options = {})
141
- raise Errno::ENOENT.new(filename) unless File.exists?(filename)
142
+ raise Errno::ENOENT.new(filename) unless File.exist?(filename)
142
143
 
143
144
  unless format = options.delete(:format)
144
145
  md = filename.match(/\.([^.]+)\z/)
@@ -203,7 +204,16 @@ module GD2
203
204
  private_class_method :image_true_color?
204
205
 
205
206
  def self.create_image_ptr(sx, sy, alpha_blending = true) #:nodoc:
206
- ptr = FFIStruct::ImagePtr.new(::GD2::GD2FFI.send(create_image_sym, sx.to_i, sy.to_i))
207
+ x = sx.to_i
208
+ y = sy.to_i
209
+
210
+ raise ArgumentError, "sx must be > 0" unless x.positive?
211
+ raise ArgumentError, "sy must be > 0" unless y.positive?
212
+
213
+ ptr = FFIStruct::ImagePtr.new(::GD2::GD2FFI.send(create_image_sym, x, y))
214
+
215
+ raise MemoryAllocationError, "Could not allocation memory for image" if ptr.null?
216
+
207
217
  ::GD2::GD2FFI.send(:gdImageAlphaBlending, ptr, alpha_blending ? 1 : 0)
208
218
  ptr
209
219
  end
@@ -1,4 +1,4 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
  #
3
3
  # See COPYRIGHT for license details.
4
4
 
@@ -1,6 +1,6 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
 
3
3
  module GD2
4
- VERSION = "0.2.0"
4
+ VERSION = '0.3.0'.freeze
5
5
  end
6
6
 
@@ -1,8 +1,8 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
 
3
3
  require './test/test_helper'
4
4
 
5
- class CanvasTest < MiniTest::Unit::TestCase
5
+ class CanvasTest < Minitest::Test
6
6
  include TestHelper
7
7
 
8
8
  def test_line
@@ -1,10 +1,36 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
 
3
3
  require './test/test_helper'
4
4
 
5
- class ImageTest < MiniTest::Unit::TestCase
5
+ class ImageTest < Minitest::Test
6
6
  include TestHelper
7
7
 
8
+ def test_invalid_image_sizes
9
+ assert_raises(ArgumentError) do
10
+ GD2::Image.new(-10, 10)
11
+ end
12
+
13
+ assert_raises(ArgumentError) do
14
+ GD2::Image.new(0, 10)
15
+ end
16
+
17
+ assert_raises(ArgumentError) do
18
+ GD2::Image.new(10, -10)
19
+ end
20
+
21
+ assert_raises(ArgumentError) do
22
+ GD2::Image.new(10, 0)
23
+ end
24
+
25
+ assert_raises(GD2::Image::MemoryAllocationError) do
26
+ n_bytes = [42].pack('i').size
27
+ n_bits = n_bytes * 8
28
+ max = 2 ** (n_bits - 2) - 1
29
+
30
+ GD2::Image.new(max, max)
31
+ end
32
+ end
33
+
8
34
  def test_image_new_and_release
9
35
  GD2::Image.new(50, 50)
10
36
  end
@@ -41,7 +67,7 @@ class ImageTest < MiniTest::Unit::TestCase
41
67
  out = File.join(Dir.tmpdir, 'test.#{ext}')
42
68
  img.export(out)
43
69
 
44
- assert(File.exists?(out))
70
+ assert(File.exist?(out))
45
71
 
46
72
  imgA = GD2::Image.import(out)
47
73
  imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
Binary file
@@ -1,4 +1,4 @@
1
- # encoding: ASCII-8BIT
1
+ # frozen_string_literal: true; encoding: ASCII-8BIT
2
2
 
3
3
  if RUBY_VERSION >= '1.9'
4
4
  require 'simplecov'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gd2-ffij
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-02 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -32,6 +32,7 @@ extra_rdoc_files:
32
32
  - README.rdoc
33
33
  files:
34
34
  - ".gitignore"
35
+ - ".travis.yml"
35
36
  - COPYRIGHT
36
37
  - Gemfile
37
38
  - Guardfile
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  version: '0'
109
110
  requirements: []
110
111
  rubyforge_project:
111
- rubygems_version: 2.4.6
112
+ rubygems_version: 2.6.13
112
113
  signing_key:
113
114
  specification_version: 4
114
115
  summary: gd2-ffij is a refactoring of the Ruby/GD2 library implemented with FFI