rubinjam 0.4.1 → 0.5.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: 8dfbf9e2a278c90af3da8ede1a9443b665595a51
4
- data.tar.gz: 4637b949e8ca3fae746fdd64ae89117403175b5f
3
+ metadata.gz: 12b4693f0228c9ef025562f3de9ca18dac47fc11
4
+ data.tar.gz: 41987578a65685f0e4f88f125d0eff2a25ae0f10
5
5
  SHA512:
6
- metadata.gz: 09119a44c5e0b820dd9c6297b995ba3e8a9a1f5e48a991cefba1aa89b7b4f9fdfb1b9ab32c0420ef12cee4997380b05c7fe3284bd87d86140b63b795d4ba8908
7
- data.tar.gz: 2af14192ea592ceb4144c7fab29c3a5b374fe58cf3df9f0d71ff8ed5c4839dd18da4880ff20046d313b0a6c97be448a825bff411ef4222ebf76b4010b43e39eb
6
+ metadata.gz: b749725f4df230e2f657915216b6b7aa7eb68885b468a49743c1b6316f630c0f51110ee4198e13fd4fd792271a38e339cf50343ec0c12c9595e187afc5b56f5b
7
+ data.tar.gz: 59a85c541e2cecd673d4d2868f9667c415cbfb0db3e6f29a91dd0c116bc47d34c08a4d09770770a4c7b8f21c7ddc52cab856a8894d525c5cda193aa69032e9a6
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.4.1
4
+ version: 0.5.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-21 00:00:00.000000000 Z
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -31,10 +31,7 @@ executables:
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - MIT-LICENSE
35
34
  - bin/rubinjam
36
- - lib/rubinjam.rb
37
- - lib/rubinjam/version.rb
38
35
  homepage: https://github.com/grosser/rubinjam
39
36
  licenses:
