Class: Gemchain::Config
- Inherits:
-
Object
- Object
- Gemchain::Config
- Defined in:
- lib/gemchain/config.rb
Defined Under Namespace
Classes: NotFoundError
Instance Attribute Summary collapse
-
#bump ⇒ Object
readonly
Returns the value of attribute bump.
-
#exclude_patterns ⇒ Object
readonly
Returns the value of attribute exclude_patterns.
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
-
#include_patterns ⇒ Object
readonly
Returns the value of attribute include_patterns.
-
#workspace ⇒ Object
readonly
Returns the value of attribute workspace.
Class Method Summary collapse
Instance Method Summary collapse
- #gem_dirs ⇒ Object
-
#initialize(workspace: Dir.pwd, include: [], exclude: [], gems: {}, bump: :patch) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(workspace: Dir.pwd, include: [], exclude: [], gems: {}, bump: :patch) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 |
# File 'lib/gemchain/config.rb', line 11 def initialize(workspace: Dir.pwd, include: [], exclude: [], gems: {}, bump: :patch) @workspace = File.(workspace) @include_patterns = [include].flatten.compact @exclude_patterns = [exclude].flatten.compact @gems = gems @bump = (bump || :patch).to_sym end |
Instance Attribute Details
#bump ⇒ Object (readonly)
Returns the value of attribute bump.
9 10 11 |
# File 'lib/gemchain/config.rb', line 9 def bump @bump end |
#exclude_patterns ⇒ Object (readonly)
Returns the value of attribute exclude_patterns.
9 10 11 |
# File 'lib/gemchain/config.rb', line 9 def exclude_patterns @exclude_patterns end |
#gems ⇒ Object (readonly)
Returns the value of attribute gems.
9 10 11 |
# File 'lib/gemchain/config.rb', line 9 def gems @gems end |
#include_patterns ⇒ Object (readonly)
Returns the value of attribute include_patterns.
9 10 11 |
# File 'lib/gemchain/config.rb', line 9 def include_patterns @include_patterns end |
#workspace ⇒ Object (readonly)
Returns the value of attribute workspace.
9 10 11 |
# File 'lib/gemchain/config.rb', line 9 def workspace @workspace end |
Class Method Details
.load(path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gemchain/config.rb', line 19 def self.load(path) path = File.(path) raise NotFoundError, "Config file not found: #{path}" unless File.exist?(path) data = YAML.safe_load(File.read(path), permitted_classes: [Regexp]) || {} new( workspace: data["workspace"] || Dir.pwd, include: data["include"] || [], exclude: data["exclude"] || [], gems: data["gems"] || {}, bump: data["bump"] || :patch ) end |
Instance Method Details
#gem_dirs ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gemchain/config.rb', line 33 def gem_dirs if @gems.any? @gems.values.map { |g| File.(g, @workspace) } else dirs = Dir.glob(@include_patterns, base: @workspace).select do |entry| full_path = File.join(@workspace, entry) File.directory?(full_path) && gemspec_in?(full_path) end.map { |entry| File.join(@workspace, entry) } if @exclude_patterns.any? excluded = Dir.glob(@exclude_patterns, base: @workspace).map { |e| File.join(@workspace, e) } dirs -= excluded end dirs end end |