stibium-bundled 0.0.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.
- checksums.yaml +7 -0
- data/.yardopts +16 -0
- data/lib/stibium-bundled.rb +9 -0
- data/lib/stibium/bundled.rb +88 -0
- data/lib/stibium/bundled/bundle.rb +89 -0
- data/lib/stibium/bundled/version.rb +17 -0
- data/lib/stibium/bundled/version.yml +17 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 872a10da7e3924dd1b8dca69f57bcbd7f31ab6b82097b3cd45ddfaf4ff8e0aa9
|
4
|
+
data.tar.gz: 97e4ccd6cd8211e1e4ad9d8ab63feec5294168b8971187ad44d6d80ee78c957b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1c253d6972da289b0ef2c78826e3d4b88d17fd19370afe47938c1cc44d6c79fd47a22f05312ade86318059e6d97c8a85937c9ed2b7817d4156ca63a4ff757479
|
7
|
+
data.tar.gz: 38c53b363286e39f45360d12717e9c5dd262906b770b04759e8ab7231b283175484fe674ae8d89db3a31b4cb83fe41c07bb179a5d507871312e2ebed4e5e5e8d
|
data/.yardopts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# vim: ft=sh
|
2
|
+
|
3
|
+
lib/**/*.rb \
|
4
|
+
--no-progress \
|
5
|
+
--markup-provider 'redcarpet' \
|
6
|
+
--markup 'markdown' \
|
7
|
+
--charset 'utf-8' \
|
8
|
+
--protected --private --embed-mixins \
|
9
|
+
--tag type:'type' --hide-tag 'type' \
|
10
|
+
--readme README.md \
|
11
|
+
--exclude '_flymake\\.rb$' \
|
12
|
+
--exclude '/\\.#'
|
13
|
+
|
14
|
+
# Local Variables:
|
15
|
+
# mode: sh
|
16
|
+
# End:
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2020-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
|
4
|
+
# License GPLv3+: GNU GPL version 3 or later
|
5
|
+
# <http://www.gnu.org/licenses/gpl.html>.
|
6
|
+
# This is free software: you are free to change and redistribute it.
|
7
|
+
# There is NO WARRANTY, to the extent permitted by law.
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift(__dir__)
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2020-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
|
4
|
+
# License GPLv3+: GNU GPL version 3 or later
|
5
|
+
# <http://www.gnu.org/licenses/gpl.html>.
|
6
|
+
# This is free software: you are free to change and redistribute it.
|
7
|
+
# There is NO WARRANTY, to the extent permitted by law.
|
8
|
+
|
9
|
+
unless Object.const_defined?(:Stibium)
|
10
|
+
# Namespace
|
11
|
+
module Stibium
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Sample of use:
|
16
|
+
#
|
17
|
+
# ```ruby
|
18
|
+
# # file: lib/awesome_gem.rb
|
19
|
+
# module AwesomeGem
|
20
|
+
# Stibium::Bundled.call(self, basedir: "#{__dir__}/..")
|
21
|
+
#
|
22
|
+
# bundled&.tap do |bundle|
|
23
|
+
# unless bundle.standalone!
|
24
|
+
# require 'bundler/setup' if bundle.locked?
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
# ```
|
29
|
+
#
|
30
|
+
# or:
|
31
|
+
#
|
32
|
+
# ```ruby
|
33
|
+
# # file: lib/awesome_gem.rb
|
34
|
+
# module AwesomeGem
|
35
|
+
# class << self
|
36
|
+
# include(Stibium::Bundled)
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# self.bundled_from("#{__dir__}/..") do |bundle|
|
40
|
+
# unless bundle.standalone!
|
41
|
+
# require 'bundler/setup' if bundle.locked?
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
module Stibium::Bundled
|
46
|
+
{
|
47
|
+
Bundle: 'bundle',
|
48
|
+
VERSION: 'version',
|
49
|
+
}.each { |k, v| autoload(k, "#{__dir__}/bundled/#{v}") }
|
50
|
+
|
51
|
+
# @!method bundled?
|
52
|
+
# Denote bundle is locked or standalone.
|
53
|
+
# @return [Boolean]
|
54
|
+
|
55
|
+
# @!method bundled
|
56
|
+
# @return [Bundle, nil]
|
57
|
+
|
58
|
+
# @param [String, Pathname] basedir
|
59
|
+
#
|
60
|
+
# @return [Bundle. nil]
|
61
|
+
def bundled_from(basedir)
|
62
|
+
Stibium::Bundled
|
63
|
+
.call(self, basedir: basedir)
|
64
|
+
.bundled
|
65
|
+
.tap { |bundle| yield(bundle) if block_given? and bundle }
|
66
|
+
end
|
67
|
+
|
68
|
+
class << self
|
69
|
+
# @param target [Class, Module]
|
70
|
+
# @param basedir [String, Pathname]
|
71
|
+
#
|
72
|
+
# @return [Class, Module]
|
73
|
+
def call(target, basedir:)
|
74
|
+
target.tap do |t|
|
75
|
+
t.singleton_class.tap do |sc|
|
76
|
+
sc.singleton_class.__send__(:include, self)
|
77
|
+
sc.define_method(:bundled?) { !bundled?.nil? }
|
78
|
+
sc.define_method(:bundled) do
|
79
|
+
# @type [Bundle] bundle
|
80
|
+
# rubocop:disable Style/TernaryParentheses
|
81
|
+
Bundle.new(basedir).yield_self { |bundle| (bundle.locked? or bundle.standalone?) ? bundle : nil }
|
82
|
+
# rubocop:enable Style/TernaryParentheses
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2020-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
|
4
|
+
# License GPLv3+: GNU GPL version 3 or later
|
5
|
+
# <http://www.gnu.org/licenses/gpl.html>.
|
6
|
+
# This is free software: you are free to change and redistribute it.
|
7
|
+
# There is NO WARRANTY, to the extent permitted by law.
|
8
|
+
|
9
|
+
require_relative '../bundled'
|
10
|
+
|
11
|
+
# Describe a bundle.
|
12
|
+
class Stibium::Bundled::Bundle
|
13
|
+
autoload(:Pathname, 'pathname')
|
14
|
+
|
15
|
+
# @return [Pathname]
|
16
|
+
attr_reader :path
|
17
|
+
|
18
|
+
# @param path [String, Pathname]
|
19
|
+
#
|
20
|
+
# @raise [Errno::ENOENT]
|
21
|
+
# @raise [ArgumentError] when given ``path`` is not a directory.
|
22
|
+
def initialize(path)
|
23
|
+
self.tap do
|
24
|
+
@path = Pathname.new(path).realpath.freeze
|
25
|
+
|
26
|
+
raise ArgumentError, 'path is not a directory' unless self.path.directory?
|
27
|
+
end.freeze
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String]
|
31
|
+
def to_path
|
32
|
+
path.to_path
|
33
|
+
end
|
34
|
+
|
35
|
+
# Denote lockfile (``gems.locked`` or ``Gemfile.lock``) is present.
|
36
|
+
#
|
37
|
+
# @see #gemfiles
|
38
|
+
#
|
39
|
+
# @return [Boolean]
|
40
|
+
def locked?
|
41
|
+
!!gemfiles[1]
|
42
|
+
end
|
43
|
+
|
44
|
+
# Get path to gemfile.
|
45
|
+
#
|
46
|
+
# @see #gemfiles
|
47
|
+
#
|
48
|
+
# @return [Pathname, nil]
|
49
|
+
def gemfile
|
50
|
+
gemfiles[0]
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get gemfile files (gemfile + lockfile) or nothing.
|
54
|
+
#
|
55
|
+
# @note Files are returned in pairs, gemfile and its lockfile. As a result a missing file provides empty result.
|
56
|
+
#
|
57
|
+
# @return [Array<Pathname>, nil]
|
58
|
+
def gemfiles
|
59
|
+
[%w[gems.rb gems.locked], %w[Gemfile Gemfile.lock]].map do |m|
|
60
|
+
m.map { |fname| path.join(fname) }.keep_if(&:file?)
|
61
|
+
end.reject(&:empty?).reject { |r| r.size < 2 }.first
|
62
|
+
end
|
63
|
+
|
64
|
+
# Denote bundle seems to be installed as a standalone.
|
65
|
+
#
|
66
|
+
# @see https://bundler.io/man/bundle-install.1.html
|
67
|
+
#
|
68
|
+
# @return [Boolean]
|
69
|
+
def standalone?
|
70
|
+
standalone_setupfile.file?
|
71
|
+
end
|
72
|
+
|
73
|
+
# Load standalone setup if present
|
74
|
+
#
|
75
|
+
# @return [Boolean]
|
76
|
+
def standalone!
|
77
|
+
# noinspection RubyResolve
|
78
|
+
standalone?.tap { |b| require standalone_setupfile if b }
|
79
|
+
end
|
80
|
+
|
81
|
+
protected
|
82
|
+
|
83
|
+
# @see #standalone?
|
84
|
+
#
|
85
|
+
# @return [Pathname]
|
86
|
+
def standalone_setupfile
|
87
|
+
path.join('bundle', 'bundler', 'setup.rb')
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2020-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
|
4
|
+
# License GPLv3+: GNU GPL version 3 or later
|
5
|
+
# <http://www.gnu.org/licenses/gpl.html>.
|
6
|
+
# This is free software: you are free to change and redistribute it.
|
7
|
+
# There is NO WARRANTY, to the extent permitted by law.
|
8
|
+
|
9
|
+
require_relative '../bundled'
|
10
|
+
require 'kamaze/version'
|
11
|
+
|
12
|
+
module Stibium::Bundled
|
13
|
+
# Version
|
14
|
+
#
|
15
|
+
# @type [Kamaze::Version]
|
16
|
+
VERSION = Kamaze::Version.new.freeze
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
major: 0
|
3
|
+
minor: 0
|
4
|
+
patch: 1
|
5
|
+
authors: ['Dimitri Arrigoni']
|
6
|
+
email: 'dimitri@arrigoni.me'
|
7
|
+
date: '2021-01-11'
|
8
|
+
summary: 'Denote bundle state'
|
9
|
+
description: 'Denote bundle state, based on conventions.'
|
10
|
+
homepage: 'https://github.com/SwagDevOps/stibium-bundled'
|
11
|
+
licenses: ['GPL-3.0']
|
12
|
+
license_header: |
|
13
|
+
Copyright (C) 2020-2021 Dimitri Arrigoni <dimitri@arrigoni.me>
|
14
|
+
License GPLv3+: GNU GPL version 3 or later
|
15
|
+
<http://www.gnu.org/licenses/gpl.html>.
|
16
|
+
This is free software: you are free to change and redistribute it.
|
17
|
+
There is NO WARRANTY, to the extent permitted by law.
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stibium-bundled
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dimitri Arrigoni
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: kamaze-version
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
description: Denote bundle state, based on conventions.
|
28
|
+
email: dimitri@arrigoni.me
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- ".yardopts"
|
34
|
+
- lib/stibium-bundled.rb
|
35
|
+
- lib/stibium/bundled.rb
|
36
|
+
- lib/stibium/bundled/bundle.rb
|
37
|
+
- lib/stibium/bundled/version.rb
|
38
|
+
- lib/stibium/bundled/version.yml
|
39
|
+
homepage: https://github.com/SwagDevOps/stibium-bundled
|
40
|
+
licenses:
|
41
|
+
- GPL-3.0
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 2.5.0
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubygems_version: 3.1.2
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: Denote bundle state
|
62
|
+
test_files: []
|