cb-ffi-proj4 0.0.3 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Rakefile +14 -5
  2. data/VERSION +1 -1
  3. data/lib/ffi-proj4.rb +34 -13
  4. data/test/test_helper.rb +1 -1
  5. metadata +30 -41
data/Rakefile CHANGED
@@ -2,9 +2,17 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'rubygems'
5
- require 'rake/gempackagetask'
5
+ require 'rubygems/package_task'
6
6
  require 'rake/testtask'
7
- require 'rake/rdoctask'
7
+ require 'rdoc/task'
8
+
9
+ if RUBY_VERSION >= '1.9'
10
+ begin
11
+ gem 'psych'
12
+ rescue Exception => e
13
+ # it's okay, fall back on the bundled psych
14
+ end
15
+ end
8
16
 
9
17
  $:.push 'lib'
10
18
 
@@ -19,6 +27,7 @@ begin
19
27
  gem.email = "dark.panda@gmail.com"
20
28
  gem.homepage = "http://github.com/dark-panda/ffi-proj4"
21
29
  gem.authors = [ "J Smith" ]
30
+ gem.add_dependency "ffi", "~> 1.0.0"
22
31
  end
23
32
  Jeweler::GemcutterTasks.new
24
33
  rescue LoadError
@@ -27,15 +36,15 @@ end
27
36
 
28
37
  desc 'Test GEOS interface'
29
38
  Rake::TestTask.new(:test) do |t|
30
- t.pattern = 'test/**/*_tests.rb'
39
+ t.test_files = FileList['test/**/*_tests.rb']
31
40
  t.verbose = !!ENV['VERBOSE_TESTS']
32
41
  end
33
42
 
34
43
  desc 'Build docs'
35
44
  Rake::RDocTask.new do |t|
36
- require 'rdoc/rdoc'
45
+ require 'rdoc'
37
46
  t.title ="ffi-proj4 #{version}"
38
47
  t.main = 'README.rdoc'
39
48
  t.rdoc_dir = 'doc'
40
- t.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'lib/**/*.rb')
49
+ t.rdoc_files.include('MIT-LICENSE', 'lib/**/*.rb')
41
50
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.6
data/lib/ffi-proj4.rb CHANGED
@@ -3,6 +3,9 @@ require 'rubygems'
3
3
  require 'ffi'
4
4
  require 'rbconfig'
5
5
 
6
+ #ENV['PROJ_LIB'] = File.join(File.dirname(__FILE__), %w{ .. data }) unless ENV['PROJ_LIB']
7
+ #p ENV['PROJ_LIB']
8
+
6
9
  module Proj4
7
10
  PROJ4_BASE = File.join(File.dirname(__FILE__), 'ffi-proj4')
8
11
 
@@ -17,7 +20,7 @@ module Proj4
17
20
 
18
21
  module FFIProj4
19
22
  def self.proj4_library_path
20
- return @proj4_library_paths if @proj4_library_paths
23
+ return @proj4_library_path if @proj4_library_path
21
24
 
22
25
  paths = if ENV['PROJ4_LIBRARY_PATH']
23
26
  [ ENV['PROJ4_LIBRARY_PATH'] ]
@@ -25,23 +28,26 @@ module Proj4
25
28
  [ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}' ]
26
29
  end
27
30
 
28
- lib = if [
29
- Config::CONFIG['arch'],
30
- Config::CONFIG['host_os']
31
- ].detect { |c| c =~ /darwin/ }
31
+ lib = if FFI::Platform::IS_MAC
32
32
  'libproj.dylib'
33
+ elsif FFI::Platform::IS_WINDOWS
34
+ # For MinGW and the official binaries
35
+ '{libproj-?,proj}.dll'
33
36
  else
34
37
  'libproj.so'
35
38
  end
36
39
 
40
+ paths = if ENV['PROJ4_LIBRARY_PATH']
41
+ [ ENV['PROJ4_LIBRARY_PATH'] ]
42
+ elsif FFI::Platform::IS_WINDOWS
43
+ ENV['PATH'].split(File::PATH_SEPARATOR)
44
+ else
45
+ [ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}' ]
46
+ end
47
+
37
48
  @proj4_library_path = Dir.glob(paths.collect { |path|
38
- "#{path}/#{lib}"
49
+ File.expand_path(File.join(path, lib))
39
50
  }).first
40
-
41
- if Config::CONFIG['host_os'] =~ /win32/
42
- @proj4_library_path = "#{ENV['PROJ4_LIBRARY_PATH'] + '\\' if ENV['PROJ4_LIBRARY_PATH']}proj.dll"
43
- end
44
- @proj4_library_path
45
51
  end
46
52
 
47
53
  extend ::FFI::Library
@@ -115,6 +121,10 @@ module Proj4
115
121
 
116
122
  :pj_datum_transform => [
117
123
  :int, :pointer, :pointer, :long, :int, :pointer, :pointer, :pointer
124
+ ],
125
+
126
+ :setenv => [
127
+ :int, :string, :string, :int
118
128
  ]
119
129
  }
120
130
 
@@ -131,9 +141,20 @@ module Proj4
131
141
  end
132
142
 
133
143
  class << self
144
+ attr_reader :proj_lib
145
+
134
146
  def version
135
147
  FFIProj4.pj_get_release
136
148
  end
149
+
150
+ def proj_lib=(lib)
151
+ @proj_lib = lib
152
+ # if RUBY_PLATFORM == 'java'
153
+ # FFIProj4.setenv('PROJ_LIB', lib, 1)
154
+ # else
155
+ ENV['PROJ_LIB'] = lib
156
+ # end
157
+ end
137
158
  end
138
159
 
139
160
  module Constants
@@ -146,7 +167,7 @@ module Proj4
146
167
  DEG_TO_RAD = 0.0174532925199432958
147
168
  end
148
169
 
149
- ENV['PROJ_LIB'] = File.join(File.dirname(PROJ4_BASE), %w{ data }) unless ENV['PROJ_LIB']
150
-
151
170
  include Constants
171
+
172
+ self.proj_lib = ENV['PROJ_LIB'] || File.join(File.dirname(__FILE__), %w{ .. data })
152
173
  end
data/test/test_helper.rb CHANGED
@@ -14,7 +14,7 @@ puts "PROJ version #{Proj4.version}"
14
14
  if defined?(Proj4::FFIProj4)
15
15
  puts "Using #{Array(Proj4::FFIProj4.proj4_library_path).join(', ')}"
16
16
  end
17
- puts "Using PROJ_LIB #{ENV['PROJ_LIB']}"
17
+ puts "Using PROJ_LIB #{Proj4.proj_lib}"
18
18
 
19
19
  module TestHelper
20
20
  TOLERANCE = 0.00000001
metadata CHANGED
@@ -1,33 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cb-ffi-proj4
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - J Smith
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-06-27 00:00:00 -04:00
19
- default_executable:
20
- dependencies: []
21
-
12
+ date: 2011-12-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ffi
16
+ requirement: &70314475501680 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70314475501680
22
25
  description: An ffi wrapper for the PROJ.4 Cartographic Projections library.
23
26
  email: dark.panda@gmail.com
24
27
  executables: []
25
-
26
28
  extensions: []
27
-
28
29
  extra_rdoc_files: []
29
-
30
- files:
30
+ files:
31
31
  - MIT-LICENSE
32
32
  - Rakefile
33
33
  - VERSION
@@ -62,39 +62,28 @@ files:
62
62
  - test/projection_tests.rb
63
63
  - test/test_helper.rb
64
64
  - test/transformation_tests.rb
65
- has_rdoc: true
66
65
  homepage: http://github.com/dark-panda/ffi-proj4
67
66
  licenses: []
68
-
69
67
  post_install_message:
70
68
  rdoc_options: []
71
-
72
- require_paths:
69
+ require_paths:
73
70
  - lib
74
- required_ruby_version: !ruby/object:Gem::Requirement
71
+ required_ruby_version: !ruby/object:Gem::Requirement
75
72
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- hash: 3
80
- segments:
81
- - 0
82
- version: "0"
83
- required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
78
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
- version: "0"
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
92
83
  requirements: []
93
-
94
84
  rubyforge_project:
95
- rubygems_version: 1.6.2
85
+ rubygems_version: 1.8.10
96
86
  signing_key:
97
87
  specification_version: 3
98
88
  summary: An ffi wrapper for the PROJ.4 Cartographic Projections library.
99
89
  test_files: []
100
-