class Tuya::TYLib
Public Class Methods
create_lib(template)
click to toggle source
# File lib/tuya/cli/odm/lib.rb, line 3 def self.create_lib(template) name = template.configurator.pod_name system = Tuya::System.instance group = system.group config = Tuya::ConfigLib.new(group.name, name) if remote_lib_exist? config.url puts "remote #{config.name} exist".yellow else puts "\npushing #{name} to remote...".yellow push_lib config, template end puts "#{config.name}".green puts "URL- #{config.url}".green end
push_lib(config, template)
click to toggle source
# File lib/tuya/cli/odm/lib.rb, line 24 def self.push_lib(config, template) origin_path = FileUtils.pwd target_path = "#{origin_path}/#{config.name}" if File.exist? target_path FileUtils.cd target_path git_path = "#{target_path}/.git" if File.exist? git_path rm_commands = [ %W(-rf #{git_path}) ] Tuya::EXE.multi_exe('rm', rm_commands, true) end repair_podspec(target_path, "#{config.name}.podspec", config, template) FileUtils.cd "Example" repair_podfile_source FileUtils.cd ".." git_commands = [ %W(init), %W(add -A), %W(commit -am init\ #{config.name}\ by\ tuya-cli), %W(remote add origin #{config.url}), %W(push --set-upstream origin master) ] Tuya::EXE.multi_exe('git', git_commands, true) end FileUtils.cd origin_path end
remote_lib_exist?(url)
click to toggle source
# File lib/tuya/cli/odm/lib.rb, line 84 def self.remote_lib_exist?(url) result = Tuya::EXE.exe('git', %W(ls-remote #{url}), false , false ) result.include? "refs/heads/master" end
repair_podfile_source()
click to toggle source
# File lib/tuya/cli/odm/lib.rb, line 60 def self.repair_podfile_source system = Tuya::System.instance group = system.group podfile = TYCiCore::Podfile.new podfile.source_replace("# source '@{GROUP_SPEC}'", "source '#{group.url}'") podfile.save end
repair_podspec(path, file, config, template)
click to toggle source
# File lib/tuya/cli/odm/lib.rb, line 70 def self.repair_podspec(path, file, config, template) Tuya::PodSpec.repair_lib_spec(path, file, config) podspec = TYCiCore::PodSpec.new "./#{file}" summary_hash = Hash.new summary_hash['type'] = template.configurator.config.type summary_hash['appVersion'] = template.configurator.config.last_version podspec.update 'summary', summary_hash.to_json podspec.save end