Class: PodsOrz::PodfileModel

Inherits:
Object
  • Object
show all
Defined in:
lib/podsorz/core/PodFile/podfile_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sentence) ⇒ PodfileModel

Returns a new instance of PodfileModel.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 23

def initialize(sentence)
  sentence_slip_list = sentence.split(',')
  return if sentence_slip_list.size.zero?

  for piece in sentence_slip_list do
      if /:git =>/ =~ piece
        @git = $~.post_match.strip
      elsif /:path =>/ =~ piece
        @path = $~.post_match.strip
      elsif /:configurations =>/ =~ piece
        @configurations = $~.post_match.strip
      elsif /:modular_headers =>/ =~ piece
        @modular_headers = $~.post_match.strip
      elsif /:branch =>/ =~ piece
        @branch = $~.post_match.strip
      elsif /:tag =>/ =~ piece
        @tag = $~.post_match.strip
      elsif /pod /=~ piece
        @name = $~.post_match.delete("'\n ")
      elsif /:subspecs =>/ =~ piece
        @subspecs = $~.post_match.strip
      else
        mt = /\'\d{1,}\..*\d{1,}\'/.match(piece)
        @version = mt[0].gsub(/[\'\"]/, "") unless mt.nil?
          
      end
  end 

  # puts %Q{model name:#{@name},git:#{@git},path:#{@path},config:#{@configurations},branch:#{@branch},tag:#{@tag}}
   
end

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



6
7
8
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 6

def branch
  @branch
end

#configurationsObject

Returns the value of attribute configurations.



6
7
8
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 6

def configurations
  @configurations
end

#gitObject

Returns the value of attribute git.



6
7
8
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 6

def git
  @git
end

#modular_headersObject

Returns the value of attribute modular_headers.



6
7
8
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 6

def modular_headers
  @modular_headers
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 6

def name
  @name
end

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 6

def path
  @path
end

#podspecObject

Returns the value of attribute podspec.



6
7
8
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 6

def podspec
  @podspec
end

#subspecsObject

Returns the value of attribute subspecs.



6
7
8
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 6

def subspecs
  @subspecs
end

#tagObject

Returns the value of attribute tag.



6
7
8
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 6

def tag
  @tag
end

#versionObject

Returns the value of attribute version.



6
7
8
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 6

def version
  @version
end

Class Method Details

.validate_podfile_sentence_instance(sentence) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/podsorz/core/PodFile/podfile_model.rb', line 8

def self.validate_podfile_sentence_instance(sentence)
  result_model = nil
  
  sentence = sentence.strip.chomp
  unless sentence.empty? || sentence.size.zero?
    unless sentence.start_with?("#")
      if sentence.start_with?("pod ")
        result_model = PodsOrz::PodfileModel.new(sentence)
      end
    end 
  end

  result_model
end