kakasi 1.0.0 → 1.0.1

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: 1e7c7cc9b276f00033e2586df340602f1ea7612a
4
- data.tar.gz: 751cc756a4096e797e9654ce03d17fd89be64f0b
3
+ metadata.gz: d07c817b6d00ce7eb000d93d9e9762b792ace073
4
+ data.tar.gz: b8130607990cd6249715a192ae7e4bed52ddf31a
5
5
  SHA512:
6
- metadata.gz: 8f541fdd5d2da31548f83f80238a8f9a4f89075f238f76c2e3f4e5feb6aeac6b857fbc341eefc02d3e3740a601a919bc0a12471b89a0609879a51af3b9ff204f
7
- data.tar.gz: 153726de54a4ae4778528988f270f8b0b38cd79960263c770fb57f827cf48b4819d0327fda9a48e030b34c5111e51f2430e27b5e7f3e97180ebe7ee2a4cea61b
6
+ metadata.gz: 48184c68e9d538bd79ffd63b8e8413b4f3f71ad8538db2cb523ec12e888ad2aa822101d5bc1d1c66b1784451e641670f5fc3f450452ec406bf9774d60e36b84e
7
+ data.tar.gz: 91d0cc0e73b284d0baff1eccfbf02d0613b2a5f16adeab3a131295354b64f859066aa40a5719d7594179a5712b4b22bd150eb77dc26d6506ff27a6faada67f9e
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ ---
2
+ language: ruby
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.2
7
+ - ruby-head
8
+ - jruby-19mode
9
+ - jruby-head
10
+ - rbx-2
11
+ script: rake test
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: ruby-head
15
+ - rvm: jruby-head
16
+ before_install:
17
+ - sudo apt-get update -qq
18
+ - sudo apt-get install -y libkakasi2 libkakasi2-dev
19
+ before_script:
20
+ - rake compile
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Akinori MUSHA
1
+ Copyright (c) 2013, 2014 Akinori MUSHA
2
2
 
3
3
  All rights reserved.
4
4
 
data/Rakefile CHANGED
@@ -18,3 +18,12 @@ Rake::RDocTask.new do |rdoc|
18
18
  end
19
19
 
20
20
  task :default => :test
21
+
22
+ task :compile do
23
+ gemspec.extensions.each { |ext|
24
+ dir, extconf = File.split(ext)
25
+ chdir(dir) {
26
+ ruby extconf
27
+ }
28
+ }
29
+ end
@@ -19,7 +19,11 @@ module KakasiExtConf
19
19
  },
20
20
 
21
21
  ffi: ->{
22
- require 'ffi'
22
+ if defined?(Rubinius)
23
+ FFI = Rubinius::FFI
24
+ else
25
+ require 'ffi'
26
+ end
23
27
  extend FFI::Library
24
28
  },
