fatbundle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 37b0d6336752c6a6a68bfccf5038bd52445c0153
4
+ data.tar.gz: df1983fec7f89e5886048554d793cf958c8a3cca
5
+ SHA512:
6
+ metadata.gz: 768b020699c5995bbbd0cd0eb6932eeb7e2a26ceeec827a3cffd4edee0178b7e1da1a00e6c81cb21a4ecb850a16dd31ebd50e0b8b7d5879bb2aea61f448abc26
7
+ data.tar.gz: 0ded5f64f48ee82efc0dc4e03721de9455c0b101e35240ebfe7ed9b1b695aac95c57802583349e0248761e640317dd6339fffd927c995882f55dde56556e9d1b
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ before_install: gem install bundler -v 1.10.5
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'thor'
4
+
5
+ # Specify your gem's dependencies in fatbundle.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Tatsuhiko Miyagawa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Fatbundle
2
+
3
+ Create a single fat bundle with all your gem dependencies in one Ruby script
4
+
5
+ ## Installation
6
+
7
+ Do not add this gem to your bundle, instead install it globally and run it like a regular command. Fatbundle will automatically load Bundler for you to load your gem dependencies.
8
+
9
+ $ gem install fatbundle
10
+
11
+ ## Usage
12
+
13
+ Create your script and describe dependencies as a regular applicaiton in `Gemfile`, and then run `bundle install`.
14
+
15
+ $ bundle install
16
+
17
+ Now you can run `fatbundle` to package your file and all gem dependencies.
18
+
19
+ $ fatbundle script.rb > script.packed.rb
20
+
21
+ The generated file contains all the gem files in pure Ruby with an embedded bootstrap loader, so you don't need any gems or even bundler to run on the other computer. You just need a Ruby runtime.
22
+
23
+ ## Limitation
24
+
25
+ Gems with C-extension cannot be packaged properly, so they'll be ignored with warnings.
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/miyagawa/fatbundle.
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
34
+
35
+ ## Author
36
+
37
+ Tatsuhiko Miyagawa
38
+
39
+ ## Acknowledgements
40
+
41
+ This gem is inspired by [FatPacker](https://metacpan.org/pod/App::FatPacker) for CPAN and FatJar for Java. Initial prototype was coded during lunch at RubyConf 2015 with yoshiori and k0kubun.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/fatbundle ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fatbundle/cli'
3
+ Fatbundle::CLI.new(ARGV).run
data/fatbundle.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fatbundle/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fatbundle"
8
+ spec.version = Fatbundle::VERSION
9
+ spec.authors = ["Tatsuhiko Miyagawa"]
10
+ spec.email = ["miyagawa@bulknews.net"]
11
+
12
+ spec.summary = %q{Create a single, fat bundle of your Ruby script using Bundler}
13
+ spec.homepage = "https://github.com/miyagawa/fatbundle"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "bin"
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ end
data/lib/fatbundle.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "fatbundle/version"
2
+
3
+ module Fatbundle
4
+ end
5
+
@@ -0,0 +1,15 @@
1
+ require 'fatbundle/packager'
2
+
3
+ module Fatbundle
4
+ class CLI
5
+ def initialize(args)
6
+ @script = args[0]
7
+ end
8
+
9
+ def run
10
+ preamble = Fatbundle::Packager.new.pack
11
+ puts preamble
12
+ puts File.read(@script) if @script
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,60 @@
1
+ require 'bundler'
2
+ require 'pathname'
3
+
4
+ module Fatbundle
5
+ class Packager
6
+ def initialize
7
+ @files = {}
8
+ end
9
+
10
+ def pack
11
+ # assuming it's running under bundler already
12
+ Bundler.load.specs.each do |spec|
13
+ unless spec.extensions.empty?
14
+ warn "Can't package C extension #{spec.name}"
15
+ next
16
+ end
17
+
18
+ spec.load_paths.each do |path|
19
+ warn "Packing #{spec.name} from #{spec.gem_dir}"
20
+ collect(path)
21
+ end
22
+ end
23
+
24
+ preamble = <<-EOF
25
+ module Fatbundle
26
+ FILES = #{@files.inspect}
27
+ LOADED = []
28
+ end
29
+
30
+ module Kernel
31
+ alias original_require require
32
+ def require(file)
33
+ if Fatbundle::LOADED.include?(file)
34
+ return true
35
+ end
36
+
37
+ if Fatbundle::FILES[file]
38
+ Fatbundle::LOADED << file
39
+ return eval(Fatbundle::FILES[file], TOPLEVEL_BINDING)
40
+ end
41
+
42
+ warn "File '\#{file}' not found in Fatbundle, falling back to original require" if ENV['FATBUNDLE_DEBUG']
43
+ original_require(file)
44
+ end
45
+ end
46
+
47
+ EOF
48
+
49
+ puts preamble.gsub /^ {8}/, ''
50
+ end
51
+
52
+ def collect(path)
53
+ base = Pathname.new(path)
54
+ Dir["#{path}/**/*.rb"].each do |file|
55
+ name = Pathname.new(file).relative_path_from(base)
56
+ @files[name.sub(/\.rb$/, '').to_s] ||= File.read(file)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module Fatbundle
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fatbundle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tatsuhiko Miyagawa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - miyagawa@bulknews.net
58
+ executables:
59
+ - fatbundle
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/fatbundle
71
+ - fatbundle.gemspec
72
+ - lib/fatbundle.rb
73
+ - lib/fatbundle/cli.rb
74
+ - lib/fatbundle/packager.rb
75
+ - lib/fatbundle/version.rb
76
+ homepage: https://github.com/miyagawa/fatbundle
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.6
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Create a single, fat bundle of your Ruby script using Bundler
100
+ test_files: []