cafe_basics_duo 0.0.52 → 0.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cafe_basics_duo.rb +66 -59
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26f9b1c4d78f5e721914e66547f94f7f25db5eba9f8518dca7ab75eb8004d930
4
- data.tar.gz: f23c7f306d676a2915fd8dc92366679f9abaee23054877c7f1913a6b40dda39d
3
+ metadata.gz: 228181735f059dfb018eceeec5bbdfd81cdf2c25afb572375d7716d808bcdec5
4
+ data.tar.gz: 15ee97f0e0b3af2e2d0028ee7802e22e70aab0755ff09c3d35763db379e7b50a
5
5
  SHA512:
6
- metadata.gz: 06efffbdb47b6a091eb195a96cdc8fef13475b30450eaf1298510818e6efd91329704ce7980698b6c9c5a9c92fe0ac25e71660999826de9351ec4fff6766a7ee
7
- data.tar.gz: f3c1dcca885e3f8270fb072ad70e632747a374320b27230c00b353562fad811c28adc09927978fdd9f8dd149df99c6ba10ef9eebade69eda6807b89517e10a8b
6
+ metadata.gz: 7153dab75607adb9dce4ea58de6597ed6ace93254442311353c4cf168dfc3d41f103f258cd317ebc4831804fa5d4ca8d2e811f831d0a2aec0d1503b7e136795e
7
+ data.tar.gz: 58f63d9fb4dc98d9fc0c6e405866a9cf677ac95cfc9b15767752dd24bcd6eefc6f6a211cacfede02f43860763c978ca38eaac9bcaf13c38d9196e951af8bea91
@@ -2213,77 +2213,53 @@ class Wordpress
2213
2213
  puts table[10]
2214
2214
  if table[7].to_i > table[10].to_i
2215
2215
  if @data['포스트설정']['테더링'].checked?
2216
- puts 'tethering ip change...'
2217
-
2218
- # ADB devices 확인
2216
+ puts 'Tethering IP change...'
2217
+
2219
2218
  stdout, stderr, status = Open3.capture3('./adb devices')
2220
- if status.success?
2219
+
2220
+ if status.success?
2221
2221
  device_id = stdout.split("\n")[1].split("\t")[0]
2222
2222
  puts device_id
2223
2223
 
2224
2224
  # ADB 서버 초기화
2225
2225
  puts 'adb kill-server'
2226
- Open3.capture3('adb kill-server')
2227
- sleep(2)
2226
+ Open3.capture3('./adb kill-server')
2227
+ sleep(3)
2228
2228
 
2229
2229
  # 다시 ADB 서버 실행
2230
2230
  puts 'adb start-server'
2231
- Open3.capture3('adb start-server')
2232
- sleep(2)
2231
+ Open3.capture3('./adb start-server')
2232
+ sleep(3)
2233
2233
 
2234
2234
  # 데이터를 끄고 켜기
2235
2235
  puts 'adb -s ' + device_id + ' shell svc data disable'
2236
- stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2237
-
2238
- if status2.success?
2239
- sleep(3)
2240
- puts 'adb -s ' + device_id + ' shell svc data enable'
2241
- Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2242
- sleep(3)
2243
- puts 'adb ok'
2244
- sleep(8)
2245
-
2246
- # IP 확인 및 재시도 (반복문 사용)
2247
- retry_count = 0
2248
- max_retries = 5
2249
- current_ip = nil
2250
-
2251
- # 무한 루프 방지
2252
- while retry_count < max_retries
2253
- begin
2254
- http = HTTP.get('https://www.findip.kr/')
2255
- noko = Nokogiri::HTML(http.to_s)
2256
- new_ip = noko.xpath('/html/body/header/h2').text.strip
2257
-
2258
- puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2259
-
2260
- # IP가 변경되었으면 @my_ip를 갱신하고 종료
2261
- if new_ip != @my_ip
2262
- @my_ip = new_ip
2263
- puts "IP 변경됨: #{@my_ip}"
2264
- break
2265
- else
2266
- puts 'IP가 변경되지 않음. 재시도...'
2267
- retry_count += 1
2268
- sleep(3) # 3초 후 재시도
2269
- end
2270
- rescue => e
2271
- retry_count += 1
2272
- sleep(3) # 3초 후 재시도
2273
- end
2274
-
2275
- # 최대 재시도 횟수를 초과하면 예외 발생시키기
2276
- if retry_count >= max_retries
2277
- raise "최대 재시도 횟수 초과. IP 변경 실패."
2278
- end
2236
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2237
+ sleep(3)
2238
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2239
+ Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2240
+ sleep(3)
2241
+ puts 'adb ok'
2242
+ sleep(8)
2243
+
2244
+ robot_ip = lambda do
2245
+ http = HTTP.get('https://www.findip.kr/')
2246
+ noko = Nokogiri::HTML(http.to_s)
2247
+ if noko.xpath('/html/body/header/h2').text != @my_ip
2248
+ @my_ip = noko.xpath('/html/body/header/h2').text
2249
+ puts "IP 변경됨[ #{@my_ip} ]"
2250
+ else
2251
+ puts @my_ip
2252
+ puts '제시도...'
2253
+ sleep(3)
2254
+ robot_ip[]
2279
2255
  end
2280
- else
2281
- puts 'Failed to disable data. Error: ' + stderr2
2282
- end
2256
+ end
2257
+ robot_ip[]
2258
+
2283
2259
  else
2284
- puts 'adb error, unable to get devices. Error: ' + stderr
2260
+ puts 'adb error pass'
2285
2261
  end
2286
- end
2262
+ end
2287
2263
 
2288
2264
 
2289
2265
  check_success = 1
@@ -2995,11 +2971,42 @@ class Wordpress
2995
2971
  end
2996
2972
  end
2997
2973
 
2974
+ #if @data['포스트설정']['지도로변경'].checked?
2975
+ # @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2976
+ # content = content.split(i.force_encoding('utf-8')).join("<koreamap>"+@data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+"</koreamap>")
2977
+ # end
2978
+ #end
2998
2979
  if @data['포스트설정']['지도로변경'].checked?
2999
- @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3000
- content = content.split(i.force_encoding('utf-8')).join("<koreamap>"+@data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+"</koreamap>")
2980
+ # 지도 주소와 사용자 설정 단어들을 가져옵니다.
2981
+ map_address = @data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8')
2982
+
2983
+ # 여러 단어로 설정된 '지도로변경단어'를 분리하여 배열로 저장
2984
+ change_words = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',')
2985
+
2986
+ # content를 각 줄로 분할
2987
+ content_lines = content.split("\n")
2988
+
2989
+ content_lines.each_with_index do |line, index|
2990
+ # 각 단어에 대해 처리
2991
+ change_words.each do |change_word|
2992
+ # 'change_word'가 포함된 줄에 대해서만 처리
2993
+ if line.include?(change_word)
2994
+ # 설정된 단어 뒤에 괄호가 있는지 확인
2995
+ if line.include?("[") && line.include?("]")
2996
+ # 괄호 안의 주소를 찾아서 그 주소는 그대로 두고, 지도로 변경된 주소로 교체
2997
+ address_in_brackets = line.match(/\[(.*?)\]/)[1] # 괄호 안의 주소를 추출
2998
+ content_lines[index] = "<koreamap>#{address_in_brackets}</koreamap>"
2999
+ else
3000
+ # 괄호가 없다면 @data['포스트설정']['지도주소']를 추가
3001
+ content_lines[index] = "<koreamap>#{map_address}</koreamap>"
3002
+ end
3003
+ end
3004
+ end
3001
3005
  end
3002
- end
3006
+
3007
+ # 다시 content로 합치기
3008
+ content = content_lines.join("\n")
3009
+ end
3003
3010
 
3004
3011
  if @data['포스트설정']['인용구변경'].checked?
3005
3012
  if @data['포스트설정']['인용구문구설정'].checked?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.52
4
+ version: 0.0.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-10 00:00:00.000000000 Z
11
+ date: 2025-02-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com