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.8.6 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.8.5 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.8.4 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.8.3 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.8.0 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.33 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.31 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.30 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.29 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.28 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.27 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.26 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.25 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.24 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.23 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb
fedux_org-stdlib-0.7.22 lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb