Class: Tuya::TYLib
- Inherits:
-
Object
- Object
- Tuya::TYLib
- Defined in:
- lib/tycli/lib.rb
Class Method Summary collapse
- .create_lib(name) ⇒ Object
- .push_lib(config) ⇒ Object
- .remote_lib_exist?(url) ⇒ Boolean
- .repair_podspec(path, file, config) ⇒ Object
Class Method Details
.create_lib(name) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/tycli/lib.rb', line 3 def self.create_lib(name) require 'tycli/config' require 'tycli/system' 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 "\n pushing #{name} to remote...".yellow push_lib config end puts "#{config.name}".green puts "URL- #{config.url}".green end |
.push_lib(config) ⇒ Object
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 |
# File 'lib/tycli/lib.rb', line 25 def self.push_lib(config) origin_path = FileUtils.pwd target_path = "#{origin_path}/#{config.name}" if File.exist? target_path FileUtils.cd target_path git_path = "#{target_path}/.git" require 'tycli/executable' 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) 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
64 65 66 67 68 69 70 71 |
# File 'lib/tycli/lib.rb', line 64 def self.remote_lib_exist?(url) require 'tycli/executable' result = Tuya::EXE.exe('git', %W(ls-remote #{url})) result.include? "refs/heads/master" end |
.repair_podspec(path, file, config) ⇒ Object
59 60 61 62 |
# File 'lib/tycli/lib.rb', line 59 def self.repair_podspec(path, file, config) require 'tycli/repo/spec' Tuya::PodSpec.repair_lib_spec(path, file, config) end |