Class: CarthageDependency
- Inherits:
-
Object
- Object
- CarthageDependency
- Defined in:
- lib/carthage_dependency.rb
Overview
Representation of a Cartfile.resolved entry.
Instance Attribute Summary collapse
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
-
.parse_cartfile_resolved_line(line) ⇒ Object
Parses Cartfile.resolved dependency entry, e.g.
Instance Method Summary collapse
-
#guessed_framework_basename ⇒ Object
Since one Cartfile.resolved entry may produce multiple differently named frameworks, this is an entry point to identifying a framework name.
-
#initialize(args) ⇒ CarthageDependency
constructor
A new instance of CarthageDependency.
- #new_version_file ⇒ Object
- #to_s ⇒ Object
- #verify_version_in_version_file(version_file) ⇒ Object
- #version_filename ⇒ Object
- #version_filepath ⇒ Object
Constructor Details
#initialize(args) ⇒ CarthageDependency
Returns a new instance of CarthageDependency.
21 22 23 24 25 26 27 28 |
# File 'lib/carthage_dependency.rb', line 21 def initialize(args) raise AppError.new, "Expected Symbol for origin '#{args[:origin]}'" unless args[:origin].kind_of? Symbol raise AppError.new, "Unrecognized origin '#{args[:oriign]}'" unless [:github, :git, :binary].include?(args[:origin]) @origin = args[:origin] @source = args[:source] @version = args[:version] end |
Instance Attribute Details
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
19 20 21 |
# File 'lib/carthage_dependency.rb', line 19 def origin @origin end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
19 20 21 |
# File 'lib/carthage_dependency.rb', line 19 def source @source end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
19 20 21 |
# File 'lib/carthage_dependency.rb', line 19 def version @version end |
Class Method Details
.parse_cartfile_resolved_line(line) ⇒ Object
Parses Cartfile.resolved dependency entry, e.g.
github "CocoaLumberjack/CocoaLumberjack" "3.2.1"
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/carthage_dependency.rb', line 7 def parse_cartfile_resolved_line(line) line.strip! matches = line.match(/^(\w+)\s+\"([^\"]+)\"(\s+\"([^\"]+)\")$/) return nil if matches.nil? if matches.length == 5 CarthageDependency.new(origin: matches[1].to_sym, source: matches[2], version: matches[4]) else nil end end |
Instance Method Details
#guessed_framework_basename ⇒ Object
Since one Cartfile.resolved entry may produce multiple differently named frameworks, this is an entry point to identifying a framework name.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/carthage_dependency.rb', line 36 def guessed_framework_basename case @origin when :github @source.split("/").last when :git filename = @source.split("/").last filename.chomp(".git") when :binary filename = @source.split("/").last filename.chomp(".json") else raise AppError.new, "Unrecognized origin '#{@origin}'" end end |
#new_version_file ⇒ Object
30 31 32 |
# File 'lib/carthage_dependency.rb', line 30 def new_version_file VersionFile.new(version_filepath) end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/carthage_dependency.rb', line 65 def to_s "#{@origin.to_s} \"#{@source}\" \"#{@version}\"" end |
#verify_version_in_version_file(version_file) ⇒ Object
59 60 61 62 63 |
# File 'lib/carthage_dependency.rb', line 59 def verify_version_in_version_file(version_file) if @version != version_file.version raise OutdatedFrameworkBuildError.new(guessed_framework_basename, version_file.version, @version) end end |
#version_filename ⇒ Object
51 52 53 |
# File 'lib/carthage_dependency.rb', line 51 def version_filename ".#{guessed_framework_basename}.version" end |
#version_filepath ⇒ Object
55 56 57 |
# File 'lib/carthage_dependency.rb', line 55 def version_filepath File.join(CARTHAGE_BUILD_DIR, version_filename) end |