Class: TYCiCore::Podfile
- Inherits:
-
Object
- Object
- TYCiCore::Podfile
- Defined in:
- lib/tuya/ci/core/podfile.rb
Constant Summary collapse
- PODFILE_TARGET_METHOD =
'pod_install'
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#file ⇒ Object
Returns the value of attribute file.
-
#main_target ⇒ Object
Returns the value of attribute main_target.
-
#multi_target ⇒ Object
Returns the value of attribute multi_target.
-
#targets ⇒ Object
writeonly
Sets the attribute targets.
Instance Method Summary collapse
-
#initialize(file = './Podfile') ⇒ Podfile
constructor
A new instance of Podfile.
- #save ⇒ Object
- #source_add(source) ⇒ Object
- #source_exist(source) ⇒ Object
- #source_replace(replace_old, replace_new) ⇒ Object
- #update(updates, deletes) ⇒ Object
Constructor Details
#initialize(file = './Podfile') ⇒ Podfile
Returns a new instance of Podfile.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tuya/ci/core/podfile.rb', line 28 def initialize(file='./Podfile') @file = file puts 'Can not find a Podfile'.red unless File.exist? @file @content = File.read @file @multi_target = is_multi_target @targets = targets @main_target = @targets[0][0] if (@targets.size > 0 && @targets[0].size > 0) end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
23 24 25 |
# File 'lib/tuya/ci/core/podfile.rb', line 23 def content @content end |
#file ⇒ Object
Returns the value of attribute file.
22 23 24 |
# File 'lib/tuya/ci/core/podfile.rb', line 22 def file @file end |
#main_target ⇒ Object
Returns the value of attribute main_target.
26 27 28 |
# File 'lib/tuya/ci/core/podfile.rb', line 26 def main_target @main_target end |
#multi_target ⇒ Object
Returns the value of attribute multi_target.
24 25 26 |
# File 'lib/tuya/ci/core/podfile.rb', line 24 def multi_target @multi_target end |
#targets=(value) ⇒ Object
Sets the attribute targets
25 26 27 |
# File 'lib/tuya/ci/core/podfile.rb', line 25 def targets=(value) @targets = value end |
Instance Method Details
#save ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/tuya/ci/core/podfile.rb', line 71 def save puts "Podfile: #{@file} saved".green puts "Podfile content is: \n #{@content}".green fh = File.new(@file, "w") fh.puts @content fh.close end |
#source_add(source) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/tuya/ci/core/podfile.rb', line 49 def source_add(source) if source.nil? || source.empty? puts "source is empty".red elsif source_exist(source) puts "source #{source} alread exist".yellow else line = TYUtil::TYFile.line_contain_content(@content, "source") TYUtil::TYFile.add_to_line(@content, "source '#{source}'", line) end end |
#source_exist(source) ⇒ Object
45 46 47 |
# File 'lib/tuya/ci/core/podfile.rb', line 45 def source_exist(source) TYUtil::TYFile.line_contain_content(@content, source) > 0 end |
#source_replace(replace_old, replace_new) ⇒ Object
41 42 43 |
# File 'lib/tuya/ci/core/podfile.rb', line 41 def source_replace(replace_old, replace_new) @content.gsub!(/#{replace_old}/, replace_new) end |
#update(updates, deletes) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/tuya/ci/core/podfile.rb', line 60 def update(updates, deletes) puts "Podfile must contain at least one target".red unless @main_target if @multi_target update_pod_methods(updates, deletes) else update_single_target(updates, deletes) end end |