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.10.6 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.10.5 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.10.4 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.10.3 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.10.2 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.10.1 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.10.0 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.9.8 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.9.7 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.9.6 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.9.5 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.9.4 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.9.2 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.9.1 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.9.0 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.8.11 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.8.10 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.8.9 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.8.8 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.8.7 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb