irpack 0.1.0 → 0.2.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.
@@ -0,0 +1,75 @@
1
+ # coding: utf-8
2
+ =begin
3
+ Copyright (c) 2011 Ryuichi Sakamoto.
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgment in the product documentation would be
16
+ appreciated but is not required.
17
+
18
+ 2. Altered source versions must be plainly marked as such, and must not be
19
+ misrepresented as being the original software.
20
+
21
+ 3. This notice may not be removed or altered from any source
22
+ distribution.
23
+ =end
24
+
25
+ require 'test/unit'
26
+ require 'irpack'
27
+ require 'utils'
28
+
29
+ class TC_IRPack < Test::Unit::TestCase
30
+ include Utils
31
+ def test_path_to_module_name
32
+ assert_equal('IR', IRPack.path_to_module_name('c:/Program Files/IronRuby1.1/bin/ir.exe'))
33
+ assert_equal('IR', IRPack.path_to_module_name('c:\\Program Files\\IronRuby1.1\\bin\\ir.exe'))
34
+ assert_equal('M1234', IRPack.path_to_module_name('1234'))
35
+ assert_equal('M__FOO_BAR', IRPack.path_to_module_name('__foo_bar'))
36
+ assert_equal('FOOBAR', IRPack.path_to_module_name('FooBar'))
37
+ assert_equal('FOO_BAR', IRPack.path_to_module_name('Foo$Bar'))
38
+ assert_equal('M_____', IRPack.path_to_module_name('モジュール'))
39
+ end
40
+
41
+ def test_ironruby_assemblies
42
+ locations = IRPack.ironruby_assemblies
43
+ locations.each do |loc|
44
+ assert(File.exist?(loc))
45
+ assert(IRPack::IronRubyAssemblies.include?(File.basename(loc, '.dll')))
46
+ end
47
+ end
48
+
49
+ def test_pack
50
+ entry = Tempfile.open(File.basename(__FILE__)) do |f|
51
+ f.write <<-RB
52
+ $: << File.dirname(__FILE__)
53
+ require 'hello'
54
+ hello
55
+ RB
56
+ f.path
57
+ end
58
+ hello = Tempfile.open(File.basename(__FILE__)) do |f|
59
+ f.write <<-RB
60
+ def hello
61
+ puts 'Hello World!'
62
+ end
63
+ RB
64
+ f.path
65
+ end
66
+ files = {
67
+ entry => 'entry.rb',
68
+ hello => 'hello.rb',
69
+ }
70
+ outfile = tempfilename('.exe')
71
+ assert_equal(outfile, IRPack.pack(outfile, files, 'entry.rb'))
72
+ assert_equal('Hello World!', `#{outfile}`.chomp)
73
+ end
74
+ end
75
+
@@ -0,0 +1,37 @@
1
+ =begin
2
+ Copyright (c) 2011 Ryuichi Sakamoto.
3
+
4
+ This software is provided 'as-is', without any express or implied
5
+ warranty. In no event will the authors be held liable for any damages
6
+ arising from the use of this software.
7
+
8
+ Permission is granted to anyone to use this software for any purpose,
9
+ including commercial applications, and to alter it and redistribute it
10
+ freely, subject to the following restrictions:
11
+
12
+ 1. The origin of this software must not be misrepresented; you must not
13
+ claim that you wrote the original software. If you use this software
14
+ in a product, an acknowledgment in the product documentation would be
15
+ appreciated but is not required.
16
+
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+
20
+ 3. This notice may not be removed or altered from any source
21
+ distribution.
22
+ =end
23
+
24
+ require 'test/unit'
25
+ require 'irpack/missing'
26
+ require 'tmpdir'
27
+
28
+ class TC_Missing < Test::Unit::TestCase
29
+ def test_mktmpdir
30
+ assert_nothing_raised do
31
+ Dir.mktmpdir('prefix') do |path|
32
+ assert_match(/prefix/, path)
33
+ end
34
+ end
35
+ end
36
+ end
37
+
@@ -1,29 +1,45 @@
1
+ =begin
2
+ Copyright (c) 2011 Ryuichi Sakamoto.
1
3
 
2
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'test/unit'
4
- require 'tempfile'
5
- require 'tmpdir'
6
- require 'fileutils'
7
- require 'irpack'
4
+ This software is provided 'as-is', without any express or implied
5
+ warranty. In no event will the authors be held liable for any damages
6
+ arising from the use of this software.
7
+
8
+ Permission is granted to anyone to use this software for any purpose,
9
+ including commercial applications, and to alter it and redistribute it
10
+ freely, subject to the following restrictions:
11
+
12
+ 1. The origin of this software must not be misrepresented; you must not
13
+ claim that you wrote the original software. If you use this software
14
+ in a product, an acknowledgment in the product documentation would be
15
+ appreciated but is not required.
16
+
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+
20
+ 3. This notice may not be removed or altered from any source
21
+ distribution.
22
+ =end
8
23
 
24
+ require 'test/unit'
25
+ require 'irpack/packager'
9
26
  require 'WindowsBase'
10
- include System
11
- include System::IO
12
- include System::IO::Packaging
27
+ require 'utils'
13
28
 
14
29
  class TC_Packager < Test::Unit::TestCase
30
+ include Utils
31
+
15
32
  SrcFiles = {
16
33
  File.join(File.dirname(__FILE__), 'test_packager.rb') => 'foo.rb',
17
34
  File.join(File.dirname(__FILE__), 'test_cscompiler.rb') => 'bar.rb',
18
35
  }
19
36
 
20
37
  def test_pack
21
- target = Tempfile.new(File.basename(__FILE__))
22
- target.close
23
- IRPack::Packager.pack(SrcFiles, target.path)
24
- package = Package.open(target.path, FileMode.open)
38
+ package_file = tempfilename
39
+ IRPack::Packager.pack(SrcFiles, package_file)
40
+ package = System::IO::Packaging::Package.open(package_file, System::IO::FileMode.open)
25
41
  SrcFiles.each do |src, dest|
26
- uri = Uri.new(File.join('/', dest), UriKind.relative)
42
+ uri = System::Uri.new(File.join('/', dest), System::UriKind.relative)
27
43
  assert(package.part_exists(uri))
28
44
  stream = package.get_part(uri).get_stream
29
45
  bytes = System::Array[System::Byte].new(stream.length)
@@ -31,26 +47,5 @@ class TC_Packager < Test::Unit::TestCase
31
47
  assert_equal(File.open(src, 'rb'){|f|f.read}, bytes.to_a.pack('C*'))
32
48
  end
33
49
  end
34
-
35
- def test_pack_dir
36
- Dir.mktmpdir do |src_path|
37
- SrcFiles.each do |src, dest|
38
- FileUtils.mkdir_p(File.join(src_path, File.dirname(dest)))
39
- FileUtils.copy(src, File.join(src_path, dest))
40
- end
41
- target = Tempfile.new(File.basename(__FILE__))
42
- target.close
43
- IRPack::Packager.pack_dir(src_path, target.path)
44
- package = Package.open(target.path, FileMode.open)
45
- SrcFiles.each do |src, dest|
46
- uri = Uri.new(File.join('/', dest), UriKind.relative)
47
- assert(package.part_exists(uri))
48
- stream = package.get_part(uri).get_stream
49
- bytes = System::Array[System::Byte].new(stream.length)
50
- stream.read(bytes, 0, stream.length)
51
- assert_equal(File.open(src, 'rb'){|f|f.read}, bytes.to_a.pack('C*'))
52
- end
53
- end
54
- end
55
50
  end
56
51
 
