Class: Tuya::TYLib
- Inherits:
-
Object
- Object
- Tuya::TYLib
- Defined in:
- lib/tuya/cli/odm/lib.rb
Class Method Summary collapse
- .create_lib(template) ⇒ Object
- .push_lib(config, template) ⇒ Object
- .remote_lib_exist?(url) ⇒ Boolean
- .repair_podfile_source ⇒ Object
- .repair_podspec(path, file, config, template) ⇒ Object
Class Method Details
.create_lib(template) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
24 25 26 27 28 29 30 31 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 |
# 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) ⇒ Boolean
84 85 86 87 88 89 |
# 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 ⇒ Object
60 61 62 63 64 65 66 67 68 |
# 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) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# 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 |