rubinjam 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ded6c9f6eb92813d7602488c593406a4f333f523
4
- data.tar.gz: 6671928069a5c2e10fb1e61435b85740d97519b3
3
+ metadata.gz: 3ad8b2a441f97b43165b8de34a5d5f4f497d9252
4
+ data.tar.gz: ff1a5400580c19c7a302783fe2844ede15db39e9
5
5
  SHA512:
6
- metadata.gz: 8f229a8694bf29678aa3b207012a75539840520ad6aa9448b3396d2a965d5a9e24b4fdf14cd28d091916481fa9c770c78ab3703012f02bbfa21894a2a29c7758
7
- data.tar.gz: 14b21b5efd99913d1cbedc952b0e49436cb10371163ae21a5ab50e6d29c2d22414456cfe3aeaedcbbe413530d59a001b4a0d5d1bd570087194058c31ecfedbea
6
+ metadata.gz: eabcb9d642ad130f409c6518ded37d8ddd1a7e8794bc74f4351bbcc1f7fdefb4da6b68d4b627b3bdf405787619aa7c9912da809749233625e420b998ceb7811e
7
+ data.tar.gz: 1a1a9c87aecc77722ea5a2f3e12e1202462da8dac8e85d7eab9dcd6f9a4d69569b56bad82e31ca9ac9eb29e4bc61706e8285a46235411702e6662664119a6a3e
data/bin/rubinjam CHANGED
@@ -20,6 +20,6 @@ BANNER
20
20
  end.parse!
21
21
 
22
22
  name, content = Rubinjam.pack(Dir.pwd)
23
- File.write(name, content)
23
+ File.open(name, 'w') { |f| f.write content }
24
24
  `chmod +x #{name}`
25
25
  raise "Unable to add execution bit" unless $?.success?
@@ -1,3 +1,3 @@
1
1
  module Rubinjam
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/rubinjam.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "tmpdir"
2
2
  require "bundler"
3
3
  require "rubinjam/version"
4
+ require "shellwords"
4
5
 
5
6
  module Rubinjam
6
7
  class << self
@@ -18,8 +19,8 @@ module Rubinjam
18
19
  Dir.mktmpdir do |dir|
19
20
  Dir.chdir(dir) do
20
21
  # unpack
21
- command = ["gem", "unpack", gem]
22
- command << "-v" << version if version
22
+ command = "gem unpack #{Shellwords.escape(gem)}"
23
+ command << " -v" << version if version
23
24
  IO.popen(command).read
24
25
 
25
26
  # bundle
@@ -56,7 +57,7 @@ module Rubinjam
56
57
  end
57
58
 
58
59
  def libs_from_paths(paths)
59
- paths.select { |p| Dir.exist?(p) }.inject({}) do |all, path|
60
+ paths.select { |p| File.directory?(p) }.inject({}) do |all, path|
60
61
  Dir.chdir path do
61
62
  all.merge!(Hash[Dir["**/*.rb"].map { |f| [f.sub(/\.rb$/, ""), File.read(f)] }])
62
63
  end
@@ -82,13 +83,34 @@ module Rubinjam
82
83
  LIBRARIES = {
83
84
  #{libraries.map { |name,content| "#{name.inspect} => #{content.inspect}" }.join(",\n ")}
84
85
  }
86
+
87
+ ROOT = File.expand_path("../", __FILE__) << "/lib/"
88
+
89
+ module AutoloadFix
90
+ def self.included(base)
91
+ base.class_eval do
92
+ alias autoload_without_rubinjam autoload
93
+ def autoload(const, file)
94
+ if Rubinjam::LIBRARIES[file]
95
+ require file
96
+ else
97
+ autoload_without_rubinjam(const, file)
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
85
103
  end
86
104
 
105
+ Module.send(:include, Rubinjam::AutoloadFix)
106
+ include Rubinjam::AutoloadFix
107
+
87
108
  def require(file)
88
- if code = Rubinjam::LIBRARIES[file]
109
+ normalized_file = file.sub(Rubinjam::ROOT, "")
110
+ if code = Rubinjam::LIBRARIES[normalized_file]
89
111
  return if code == :loaded
90
- eval(code, TOPLEVEL_BINDING, "rubinjam/\#{file}")
91
- Rubinjam::LIBRARIES[file] = :loaded
112
+ eval(code, TOPLEVEL_BINDING, "rubinjam/\#{normalized_file}.rb")
113
+ Rubinjam::LIBRARIES[normalized_file] = :loaded
92
114
  else
93
115
  super
94
116
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubinjam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-14 00:00:00.000000000 Z
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler