Class: RubyEventStore::Browser::GemSource
- Inherits:
-
Object
- Object
- RubyEventStore::Browser::GemSource
- Defined in:
- lib/ruby_event_store/browser/gem_source.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #from_git? ⇒ Boolean
- #from_rubygems? ⇒ Boolean
-
#initialize(load_path) ⇒ GemSource
constructor
A new instance of GemSource.
- #version ⇒ Object
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
#path ⇒ Object (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
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
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 |
#version ⇒ Object
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 |