Class: OrganizeGemfile::BundleParser
- Inherits:
-
Object
- Object
- OrganizeGemfile::BundleParser
- Defined in:
- lib/organize_gemfile/bundle_parser.rb
Instance Method Summary collapse
- #groups ⇒ Object
-
#initialize(gemfile_path, gemfile_lock_path) ⇒ BundleParser
constructor
A new instance of BundleParser.
- #ruby_version ⇒ Object
Constructor Details
#initialize(gemfile_path, gemfile_lock_path) ⇒ BundleParser
Returns a new instance of BundleParser.
3 4 5 6 7 8 9 |
# File 'lib/organize_gemfile/bundle_parser.rb', line 3 def initialize(gemfile_path, gemfile_lock_path) @gemfile_path = gemfile_path @gemfile_lock_path = gemfile_lock_path @dsl = Bundler::Definition.build(@gemfile_path, @gemfile_lock_path, {}) @requires = @dsl.requires @sources = sources end |
Instance Method Details
#groups ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/organize_gemfile/bundle_parser.rb', line 11 def groups ret = {} before_default = @sources.select { |source| source[:appear_at_top] == true } if before_default.any? ret["before_default"] = GemfileGroup.new(:before_default, before_default) end @sources.reject { |source| source[:appear_at_top] == true } .group_by { |source| source[:groups] } .map do |group, sources| ret[group.map(&:to_s).join("_")] = GemfileGroup.new(group, sources) end ret end |
#ruby_version ⇒ Object
28 29 30 |
# File 'lib/organize_gemfile/bundle_parser.rb', line 28 def ruby_version @dsl.ruby_version&.versions&.first end |