bootinq 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a2e3311d9fe2f906d1d620e0bff5fa4271d6aaf0
4
+ data.tar.gz: fa4bc277f3707743b340b53988252f425a6648c0
5
+ SHA512:
6
+ metadata.gz: d047b517e113b611dbfc62ad58f8f4ac86aa96cd30a4ae7ac9d11a5ac1564911e35307e5d651f01f5401224b8a31e4ae48ef1e38a152f9b8144edc0a99e5414f
7
+ data.tar.gz: 4b09c5cff33cfc68c72dffeeea388673e4ab873283a34db963c9e73cbe6b818d3d1c3572253e6a040d00c44c964a38d7595b2a24e12b3a3bce7ba015b9369ebf
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /log/*.log
11
+ /spec/dummy/db/*.sqlite3
12
+ /spec/dummy/db/*.sqlite3-journal
13
+ /spec/dummy/log/*.log
14
+ /spec/dummy/tmp/
15
+ /spec/dummy/.sass-cache
16
+ .rake_t_cache
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,36 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Declare your gem's dependencies in bootinq.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ gem 'rails', '~> 4.2'
14
+ gem 'sqlite3'
15
+
16
+ # To use a debugger
17
+ gem 'byebug', group: [:development, :test]
18
+
19
+ group :development, :test do
20
+ # You need these
21
+ gem "rspec-rails"
22
+ gem "pry"
23
+ end
24
+
25
+ group :development do
26
+ # You don't need these, but I use them
27
+ gem "awesome_print"
28
+ end
29
+
30
+ group :shared_boot do
31
+ gem 'shared', path: 'spec/dummy/engines/shared'
32
+ end
33
+
34
+ group :api_boot do
35
+ gem 'api', path: 'spec/dummy/engines/api'
36
+ end
@@ -0,0 +1,48 @@
1
+ # Rails Boot Inquirer (Bootinq)
2
+
3
+ The gem allows to select which bundle groups to boot in the current rails process.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'bootinq'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Insert `require "bootinq"` to the top of `config/application.rb` file.
18
+
19
+ Find a `Bundler.require(*Rails.groups)` line below and replace it with the `Bootinq.require`.
20
+
21
+ ## Example `config/bootinq.yml`:
22
+
23
+ ```yaml
24
+ env_key: BOOTINQ
25
+ default: "-f"
26
+
27
+ parts:
28
+ s: :shared
29
+
30
+ mount:
31
+ a: :api
32
+ f: :engine
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ Using example `bootinq.yml` above, you can create `api_boot` group in your `Gemfile` and load gems from that only when flag `BOOTINQ=a` is set. The group can contain local `api` gem, which provides a mountable engine. Please, see `specs/dummy` for the example.
38
+
39
+ ## Development
40
+
41
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
42
+
43
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/estum/bootinq.
48
+
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bootinq"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -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 'bootinq/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bootinq"
8
+ spec.version = Bootinq::VERSION
9
+ spec.authors = ["Anton"]
10
+ spec.email = ["anton.estum@gmail.com"]
11
+
12
+ spec.summary = %q{Rails Boot Inquirer}
13
+ spec.description = %q{Allows to select which bundle groups to boot in the current rails process}
14
+ spec.homepage = "https://github.com/estum/bootinq"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |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
@@ -0,0 +1,102 @@
1
+ require "yaml"
2
+ require "erb"
3
+ require "singleton"
4
+ require "forwardable"
5
+ require "bootinq/component"
6
+
7
+ # = Bootinq
8
+ #
9
+ # == Installation
10
+ #
11
+ # 1. Insert <tt>require "bootinq"</tt> in the top of <tt>config/application.rb</tt>
12
+ #
13
+ # 2. Find <tt>Bundler.require(*Rails.groups)</tt> line below and replace it
14
+ # with the <tt>Bootinq.require</tt>.
15
+ #
16
+ # == Example <tt>config/bootinq.yml</tt>:
17
+ #
18
+ # env_key: BOOTINQ
19
+ # default: "-f"
20
+ #
21
+ # parts:
22
+ # s: :shared
23
+ #
24
+ # mount:
25
+ # a: :api
26
+ # f: :engine
27
+ class Bootinq
28
+ NEG = '-'.freeze
29
+ DEFAULT = {
30
+ "env_key" => 'BOOTINQ',
31
+ "default" => '',
32
+ "parts" => {},
33
+ "mount" => {}
34
+ }
35
+
36
+ attr_reader :flags, :components
37
+
38
+ include Singleton
39
+ extend SingleForwardable
40
+
41
+ def initialize
42
+ config = YAML.load(File.read(ENV['BOOTINQ_PATH']))
43
+ config.reject! { |_, v| v.nil? }
44
+ config.reverse_merge!(DEFAULT)
45
+
46
+ config['parts'].merge!(config['mount'])
47
+
48
+ value = ENV[config['env_key']] || config['default'].to_s
49
+ neg = value.start_with?(NEG)
50
+
51
+ flags = []
52
+ parts = []
53
+
54
+ config['parts'].each do |flag, name|
55
+ if neg ^ value[flag]
56
+ flags << flag
57
+ parts << Component.new(name, mountable: config['mount'].key?(flag))
58
+ end
59
+ end
60
+
61
+ @_value = value.freeze
62
+ @_neg = neg.freeze
63
+ @flags = flags.freeze
64
+ @components = parts.freeze
65
+ end
66
+
67
+ # Checks if a given gem (i.e. a gem group) is enabled
68
+ def enabled?(gem_name)
69
+ components.include?(gem_name)
70
+ end
71
+
72
+ # Returns a <tt>Bootinq::Component</tt> object by its name
73
+ def component(key)
74
+ components[components.index(key)]
75
+ end
76
+
77
+ # Enums each mountable component
78
+ def each_mountable
79
+ return to_enum(__method__) unless block_given?
80
+ components.each { |c| yield(c) if c.mountable? }
81
+ end
82
+
83
+ # Invokes <tt>Rails.groups</tt> method within enabled Bootinq's groups
84
+ def groups(*groups)
85
+ Rails.groups(*components.map(&:group), *groups)
86
+ end
87
+
88
+ def_delegators "instance", *instance_methods(false)
89
+
90
+ class << self
91
+ # The helper method to bootstrap the Bootinq. Sets the BOOTINQ_PATH enviroment variable
92
+ # and requires selected bundler groups.
93
+ def require(*groups)
94
+ ENV['BOOTINQ_PATH'] ||= File.expand_path('../bootinq.yml', caller_locations(1..1)[0].path)
95
+ Bundler.require(*instance.groups(*groups))
96
+ end
97
+
98
+ private def new
99
+ super.freeze
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,8 @@
1
+ env_key: BOOTINQ
2
+ default: "-f"
3
+ parts:
4
+ # s: :shared
5
+
6
+ mount:
7
+ # a: :api
8
+ # f: :engine
@@ -0,0 +1,20 @@
1
+ class Bootinq
2
+ class Component < DelegateClass(Symbol)
3
+ attr_reader :gem_name, :mountable, :namespace, :group
4
+ alias :to_s :gem_name
5
+ alias :mountable? :mountable
6
+
7
+ def initialize(name, mountable: false)
8
+ super(name)
9
+ @gem_name = name.to_s.freeze
10
+ @mountable = !!mountable
11
+ @group = :"#{gem_name}_boot"
12
+ @namespace = :"#{gem_name.camelcase}" if mountable?
13
+ freeze
14
+ end
15
+
16
+ def engine
17
+ Object.const_get(@namespace)::Engine
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ class Bootinq
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :bootinq do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bootinq
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Anton
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-01 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: Allows to select which bundle groups to boot in the current rails process
56
+ email:
57
+ - anton.estum@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - bootinq.gemspec
71
+ - lib/bootinq.rb
72
+ - lib/bootinq.yml
73
+ - lib/bootinq/component.rb
74
+ - lib/bootinq/version.rb
75
+ - lib/tasks/bootinq_tasks.rake
76
+ homepage: https://github.com/estum/bootinq
77
+ licenses: []
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.8
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Rails Boot Inquirer
99
+ test_files: []
100
+ has_rdoc: