Class: Tuya::TYGroup
- Inherits:
-
Object
- Object
- Tuya::TYGroup
- Defined in:
- lib/tycli/group.rb
Class Method Summary collapse
- .create_spec(group) ⇒ Object
- .create_tuya_public_inc ⇒ Object
- .create_tuya_public_inc_if_need ⇒ Object
- .is_local_repo_exist?(group_spec) ⇒ Boolean
- .is_tuya_public_inc_exist? ⇒ Boolean
- .remote_spec_exist?(group) ⇒ Boolean
- .setup_local_repo(group) ⇒ Object
- .setup_spec(group) ⇒ Object
- .status ⇒ Object
- .update_tuya_public_inc ⇒ Object
Class Method Details
.create_spec(group) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/tycli/group.rb', line 42 def self.create_spec(group) require 'tycli/config' config = Tuya::Config.new(group.name) local_spec_path = "#{config.path}spec/#{group.spec}" if File.exist? local_spec_path `rm -rf #{local_spec_path}` end `mkdir -p #{local_spec_path}` # `touch #{local_spec_path}/README.md` fh = File.new("#{local_spec_path}/README.md", 'w') fh.puts 'create by tuya-cli' fh.close origin_path = FileUtils.pwd FileUtils.cd "#{local_spec_path}" require 'tycli/executable' commands = [ %W(init), %W(add -A), %W(commit -am init\ repo\ spec), %W(remote add origin #{group.url}), %W(push --set-upstream origin master) ] Tuya::EXE.multi_exe('git', commands, true) FileUtils.cd origin_path end |
.create_tuya_public_inc ⇒ Object
118 119 120 |
# File 'lib/tycli/group.rb', line 118 def self.create_tuya_public_inc `pod repo add TYPublicSpecs https://github.com/TuyaInc/TYPublicSpecs.git` end |
.create_tuya_public_inc_if_need ⇒ Object
114 115 116 |
# File 'lib/tycli/group.rb', line 114 def self.create_tuya_public_inc_if_need create_tuya_public_inc unless is_tuya_public_inc_exist? end |
.is_local_repo_exist?(group_spec) ⇒ Boolean
102 103 104 105 106 107 108 |
# File 'lib/tycli/group.rb', line 102 def self.is_local_repo_exist?(group_spec) system = Tuya::System.instance local_path = system.pod_config.repos_dir + group_spec File.directory?(local_path) end |
.is_tuya_public_inc_exist? ⇒ Boolean
110 111 112 |
# File 'lib/tycli/group.rb', line 110 def self.is_tuya_public_inc_exist? is_local_repo_exist? 'TYPublicSpecs' end |
.remote_spec_exist?(group) ⇒ Boolean
78 79 80 81 82 83 84 85 |
# File 'lib/tycli/group.rb', line 78 def self.remote_spec_exist?(group) require 'tycli/executable' result = Tuya::EXE.exe('git', %W(ls-remote #{group.url})) result.include? "refs/heads/master" end |
.setup_local_repo(group) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/tycli/group.rb', line 87 def self.setup_local_repo(group) if is_local_repo_exist?(group.spec) system = Tuya::System.instance local_path = system.pod_config.repos_dir + group.spec FileUtils.rm_rf(local_path) end repo_add = "pod repo add #{group.spec} #{group.url}" `#{repo_add}` require 'tycli/config' puts "update local config: #{group.name}".yellow config = Tuya::Config.new(group.name) config.update_local_config end |
.setup_spec(group) ⇒ Object
37 38 39 40 |
# File 'lib/tycli/group.rb', line 37 def self.setup_spec(group) create_spec group unless remote_spec_exist? group setup_local_repo group end |
.status ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tycli/group.rb', line 10 def self.status system = Tuya::System.instance group = system.group puts "can not find tuya group, please use 'tuya group create --name=group_name'".red unless group if group puts "#{group.name}".yellow puts "- Repo: #{group.spec}".green puts "- URL: #{group.url}".green puts "\ncan not find #{group.spec}, please use 'tuya group create --name=group_name'".red unless is_local_repo_exist? group.spec end tuya_pub = is_tuya_public_inc_exist? puts "\ncan not find TYPublicSpecs please use 'pod repo add TYPublicSpecs https://github.com/TuyaInc/TYPublicSpecs.git'".red unless tuya_pub if tuya_pub puts "\nTYPublic".yellow puts "- Repo: TYPublicSpecs".green puts "- URL: https://github.com/TuyaInc/TYPublicSpecs.git".green end end |
.update_tuya_public_inc ⇒ Object
122 123 124 125 |
# File 'lib/tycli/group.rb', line 122 def self.update_tuya_public_inc puts "\nUpdate TYPublicSpecs".yellow `pod repo update TYPublicSpecs` end |