Class: Tuya::PodSpec
- Inherits:
-
Object
- Object
- Tuya::PodSpec
- Defined in:
- lib/tycli/repo/spec.rb
Class Method Summary collapse
- .ask_pod_spec ⇒ Object
- .pod_spec_version(podspec) ⇒ Object
- .podspec_files(podspec) ⇒ Object
- .repair_lib_spec(path, file, config) ⇒ Object
- .repair_source(podspec, git_url) ⇒ Object
- .update(podspec, version) ⇒ Object
Class Method Details
.ask_pod_spec ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tycli/repo/spec.rb', line 4 def self.ask_pod_spec files = podspec_files(nil) answer = "" if files.size == 1 answer = files[0] elsif files.size > 1 require 'tycli/util/ask' podspecs = Array.new files.each do |podspec_path| podspecs.push File.basename(podspec_path) end answer = Tuya::TYAsk.ask_with_answers("which podspec will be pushed", podspecs) end answer end |
.pod_spec_version(podspec) ⇒ Object
26 27 28 29 30 |
# File 'lib/tycli/repo/spec.rb', line 26 def self.pod_spec_version(podspec) content = File.read("./#{podspec}") version = (content.match(/s.version[\s]*=[\s]*'([\d]+.){2}[\d]+'/)[0]).match(/([\d]+.){2}[\d]+/)[0] version.gsub(/(\d+)$/, ((version.split(".")[-1]).to_i + 1).to_s) end |
.podspec_files(podspec) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/tycli/repo/spec.rb', line 76 def self.podspec_files(podspec) if podspec path = Pathname(podspec) raise Informative, "Couldn't find #{podspec}" unless path.exist? [path] else files = Pathname.glob('*.podspec{,.json}') # raise Informative, "Couldn't find any podspec files in current directory" if files.empty? puts "Couldn't find any podspec files in current directory".red if files.empty? files end end |
.repair_lib_spec(path, file, config) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/tycli/repo/spec.rb', line 58 def self.repair_lib_spec(path, file, config) podspec = "#{path}/#{file}" if File.exist? podspec spec_content = File.read(podspec) spec_content = repair_source(spec_content, config.url) fh = File.new(podspec, "w") fh.puts spec_content fh.close end end |
.repair_source(podspec, git_url) ⇒ Object
72 73 74 |
# File 'lib/tycli/repo/spec.rb', line 72 def self.repair_source(podspec, git_url) podspec.gsub!(/:git => (.*),/, ":git => '#{git_url}',") end |
.update(podspec, version) ⇒ Object
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 |
# File 'lib/tycli/repo/spec.rb', line 32 def self.update(podspec, version) result = Array.new files = podspec_files(podspec) files.each do |podspec_path| spec_content = File.read(podspec_path) res = spec_content.scan(/.version\s*=\s*'#{version}'/) if res.size == 0 spec_content.gsub!(/s.version\s*=(.*?)'$/, "s.version = '#{version}'") fh = File.new(podspec_path, "w") fh.puts spec_content fh.close result.push(podspec_path) end result end end |