Class: Shard::Ref

Inherits:
Struct
  • Object
show all
Defined in:
lib/shard/ref.rb

Constant Summary collapse

PATTERN =

# Declarations #

#
%r{([a-zA-Z0-9_-]+)/(\w+)}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



3
4
5
# File 'lib/shard/ref.rb', line 3

def file
  @file
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/shard/ref.rb', line 3

def name
  @name
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



3
4
5
# File 'lib/shard/ref.rb', line 3

def user
  @user
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



3
4
5
# File 'lib/shard/ref.rb', line 3

def version
  @version
end

Class Method Details

.parse(shard_line) ⇒ Object

# Class Methods #

#


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shard/ref.rb', line 19

def self.parse(shard_line)
  if matcher = shard_line.match(PATTERN)
    user    = matcher[1]
    name    = matcher[2]
    file    = nil
    version = 'HEAD'

    new(user, name, file, version)
  else
    nil
  end
end

.valid?(shard_line) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/shard/ref.rb', line 32

def self.valid?(shard_line)
  shard_line =~ PATTERN
end