simple-class-loader 0.0.1
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.
- data/.gitignore +17 -0
- data/.rbenv-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/simple-class-loader.rb +36 -0
- data/lib/simple-class-loader/version.rb +7 -0
- data/simple-class-loader.gemspec +21 -0
- data/spec/jar/TestCaseA.jar +0 -0
- data/spec/jar/TestCaseB.jar +0 -0
- data/spec/jar/junit-4.10.jar +0 -0
- data/spec/simple_class_loader_spec.rb +58 -0
- data/spec/spec_helper.rb +9 -0
- metadata +84 -0
data/.gitignore
ADDED
data/.rbenv-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby-1.7.2
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kazuhiro Yamada
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Simple::Class::Loader
|
2
|
+
|
3
|
+
SimpleClassLoader for JRuby
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'simple-class-loader'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install simple-class-loader
|
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
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'pp'
|
3
|
+
require 'java'
|
4
|
+
require "simple-class-loader/version"
|
5
|
+
java_import "java.net.URL"
|
6
|
+
java_import "java.net.URLClassLoader"
|
7
|
+
|
8
|
+
class SimpleClassLoader
|
9
|
+
|
10
|
+
def initialize(jar_paths)
|
11
|
+
jar_urls = get_jar_urls(jar_paths)
|
12
|
+
@class_loader = java.net.URLClassLoader.new(jar_urls)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_jar_urls(jar_paths)
|
16
|
+
jar_urls = []
|
17
|
+
jar_paths.each do |jar_path|
|
18
|
+
jar_urls << get_url(jar_path)
|
19
|
+
end
|
20
|
+
jar_urls.to_java(java.net.URL)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_url(jar_path)
|
24
|
+
java.io.File.new(jar_path).toURL
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_class(class_name)
|
28
|
+
class_type = @class_loader.loadClass(class_name)
|
29
|
+
class_type.newInstance
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_jar(jar_path)
|
33
|
+
@class_loader.addURL(get_url(jar_path))
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'simple-class-loader/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "simple-class-loader"
|
8
|
+
gem.version = Simple::Class::Loader::VERSION
|
9
|
+
gem.authors = ["Kazuhiro Yamada"]
|
10
|
+
gem.email = ["kyamada@sonix.asia"]
|
11
|
+
gem.description = "SimpleClassLoader for JRuby"
|
12
|
+
gem.summary = "SimpleClassLoader for JRuby"
|
13
|
+
gem.homepage = "https://github.com/k-yamada/jruby-simple-class-loader"
|
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
|
+
gem.add_development_dependency 'rspec'
|
21
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
describe SimpleClassLoader do
|
6
|
+
|
7
|
+
JAR_JUNIT_PATH = "#{File.dirname(__FILE__)}/jar/junit-4.10.jar"
|
8
|
+
JAR_TEST_CASE_A = "#{File.dirname(__FILE__)}/jar/TestCaseA.jar"
|
9
|
+
JAR_TEST_CASE_B = "#{File.dirname(__FILE__)}/jar/TestCaseB.jar"
|
10
|
+
PACKAGE = "com.scirocco.cloud.test.ADTest"
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
end
|
14
|
+
|
15
|
+
def check_test_case_a(test_case)
|
16
|
+
test_case.methods.should include(:testA)
|
17
|
+
test_case.methods.should_not include(:testB)
|
18
|
+
end
|
19
|
+
|
20
|
+
def check_test_case_b(test_case)
|
21
|
+
test_case.methods.should include(:testB)
|
22
|
+
test_case.methods.should_not include(:testA)
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#load_class" do
|
26
|
+
it "should load TestCaseA" do
|
27
|
+
loader = SimpleClassLoader.new([JAR_JUNIT_PATH, JAR_TEST_CASE_A])
|
28
|
+
test_case = loader.load_class(PACKAGE)
|
29
|
+
check_test_case_a test_case
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should load TestCaseB" do
|
33
|
+
loader = SimpleClassLoader.new([JAR_JUNIT_PATH, JAR_TEST_CASE_B])
|
34
|
+
test_case = loader.load_class(PACKAGE)
|
35
|
+
check_test_case_b test_case
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should load TestCaseA and TestCaseB with different SimpleClassLoader instance" do
|
39
|
+
loader = SimpleClassLoader.new([JAR_JUNIT_PATH, JAR_TEST_CASE_A])
|
40
|
+
test_case = loader.load_class(PACKAGE)
|
41
|
+
check_test_case_a test_case
|
42
|
+
|
43
|
+
loader = SimpleClassLoader.new([JAR_JUNIT_PATH, JAR_TEST_CASE_B])
|
44
|
+
test_case = loader.load_class(PACKAGE)
|
45
|
+
check_test_case_b test_case
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#add_jar" do
|
50
|
+
it "should add TestCaseA" do
|
51
|
+
loader = SimpleClassLoader.new([JAR_JUNIT_PATH])
|
52
|
+
loader.add_jar(JAR_TEST_CASE_A)
|
53
|
+
test_case = loader.load_class(PACKAGE)
|
54
|
+
check_test_case_a test_case
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple-class-loader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kazuhiro Yamada
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: !binary |-
|
21
|
+
MA==
|
22
|
+
none: false
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: !binary |-
|
28
|
+
MA==
|
29
|
+
none: false
|
30
|
+
prerelease: false
|
31
|
+
type: :development
|
32
|
+
description: SimpleClassLoader for JRuby
|
33
|
+
email:
|
34
|
+
- kyamada@sonix.asia
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- ".gitignore"
|
40
|
+
- ".rbenv-version"
|
41
|
+
- Gemfile
|
42
|
+
- LICENSE.txt
|
43
|
+
- README.md
|
44
|
+
- Rakefile
|
45
|
+
- lib/simple-class-loader.rb
|
46
|
+
- lib/simple-class-loader/version.rb
|
47
|
+
- simple-class-loader.gemspec
|
48
|
+
- spec/jar/TestCaseA.jar
|
49
|
+
- spec/jar/TestCaseB.jar
|
50
|
+
- spec/jar/junit-4.10.jar
|
51
|
+
- spec/simple_class_loader_spec.rb
|
52
|
+
- spec/spec_helper.rb
|
53
|
+
homepage: https://github.com/k-yamada/jruby-simple-class-loader
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: !binary |-
|
64
|
+
MA==
|
65
|
+
none: false
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: !binary |-
|
71
|
+
MA==
|
72
|
+
none: false
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.8.24
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: SimpleClassLoader for JRuby
|
79
|
+
test_files:
|
80
|
+
- spec/jar/TestCaseA.jar
|
81
|
+
- spec/jar/TestCaseB.jar
|
82
|
+
- spec/jar/junit-4.10.jar
|
83
|
+
- spec/simple_class_loader_spec.rb
|
84
|
+
- spec/spec_helper.rb
|