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
# File 'lib/cocoapods-modularization/command/mod/update.rb', line 22

def initialize(argv)
  @name = argv.shift_argument

  version = Meta::MetaAccessor.version(@name)
  @version = argv.option('version', version_auto_increase(version))
  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



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

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

  Meta::MetaReference.encode_podfile
  UI.puts("Podfile encoded")
end

#validate!Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cocoapods-modularization/command/mod/update.rb', line 30

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