Class: Pod::Command::Flutter::Archive

Inherits:
Pod::Command::Flutter show all
Defined in:
lib/cocoapods-flutter/command/flutter/archive.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command::Flutter

#validate!

Constructor Details

#initialize(argv) ⇒ Archive

Returns a new instance of Archive.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/cocoapods-flutter/command/flutter/archive.rb', line 32

def initialize(argv)
  @module_name = argv.shift_argument
  @version = [argv.option('major'), argv.option('minor'), argv.option('patch')].join "."
  # tmp_version = argv.shift_argument
  # #如果满足
  # if tmp_version =~ /([0-9]+\.)+[0-9]+/
  #   @version = tmp_version
  # else
  #   tmp_str = tmp_version.dup
  #   last_v = "0"
  #   mid_v = "0"
  #   main_v = "0"
  #   unless tmp_str.empty?
  #     last_v = tmp_str.slice!(tmp_str.length - 1, 1)
  #   end
  #   unless tmp_str.empty?
  #     mid_v = tmp_str.slice!(tmp_str.length - 1, 1)
  #   end
  #   unless tmp_str.empty?
  #     main_v = tmp_str
  #   end
  #
  #   versions = Array.new
  #   versions << main_v
  #   versions << mid_v
  #   versions << last_v
  #   @version = versions.join "."
  # end


  @build_modes = []
  @pod_repo = argv.option('repo', 'master')
  @sources = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
  @flutter_wrapper = argv.option('wrapper', 'flutter')
  @pub_upgrade = argv.flag?('upgrade', true)
  @flutter_version = argv.option('flutterversion')
  @build_run = argv.flag?('buildrun', true)
  @working_dir = Dir.pwd

  if argv.flag?('debug', true)
    @build_modes.append 'debug'
  end
  if argv.flag?('release', true)
    @build_modes.append 'release'
  end

  super
end

Class Method Details

.optionsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cocoapods-flutter/command/flutter/archive.rb', line 16

def self.options
  [
      ['--repo', 'podspec repo'],
      ['--sources', 'podspec sources'],
      ['--upgrade', 'pub upgrade'],
      ['--wrapper', 'Default is flutter'],
      ['--flutterversion', 'FlutterSDK version'],
      ['--buildrun', 'run build-runner'],
      ['--debug', 'debug mode'],
      ['--release', 'release mode'],
      ['--major', 'major version'],
      ['--minor', 'minor version'],
      ['--patch', 'patch version'],
  ].concat(Pod::Command::Repo::Push.options).concat(super).uniq
end

Instance Method Details

#default_fluttter_versionObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/cocoapods-flutter/command/flutter/archive.rb', line 86

def default_fluttter_version
  flutter_version = ''
  stdin, stdout_stderr, wait_thr = Open3.popen2e('fvm', @flutter_wrapper, '--version');
  stdout_stderr.each_line do |line|
    if line.start_with?('Flutter ')
      flutter_version = line.split('').first.split(' ').last
    end
  end
  exit_status = wait_thr.value
  if exit_status.success?
    puts stdout_stderr.gets
  else
    raise stdout_stderr.gets
  end
  stdout_stderr.close
  stdin.close
  flutter_version
end

#runObject



81
82
83
84
# File 'lib/cocoapods-flutter/command/flutter/archive.rb', line 81

def run
  archiver = Archiver.new(@module_name, @version, @sources, @flutter_wrapper, @pub_upgrade, @flutter_version, @build_run, @working_dir,@pod_repo, @build_modes)
  archiver.archive
end