Sha256: b4a85c2b8248319e33d352cb181edd7e42fa7a7036dad672a21df664b60d52f6

Contents?: true

Size: 635 Bytes

Versions: 56

Compression:

Stored size: 635 Bytes

Contents

# encoding: utf-8
require 'json'
require 'fedux_org_stdlib/version_management/exceptions'

module FeduxOrgStdlib
  # Version management
  module VersionManagement
    # Ruby version file parser
    class RubygemVersionFileParser
      attr_reader :version, :modules

      def parse(file)
        data = File.read(file)

        @version = data.match(/(?:VERSION|Version)\s+=\s+["']([^'"]+)["']/) { Regexp.last_match[1] }
        @modules = data.scan(/^\s*module\s+([A-Z][A-Za-z0-9]+(?:::[A-Z][A-Z0-9a-z]+)*)$/x).flatten

        fail Exceptions::VersionFileInvalid, JSON.dump(file: file) if version.blank?
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.11.18 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.17 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.16 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.15 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.14 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.12 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.11 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.9 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.8 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.7 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.6 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.5 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.4 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.3 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.2 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.1 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.11.0 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.10.9 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.10.8 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.10.7 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb