Class: RubyEventStore::Browser::GemSource

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/browser/gem_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(load_path) ⇒ GemSource

Returns a new instance of GemSource.



8
9
10
11
12
13
# File 'lib/ruby_event_store/browser/gem_source.rb', line 8

def initialize(load_path)
  @path =
    load_path
      .select { |entry| String === entry }
      .find { |entry| entry.match? %r{ruby_event_store-browser(?:-\d+\.\d+\.\d+)?/lib\z} }
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/ruby_event_store/browser/gem_source.rb', line 6

def path
  @path
end

Instance Method Details

#from_git?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ruby_event_store/browser/gem_source.rb', line 27

def from_git?
  path.match? %r{/bundler/gems/rails_event_store-[a-z0-9]{12}/ruby_event_store-browser/lib\z}
end

#from_rubygems?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ruby_event_store/browser/gem_source.rb', line 23

def from_rubygems?
  path.match? %r{/gems/ruby_event_store-browser-\d+\.\d+\.\d+/lib\z}
end

#versionObject



15
16
17
18
19
20
21
# File 'lib/ruby_event_store/browser/gem_source.rb', line 15

def version
  if from_rubygems?
    path.split("/").fetch(-2).split("-").last
  elsif from_git?
    path.split("/").fetch(-3).split("-").last
  end
end