Class: Horatio::Detector::RubyGem

Inherits:
Object
  • Object
show all
Includes:
NULLWritter, Validator
Defined in:
lib/horatio/detector/rubygem.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NULLWritter

#increment

Methods included from Validator

#validate, #validate_name, #validate_version

Constructor Details

#initializeRubyGem

Returns a new instance of RubyGem.



10
11
12
# File 'lib/horatio/detector/rubygem.rb', line 10

def initialize
  File.open(Dir.glob('*.gemspec').first, 'r') { |f| @spec_file = f.read }
end

Class Method Details

.detectObject



14
15
16
# File 'lib/horatio/detector/rubygem.rb', line 14

def self.detect
  Dir.glob('*.gemspec').any?
end

Instance Method Details

#descriptionObject



27
28
29
# File 'lib/horatio/detector/rubygem.rb', line 27

def description
  'Ruby gemspec'
end

#nameObject



18
19
20
# File 'lib/horatio/detector/rubygem.rb', line 18

def name
  @spec_file.match(/spec\.name.*$/i).to_s.split('=')[1].strip.gsub(/[\'\"\\]/, '')
end

#versionObject



22
23
24
25
# File 'lib/horatio/detector/rubygem.rb', line 22

def version
  File.open(Dir.glob('lib/**/version.rb').first, 'rb') { |f| @version_file = f.read }
  @version_file.match(/(\d.)+\d/).to_s.strip.gsub(/[\'\"\\]/, '')
end