@@ -0,0 +1,79 @@
1
+ =begin
2
+ Copyright (c) 2011 Ryuichi Sakamoto.
3
+
4
+ This software is provided 'as-is', without any express or implied
5
+ warranty. In no event will the authors be held liable for any damages
6
+ arising from the use of this software.
7
+
8
+ Permission is granted to anyone to use this software for any purpose,
9
+ including commercial applications, and to alter it and redistribute it
10
+ freely, subject to the following restrictions:
11
+
12
+ 1. The origin of this software must not be misrepresented; you must not
13
+ claim that you wrote the original software. If you use this software
14
+ in a product, an acknowledgment in the product documentation would be
15
+ appreciated but is not required.
16
+
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+
20
+ 3. This notice may not be removed or altered from any source
21
+ distribution.
22
+ =end
23
+
24
+ require 'WindowsBase'
25
+ require 'tempfile'
26
+
27
+ module Utils
28
+ module_function
29
+ def create_package(filename_or_contents, contents=nil, &block)
30
+ if contents then
31
+ package = System::IO::Packaging::Package.open(
32
+ filename_or_contents,
33
+ System::IO::FileMode.create)
34
+ else
35
+ package = System::IO::Packaging::Package.open(
36
+ System::IO::MemoryStream.new,
37
+ System::IO::FileMode.create)
38
+ contents = filename_or_contents
39
+ end
40
+ contents.each do |path, content|
41
+ uri = System::IO::Packaging::PackUriHelper.create_part_uri(System::Uri.new(path, System::UriKind.relative))
42
+ part = package.create_part(
43
+ uri,
44
+ 'application/octet-stream',
45
+ System::IO::Packaging::CompressionOption.not_compressed)
46
+ stream = part.get_stream
47
+ stream.write(content, 0, content.bytesize)
48
+ stream.close
49
+ package.create_relationship(
50
+ uri,
51
+ System::IO::Packaging::TargetMode.internal,
52
+ 'http://schemas.openxmlformats.org/package/2006/relationships/meta data/core-properties')
53
+ end
54
+ block.call(package) if block
55
+ package.close
56
+ package
57
+ end
58
+
59
+ def tempfilename(suffix='')
60
+ tmp = Tempfile.open([File.basename($0), suffix])
61
+ tmp.close
62
+ $tempfiles ||= []
63
+ $tempfiles << tmp
64
+ tmp.path
65
+ end
66
+
67
+ IronRubyAssemblies = %w[
68
+ Microsoft.Dynamic
69
+ Microsoft.Scripting
70
+ Microsoft.Scripting.Core
71
+ IronRuby
72
+ IronRuby.Libraries
73
+ IronRuby.Libraries.Yaml
74
+ ]
75
+ def ironruby_assemblies
76
+ System::AppDomain.current_domain.get_assemblies.select {|asm| IronRubyAssemblies.include?(asm.get_name.name) }.collect {|asm| asm.location }
77
+ end
78
+ end
79
+
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irpack
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 0
9
- version: 0.1.0
4
+ prerelease:
5
+ version: 0.2.1
10
6
  platform: ruby
11
7
  authors:
12
8
  - kumaryu
@@ -14,8 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-09-11 00:00:00 +09:00
18
- default_executable:
13
+ date: 2011-07-15 00:00:00 Z
19
14
  dependencies: []
20
15
 
21
16
  description: |
@@ -31,10 +26,21 @@ extra_rdoc_files: []
31
26
 
32
27
  files:
33
28
  - bin/irpack
29
+ - lib/irpack/application.rb
30
+ - lib/irpack/bootloader.rb
31
+ - lib/irpack/cscompiler.rb
32
+ - lib/irpack/entrypoint.rb
33
+ - lib/irpack/missing.rb
34
+ - lib/irpack/packager.rb
34
35
  - lib/irpack.rb
36
+ - test/test_application.rb
37
+ - test/test_bootloader.rb
35
38
  - test/test_cscompiler.rb
39
+ - test/test_entrypoint.rb
40
+ - test/test_irpack.rb
41
+ - test/test_missing.rb
36
42
  - test/test_packager.rb
37
- has_rdoc: true
43
+ - test/utils.rb
38
44
  homepage: http://github.com/kumaryu/irpack
39
45
  licenses: []
40
46
 
@@ -48,21 +54,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
54
  requirements:
49
55
  - - ">="
50
56
  - !ruby/object:Gem::Version
51
- segments:
52
- - 0
53
57
  version: "0"
54
58
  required_rubygems_version: !ruby/object:Gem::Requirement
55
59
  none: false
56
60
  requirements:
57
61
  - - ">="
58
62
  - !ruby/object:Gem::Version
59
- segments:
60
- - 0
61
63
  version: "0"
62
64
  requirements:
63
65
  - none
64
66
  rubyforge_project:
65
- rubygems_version: 1.3.7
67
+ rubygems_version: 1.8.5
66
68
  signing_key:
67
69
  specification_version: 3
68
70
  summary: Generate a standalone executable file from IronRuby scripts.