40
37
  - MIT
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (C) 2013 Michael Grosser <michael@grosser.it>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/lib/rubinjam.rb DELETED
@@ -1,210 +0,0 @@
1
- require "tmpdir"
2
- require "bundler"
3
- require "rubinjam/version"
4
-
5
- module Rubinjam
6
- HEADER = '#!/usr/bin/env ruby'.freeze
7
-
8
- class << self
9
- def pack(dir)
10
- Dir.chdir(dir) do
11
- binaries = Dir["bin/*"]
12
- raise "No binary found in ./bin" if binaries.size == 0
13
- raise "Can only pack exactly 1 binary, found #{binaries.join(",")} in ./bin" unless binaries.size == 1
14
- content = environment + File.read(binaries.first)
15
- [File.basename(binaries.first), content]
16
- end
17
- end
18
-
19
- def pack_gem(gem, version=nil)
20
- require "shellwords"
21
- require "rubygems/package"
22
-
23
- Dir.mktmpdir do |dir|
24
- Dir.chdir(dir) do
25
- # fetch
26
- command = "gem fetch #{Shellwords.escape(gem)}"
27
- command << " -v" << version if version
28
- sh(command)
29
-
30
- # load spec
31
- gem_ball = Dir["*.gem"].first
32
- spec = Gem::Package.new(gem_ball).spec.to_ruby
33
- sh("gem unpack #{gem_ball}")
34
-
35
- # bundle
36
- Dir.chdir(gem_ball.sub(".gem", "")) do
37
- File.open("#{gem}.gemspec", "w") { |f| f.write spec }
38
- Rubinjam.pack(Dir.pwd)
39
- end
40
- end
41
- end
42
- end
43
-
44
- private
45
-
46
- def libraries
47
- libs_from_paths(["lib"]).merge(gem_libraries)
48
- end
49
-
50
- def gem_libraries
51
- return {} unless gemspec = Dir["*.gemspec"].first
52
- return {} unless File.read(gemspec) =~ /add_(runtime_)?dependency/
53
-
54
- Dir.mktmpdir do |dir|
55
- sh "cp -R . #{dir}/"
56
- Dir.chdir(dir) do
57
- write gemspec, File.read(gemspec).gsub(/.*add_development_dependency.*/, "")
58
- write "Gemfile", <<-RUBY.gsub(/^ /, "")
59
- source "https://rubygems.org"
60
- gemspec
61
- RUBY
62
-
63
- sh("rm -f Gemfile.lock")
64
- sh("BUNDLE_IGNORE_CONFIG=1 bundle install --quiet --path bundle") # heroku has a --deployment config -> ignore it
65
- paths = sh("bundle exec ruby -e 'puts $LOAD_PATH'").split("\n")
66
- paths = paths.grep(%r{/gems/}).reject { |r| r =~ %r{/gems/bundler-\d} }
67
- libs_from_paths(paths)
68
- end
69
- end
70
- end
71
-
72
- def libs_from_paths(paths)
73
- paths.select { |p| File.directory?(p) }.inject({}) do |all, path|
74
- Dir.chdir path do
75
- all.merge!(Hash[Dir["**/*.rb"].map { |f| [f.sub(/\.rb$/, ""), File.read(f)] }])
76
- end
77
- end
78
- end
79
-
80
- def sh(command, options={})
81
- result = Bundler.with_clean_env { `#{command} 2>/dev/null` }
82
- raise "#{options[:fail] ? "SUCCESS" : "FAIL"} #{command}\n#{result}" if $?.success? == !!options[:fail]
83
- result
84
- end
85
-
86
- def write(file, content)
87
- FileUtils.mkdir_p(File.dirname(file))
88
- File.open(file, "w") { |f| f.write content }
89
- end
90
-
91
- def environment
92
- <<-RUBY.gsub(/^ /, "")
93
- #{HEADER}
94
- # generated by rubinjam v#{VERSION} -- https://github.com/grosser/rubinjam
95
- module Rubinjam
96
- LIBRARIES = {
97
- #{libraries.map { |name,content| "#{name.inspect} => #{content.inspect}" }.join(",\n ")}
98
- }
99
-
100
- ROOT = File.expand_path("../", __FILE__) << "/rubinjam/"
101
-
102
- class << self
103
- def normalize_file(file)
104
- return file unless file.start_with?("/")
105
- if file.start_with?(ROOT)
106
- file.sub(ROOT, "")
107
- else
108
- file.split('/lib/').last
109
- end
110
- end
111
-
112
- def file_from_nesting(mod, const)
113
- if file = mod.rubinjam_autload[const]
114
- return [mod, file]
115
- end
116
-
117
- nesting(mod.name)[1..-1].detect do |mod|
118
- file = mod.rubinjam_autload[const]
119
- break [mod, file] if file
120
- end
121
- end
122
-
123
- # this does not reflect the actual Module.nesting of the caller,
124
- # but it should be close enough
125
- def nesting(name)
126
- nesting = []
127
- namespace = name.split("::")
128
- namespace.inject(Object) do |base, n|
129
- klass = base.const_get(n)
130
- nesting << klass
131
- klass
132
- end
133
- nesting.reverse
134
- end
135
- end
136
-
137
- module ModuleAutoloadFix
138
- def self.included(base)
139
- base.class_eval do
140
- def rubinjam_autload
141
- @rubinjam_autload ||= {}
142
- end
143
-
144
- alias autoload_without_rubinjam autoload
145
- def autoload(const, file)
146
- normalized_file = Rubinjam.normalize_file(file)
147
- if Rubinjam::LIBRARIES[normalized_file]
148
- rubinjam_autload[const] = normalized_file
149
- else
150
- autoload_without_rubinjam(const, file)
151
- end
152
- end
153
-
154
- alias const_missing_without_rubinjam const_missing
155
- def const_missing(const)
156
- # do not load twice / go into infitire loops
157
- @rubinjam_tried_const_missing ||= {}
158
- if @rubinjam_tried_const_missing[const]
159
- return const_missing_without_rubinjam(const)
160
- end
161
- @rubinjam_tried_const_missing[const] = true
162
-
163
- # try to find autoload in current module or nesting
164
- nesting, file = Rubinjam.file_from_nesting(self, const)
165
- if file
166
- require file
167
- nesting.const_get(const)
168
- else
169
- const_missing_without_rubinjam(const)
170
- end
171
- end
172
- end
173
- end
174
- end
175
-
176
- module BaseAutoloadFix
177
- def self.included(base)
178
- base.class_eval do
179
- alias autoload_without_rubinjam autoload
180
-
181
- def autoload(const, file)
182
- normalized_file = Rubinjam.normalize_file(file)
183
- if Rubinjam::LIBRARIES[normalized_file]
184
- require normalized_file
185
- else
186
- autoload_without_rubinjam(const, file)
187
- end
188
- end
189
- end
190
- end
191
- end
192
- end
193
-
194
- Module.send(:include, Rubinjam::ModuleAutoloadFix)
195
- include Rubinjam::BaseAutoloadFix
196
-
197
- def require(file)
198
- normalized_file = Rubinjam.normalize_file(file)
199
- if code = Rubinjam::LIBRARIES[normalized_file]
200
- return if code == :loaded
201
- eval(code, TOPLEVEL_BINDING, "rubinjam/\#{normalized_file}.rb")
202
- Rubinjam::LIBRARIES[normalized_file] = :loaded
203
- else
204
- super
205
- end
206
- end
207
- RUBY
208
- end
209
- end
210
- end
@@ -1,3 +0,0 @@
1
- module Rubinjam
2
- VERSION = "0.4.1"
3
- end