Class: Pod::Command::Mod::Update

Inherits:
Pod::Command::Mod show all
Defined in:
lib/cocoapods-modularization/command/mod/update.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Update

Returns a new instance of Update.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cocoapods-modularization/command/mod/update.rb', line 22

def initialize(argv)
  @name = argv.shift_argument

  version = argv.option('version', '')
  if version.length == 0
    current_version = Meta::MetaAccessor.version(@name)
    @auto_increase = true
    @version = version_auto_increase(current_version)
  else
    @auto_increase = false
    @version = version
  end

  super
end

Class Method Details

.optionsObject



16
17
18
19
20
# File 'lib/cocoapods-modularization/command/mod/update.rb', line 16

def self.options 
  [
    ['--version=VERSION', 'version of the component, if this option is not indicate, version will be auto increased']
  ].concat(super)
end

Instance Method Details

#runObject



50
51
52
53
54
55
56
57
58
# File 'lib/cocoapods-modularization/command/mod/update.rb', line 50

def run
  Meta::MetaAccessor.update_dep(@name, @version)
  UI.puts("#{@name} has been updated to #{@version}")

  if @auto_increase
    Meta::MetaReference.encode_podfile(@enable_branch)
  end
  UI.puts("Podfile encoded")
end

#validate!Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cocoapods-modularization/command/mod/update.rb', line 38

def validate!
  super
  help! "meta not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.meta_path)
  help! "data not found, run `pod sync` to fix this issue" unless File.exists?(Meta::MetaConstants.data_path)

  help! 'A component name is required.' unless @name
  dependencies = Meta::MetaAccessor.dependencies()
  help! "#{@name} not found in dependencies: #{dependencies}" unless dependencies.include?(@name)
  
  help! "version (#{@version}) illlegal" unless @version =~ /\d+\.\d+\.\d+/
end