25
29
  }.find { |impl, code|
@@ -36,46 +40,31 @@ module KakasiExtConf
36
40
 
37
41
  print 'checking for kakasi... '
38
42
 
39
- libkakasi = Enumerator.new { |y|
40
- libfilename = RbConfig::CONFIG['LIBRUBY_SO'].tap { |so|
41
- prefix = so[/\A(?:lib|)/]
42
- suffix = so[/\.(?![0-9]+(?:\.|\z))[^.]+/] or raise 'failed to detect the file extension for dynamic libraries'
43
- break prefix + 'kakasi' + suffix
44
- }
43
+ require '../../lib/kakasi/platform.rb'
45
44
 
46
- $LIBPATH.each { |dir|
47
- y << File.join(dir, libfilename)
48
- }
49
- y << 'kakasi'
50
- y << 'libkakasi'
51
- y << libfilename
52
- }.find { |lib|
53
- begin
45
+ begin
46
+ libkakasi = Kakasi::Lib.try_load($LIBPATH) { |lib|
54
47
  case default_impl
55
48
  when :fiddle, :dl
56
49
  dlload lib
57
50
  when :ffi
58
51
  ffi_lib lib
59
52
  else
60
- next false
53
+ raise LoadError, 'NOTREACHED'
61
54
  end
62
- puts lib
63
- true
64
- rescue LoadError, StandardError
65
- false
66
- end
67
- } or
68
- begin
69
- puts 'FAILED!'
70
- exit false
71
- end
55
+ }
56
+ puts libkakasi
57
+ rescue LoadError
58
+ puts 'FAILED!'
59
+ exit false
60
+ end
72
61
 
73
62
  '../../lib/kakasi/config.rb'.tap { |rb|
74
63
  puts 'creating %s' % rb
75
64
  File.open(File.expand_path(rb, File.dirname(__FILE__)), 'wt') { |f|
76
- f.print <<-'EOF' % [libkakasi.inspect, default_impl.inspect]
65
+ f.print <<-'EOF' % [$LIBPATH.inspect, default_impl.inspect]
77
66
  module Kakasi
78
- LIBKAKASI = %s unless defined?(LIBKAKASI)
67
+ LIBPATH = %s unless defined?(LIBPATH)
79
68
  IMPL = %s unless defined?(IMPL)
80
69
  end
81
70
  EOF
data/kakasi.gemspec CHANGED
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "rake"
30
30
  spec.add_development_dependency "rdoc", ["> 2.4.2"]
31
31
  spec.add_development_dependency "bundler", [">= 1.2"]
32
+ spec.add_development_dependency "test-unit"
32
33
  end
data/lib/kakasi.rb CHANGED
@@ -3,19 +3,14 @@ require 'kakasi/version'
3
3
  module Kakasi
4
4
  case RUBY_ENGINE
5
5
  when 'jruby'
6
- LIBKAKASI = 'kakasi' unless defined?(LIBKAKASI)
7
- IMPL = :ffi unless defined?(IMPL)
6
+ LIBPATH = [].freeze
7
+ IMPL = :ffi unless defined?(::Kakasi::IMPL)
8
8
  else
9
9
  begin
10
10
  require 'kakasi/config'
11
11
  rescue LoadError
12
- require 'rbconfig'
13
- LIBKAKASI = RbConfig::CONFIG['LIBRUBY_SO'].tap { |so|
14
- prefix = so[/\A(?:lib|)/]
15
- suffix = so[/\.(?![0-9]+(?:\.|\z))[^.]+/] or raise 'failed to detect the file extension for dynamic libraries'
16
- break prefix + 'kakasi' + suffix
17
- } unless defined?(LIBKAKASI)
18
- IMPL = :ffi unless defined?(IMPL)
12
+ LIBPATH = [].freeze
13
+ IMPL = :ffi unless defined?(::Kakasi::IMPL)
19
14
  end
20
15
  end
21
16
 
data/lib/kakasi/ffi.rb CHANGED
@@ -7,7 +7,11 @@ module Kakasi
7
7
  end
8
8
  extend FFI::Library
9
9
 
10
- ffi_lib LIBKAKASI
10
+ require 'kakasi/platform'
11
+
12
+ try_load { |lib|
13
+ ffi_lib lib
14
+ }
11
15
 
12
16
  attach_function 'kakasi_getopt_argv', [:int, :pointer], :int
13
17
  attach_function 'kakasi_do', [:string], :pointer
data/lib/kakasi/fiddle.rb CHANGED
@@ -14,7 +14,11 @@ module Kakasi
14
14
  raise 'Unsupported pointer size: %u' % SIZEOF_VOIDP
15
15
  end
16
16
 
17
- dlload LIBKAKASI
17
+ require 'kakasi/platform'
18
+
19
+ try_load { |lib|
20
+ dlload lib
21
+ }
18
22
 
19
23
  extern 'int kakasi_getopt_argv(int, char **)'
20
24
  extern 'char *kakasi_do(char *)'
@@ -0,0 +1,59 @@
1
+ module Kakasi
2
+ module Lib
3
+ if defined?(::FFI::Platform)
4
+ LIBPREFIX = ::FFI::Platform::LIBPREFIX
5
+ LIBSUFFIX = ::FFI::Platform::LIBSUFFIX
6
+ else
7
+ LIBPREFIX =
8
+ case RbConfig::CONFIG['host_os']
9
+ when /mingw|mswin/i
10
+ ''.freeze
11
+ when /cygwin/i
12
+ 'cyg'.freeze
13
+ else
14
+ 'lib'.freeze
15
+ end
16
+
17
+ LIBSUFFIX =
18
+ case RbConfig::CONFIG['host_os']
19
+ when /darwin/i
20
+ 'dylib'.freeze
21
+ when /mingw|mswin|cygwin/i
22
+ 'dll'.freeze
23
+ else
24
+ 'so'.freeze
25
+ end
26
+ end
27
+
28
+ DEFLIBPATH =
29
+ begin
30
+ [RbConfig::CONFIG['libir']] |
31
+ case RbConfig::CONFIG['host_os']
32
+ when /mingw|mswin/i
33
+ []
34
+ else
35
+ %w[/lib /usr/lib]
36
+ end
37
+ end.freeze
38
+
39
+ def self.map_library_name(name)
40
+ "#{LIBPREFIX}#{name}.#{LIBSUFFIX}"
41
+ end
42
+
43
+ def self.try_load(libpath = LIBPATH)
44
+ basename = map_library_name('kakasi')
45
+ (libpath | DEFLIBPATH).each { |dir|
46
+ begin
47
+ filename = File.join(dir, basename)
48
+ yield filename
49
+ return filename
50
+ rescue LoadError, StandardError
51
+ next
52
+ end
53
+ }
54
+
55
+ yield basename
56
+ return basename
57
+ end
58
+ end
59
+ end
@@ -1,4 +1,4 @@
1
1
  module Kakasi
2
2
  KAKASI_VERSION = '2002-09-28'
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kakasi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akinori MUSHA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: A Ruby binding for KAKASI implemented with Fiddle/DL/FFI
56
70
  email:
57
71
  - knu@idaemons.org
@@ -61,6 +75,7 @@ extensions:
61
75
  extra_rdoc_files: []
62
76
  files:
63
77
  - ".gitignore"
78
+ - ".travis.yml"
64
79
  - Gemfile
65
80
  - LICENSE.txt
66
81
  - README.md
@@ -71,6 +86,7 @@ files:
71
86
  - lib/kakasi/dl.rb
72
87
  - lib/kakasi/ffi.rb
73
88
  - lib/kakasi/fiddle.rb
89
+ - lib/kakasi/platform.rb
74
90
  - lib/kakasi/version.rb
75
91
  - test/helper.rb
76
92
  - test/test_kakasi.rb
@@ -94,10 +110,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
110
  version: '0'
95
111
  requirements: []
96
112
  rubyforge_project:
97
- rubygems_version: 2.1.11
113
+ rubygems_version: 2.2.2
98
114
  signing_key:
99
115
  specification_version: 4
100
116
  summary: A Ruby binding for KAKASI implemented with FFI
101
117
  test_files:
102
118
  - test/helper.rb
103
119
  - test/test_kakasi.rb
120
+ has_rdoc: