class Tuya::PodSpec

Public Class Methods

ask_pod_spec() click to toggle source
# File lib/tycli/repo/spec.rb, line 14
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

                require 'tuya/ci/core'
                answer = TYCiCore::TYAsk.ask_with_answers("which podspec will be pushed", podspecs)
        end

        answer

end
local_pod_version_exist(version, spec, lib_name) click to toggle source
# File lib/tycli/repo/spec.rb, line 4
def self.local_pod_version_exist(version, spec, lib_name)

        require 'tycli/system'

        system = Tuya::System.instance
        local_path = system.pod_config.repos_dir + spec + lib_name + version

        File.directory?(local_path)
end
pod_spec_version(podspec) click to toggle source
# File lib/tycli/repo/spec.rb, line 38
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) click to toggle source
# File lib/tycli/repo/spec.rb, line 88
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) click to toggle source
# File lib/tycli/repo/spec.rb, line 70
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) click to toggle source
# File lib/tycli/repo/spec.rb, line 84
def self.repair_source(podspec, git_url)
        podspec.gsub!(/:git => (.*),/, ":git => '#{git_url}',")
end
update(podspec, version) click to toggle source
# File lib/tycli/repo/spec.rb, line 44
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