module Gemnasium::Parser::Patterns
Constants
- ADD_DEPENDENCY_CALL
- ARRAY
- BOOLEAN
- COMMENT
- ELEMENT
- GEMSPEC_CALL
- GEM_CALL
- GEM_NAME
- GIT_CALL
- GROUP_CALL
- KEY
- MATCHER
- NIL
- OPTIONS
- PAIR
- PATH_CALL
- QUOTED_GEM_NAME
- REQUIREMENT
- REQUIREMENTS
- REQUIREMENT_LIST
- STRING
- SYMBOL
- SYMBOLS
- VALUE
- VERSION
Public Class Methods
key(string)
click to toggle source
# File lib/gemnasium/parser/patterns.rb, line 46 def self.key(string) string.tr(%Q(:"'), "") end
options(string)
click to toggle source
# File lib/gemnasium/parser/patterns.rb, line 38 def self.options(string) {}.tap do |hash| return hash unless string pairs = Hash[*string.match(OPTIONS).captures.compact] pairs.each{|k,v| hash[key(k)] = value(v) } end end
value(string)
click to toggle source
# File lib/gemnasium/parser/patterns.rb, line 50 def self.value(string) case string when ARRAY then values(string.tr("[]", "")) when SYMBOL then string.tr(%Q(:"'), "").to_sym when STRING then string.tr(%Q("'), "") when BOOLEAN then string == "true" when NIL then nil end end
values(string)
click to toggle source
# File lib/gemnasium/parser/patterns.rb, line 60 def self.values(string) string.strip.split(/[ \t]*,[ \t]*/).map{|v| value(v) } end