Class: Tuya::PodSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/tuya/cli/odm/repo/spec.rb

Class Method Summary collapse

Class Method Details

.ask_pod_specObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tuya/cli/odm/repo/spec.rb', line 12

def self.ask_pod_spec

	files = podspec_files(nil)

	answer = ""

	if files.size == 1
		answer = files[0]
	elsif files.size > 1

		podspecs = Array.new
		files.each do |podspec_path|
			podspecs.push File.basename(podspec_path)
		end

		answer = TYCiCore::TYAsk.ask_with_answers("which podspec will be pushed", podspecs)
	end

	answer

end

.local_pod_version_exist(version, spec, lib_name) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/tuya/cli/odm/repo/spec.rb', line 4

def self.local_pod_version_exist(version, spec, lib_name)

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

	File.directory?(local_path)
end

.pod_spec_version(podspec) ⇒ Object



34
35
36
37
38
# File 'lib/tuya/cli/odm/repo/spec.rb', line 34

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/tuya/cli/odm/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



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/tuya/cli/odm/repo/spec.rb', line 57

def self.repair_lib_spec(path, file, config)

	# TUDO 这里使用旧实现, 未迁移tuya-ci-core
	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/tuya/cli/odm/repo/spec.rb', line 72

def self.repair_source(podspec, git_url)
	podspec.gsub!(/:git => (.*),/, ":git => '#{git_url}',")
end

.update(podspec, version) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/tuya/cli/odm/repo/spec.rb', line 40

def self.update(podspec, version)

	result = Array.new

	files = podspec_files(podspec)

	files.each do |podspec_path|
		podspec = TYCiCore::PodSpec.new "./#{podspec_path}"
		if podspec.update 'version', version
			# podspec.update 'summary', ""
			result.push(podspec_path)
		end
		podspec.save
		result
	end
end