i_can_has_java_class 0.0.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: e3faf4057c09b7177297dcc8e8182cb39aa97c3d
4
+ data.tar.gz: 6dd1d4ca1afdae2c231ff5738e93b2d1f2c81aa5
5
+ SHA512:
6
+ metadata.gz: e0ad06040f160937ca2e12f9a82b0a92cfc4464b5562a84033ce84c046e8a16cbda5d59a48faa1b9f6a1110c9dcbba5c36a4a2833e1e2f76800f0f5e22bff784
7
+ data.tar.gz: e764f90a1f968546594f41824ad713dd1e1ec6e86a3fb8949d1eb8da7d0433159a8712e3a25e0f81fd020f009117490c27817f6c5ccfd8e7fbee304306e9dda1
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ *.ruby-*
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in i_can_has_java_class.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Brandon Dewitt
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # ICanHasJavaClass
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'i_can_has_java_class'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install i_can_has_java_class
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ desc "Run specs (default)"
8
+ task :default => :spec
9
+
10
+ Dir["lib/tasks/**/*.rake"].each { |ext| load ext } if defined?(Rake)
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'i_can_has_java_class/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "i_can_has_java_class"
8
+ gem.version = ICanHasJavaClass::VERSION
9
+ gem.authors = ["Brandon Dewitt"]
10
+ gem.email = ["brandonsdewitt@gmail.com"]
11
+ gem.description = %q{ a small gem to check to see if a java class can be found }
12
+ gem.summary = %q{ checking to see if i can has java class in JRuby }
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+
21
+ gem.add_development_dependency "bundler", "~> 1.3"
22
+ gem.add_development_dependency "rake"
23
+ gem.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,30 @@
1
+ require 'java'
2
+ require "i_can_has_java_class/version"
3
+
4
+ module ICanHasJavaClass
5
+ def self.java_class_defined?(class_string)
6
+ !!java_class_exists_in_class_loader?(class_string, ::JRuby.runtime.jruby_class_loader) ||
7
+ !!java_class_exists_in_class_loader?(class_string, nil)
8
+ end
9
+
10
+ def self.java_class_exists_in_class_loader?(class_string, class_loader)
11
+ if class_loader
12
+ return ::Java::JavaLang::Class.forName(class_string, false, class_loader)
13
+ else
14
+ return ::Java::JavaLang::Class.forName(class_string)
15
+ end
16
+ rescue ::Java::JavaLang::ClassNotFoundException
17
+ return false
18
+ end
19
+
20
+ def self.java_class_for(class_string)
21
+ case
22
+ when (klass = java_class_exists_in_class_loader?(class_string, ::JRuby.runtime.jruby_class_loader)) then
23
+ return klass
24
+ when (klass = java_class_exists_in_class_loader?(class_string, nil)) then
25
+ return klass
26
+ else
27
+ raise ::Java::JavaLang::ClassNotFoundException.new
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ require 'i_can_has_java_class'
2
+
3
+ module Kernel
4
+ def java_class_defined?(class_string)
5
+ ::ICanHasJavaClass.java_class_defined?(class_string)
6
+ end
7
+
8
+ def java_class_for(class_string)
9
+ ::ICanHasJavaClass.java_class_for(class_string)
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module ICanHasJavaClass
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'i_can_has_java_class/kernel_ext'
3
+
4
+ describe ::Kernel do
5
+ context "#java_class_defined?" do
6
+ it "is true when class is defined" do
7
+ java_class_defined?("java.lang.Class").should be_true
8
+ end
9
+
10
+ it "is false when class is not defined" do
11
+ java_class_defined?("java.lang.some.other.potential.class.that.may.be.used").should be_false
12
+ end
13
+ end
14
+
15
+ context "#java_class_for" do
16
+ it "returns a known classs java_class" do
17
+ java_class_for("java.lang.Class").should eq(::Java::JavaLang::Class.java_class)
18
+ end
19
+
20
+ it "raises an exception on no class found" do
21
+ expect {
22
+ java_class_for("java.lang.some.other-potential.class.that.may.be.user")
23
+ }.to raise_error(::Java::JavaLang::ClassNotFoundException)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe ::ICanHasJavaClass do
4
+ context "#java_class_defined?" do
5
+ it "is true when class is defined" do
6
+ described_class.java_class_defined?("java.lang.Class").should be_true
7
+ end
8
+
9
+ it "is false when class is not defined" do
10
+ described_class.java_class_defined?("java.lang.some.other.potential.class.that.may.be.used").should be_false
11
+ end
12
+ end
13
+
14
+ context "#java_class_for" do
15
+ it "returns a known classs java_class" do
16
+ described_class.java_class_for("java.lang.Class").should eq(::Java::JavaLang::Class.java_class)
17
+ end
18
+
19
+ it "raises an exception on no class found" do
20
+ expect {
21
+ described_class.java_class_for("java.lang.some.other-potential.class.that.may.be.user")
22
+ }.to raise_error(::Java::JavaLang::ClassNotFoundException)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ ::Bundler.require(:default, :development, :test)
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i_can_has_java_class
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Dewitt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: '1.3'
25
+ prerelease: false
26
+ type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ prerelease: false
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ prerelease: false
54
+ type: :development
55
+ description: ' a small gem to check to see if a java class can be found '
56
+ email:
57
+ - brandonsdewitt@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - i_can_has_java_class.gemspec
68
+ - lib/i_can_has_java_class.rb
69
+ - lib/i_can_has_java_class/kernel_ext.rb
70
+ - lib/i_can_has_java_class/version.rb
71
+ - spec/i_can_has_java_class/kernel_ext_spec.rb
72
+ - spec/i_can_has_java_class_spec.rb
73
+ - spec/spec_helper.rb
74
+ homepage: ''
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.1.9
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: checking to see if i can has java class in JRuby
97
+ test_files:
98
+ - spec/i_can_has_java_class/kernel_ext_spec.rb
99
+ - spec/i_can_has_java_class_spec.rb
100
+ - spec/spec_helper.rb