cafe_buy_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_buy_duo.rb +66 -59
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0136552ddaba493a7d8c3464b46ffb189e4eb6a8d4059a68208b19feb847b05a
4
- data.tar.gz: d29b471e5758727c56cc18fc2f9fcbcbbbcd02f63232d6d4bbb121e131a1021b
3
+ metadata.gz: 4e8c0715161ebfe6236814a50a5fb9507c083e4a147e08abb8844c5bc7283f48
4
+ data.tar.gz: 23097cf5b32395afaaab17c783b57781865989a029768fbdbbbd11fc40145ee4
5
5
  SHA512:
6
- metadata.gz: 18380c6f2ac2d876172c8421f9c21f3b051110e56c9f65ead78d3bddb151eac004bbfbcabd308db2cf8752d9334ed8c519e4002896601b4d276f1f1948e498a7
7
- data.tar.gz: bd46204c66bd1762fba2974a928e913cda2291701edc3bf2923ecf58daa31b74369ab19ebee00e887ae8345a55bab4d349822f5b43d3db1f877fbbaea1950966
6
+ metadata.gz: d9424345c2925f0a2fdcc5864c47c70886e39996b53c34edb27554233e377c8e9a0085c81bf7ed162a24b9a85bd0c3fe135d8224c8c916cde4c68d7946f33bcb
7
+ data.tar.gz: 9d12375ccf2e81587ad64063736798b3b051a21479ab5bd5aa007c8cd4d390ccdcdf20e07d83b16ec0879d28fe48d67fb90cec5084cf5a378e438b161ab0c4a5
data/lib/cafe_buy_duo.rb CHANGED
@@ -2543,77 +2543,53 @@ class Wordpress
2543
2543
  puts table[10]
2544
2544
  if table[7].to_i > table[10].to_i
2545
2545
  if @data['포스트설정']['테더링'].checked?
2546
- puts 'tethering ip change...'
2547
-
2548
- # ADB devices 확인
2546
+ puts 'Tethering IP change...'
2547
+
2549
2548
  stdout, stderr, status = Open3.capture3('./adb devices')
2550
- if status.success?
2549
+
2550
+ if status.success?
2551
2551
  device_id = stdout.split("\n")[1].split("\t")[0]
2552
2552
  puts device_id
2553
2553
 
2554
2554
  # ADB 서버 초기화
2555
2555
  puts 'adb kill-server'
2556
- Open3.capture3('adb kill-server')
2557
- sleep(2)
2556
+ Open3.capture3('./adb kill-server')
2557
+ sleep(3)
2558
2558
 
2559
2559
  # 다시 ADB 서버 실행
2560
2560
  puts 'adb start-server'
2561
- Open3.capture3('adb start-server')
2562
- sleep(2)
2561
+ Open3.capture3('./adb start-server')
2562
+ sleep(3)
2563
2563
 
2564
2564
  # 데이터를 끄고 켜기
2565
2565
  puts 'adb -s ' + device_id + ' shell svc data disable'
2566
- stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2567
-
2568
- if status2.success?
2569
- sleep(3)
2570
- puts 'adb -s ' + device_id + ' shell svc data enable'
2571
- Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2572
- sleep(3)
2573
- puts 'adb ok'
2574
- sleep(8)
2575
-
2576
- # IP 확인 및 재시도 (반복문 사용)
2577
- retry_count = 0
2578
- max_retries = 5
2579
- current_ip = nil
2580
-
2581
- # 무한 루프 방지
2582
- while retry_count < max_retries
2583
- begin
2584
- http = HTTP.get('https://www.findip.kr/')
2585
- noko = Nokogiri::HTML(http.to_s)
2586
- new_ip = noko.xpath('/html/body/header/h2').text.strip
2587
-
2588
- puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2589
-
2590
- # IP가 변경되었으면 @my_ip를 갱신하고 종료
2591
- if new_ip != @my_ip
2592
- @my_ip = new_ip
2593
- puts "IP 변경됨: #{@my_ip}"
2594
- break
2595
- else
2596
- puts 'IP가 변경되지 않음. 재시도...'
2597
- retry_count += 1
2598
- sleep(3) # 3초 후 재시도
2599
- end
2600
- rescue => e
2601
- retry_count += 1
2602
- sleep(3) # 3초 후 재시도
2603
- end
2604
-
2605
- # 최대 재시도 횟수를 초과하면 예외 발생시키기
2606
- if retry_count >= max_retries
2607
- raise "최대 재시도 횟수 초과. IP 변경 실패."
2608
- end
2566
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2567
+ sleep(3)
2568
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2569
+ Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2570
+ sleep(3)
2571
+ puts 'adb ok'
2572
+ sleep(8)
2573
+
2574
+ robot_ip = lambda do
2575
+ http = HTTP.get('https://www.findip.kr/')
2576
+ noko = Nokogiri::HTML(http.to_s)
2577
+ if noko.xpath('/html/body/header/h2').text != @my_ip
2578
+ @my_ip = noko.xpath('/html/body/header/h2').text
2579
+ puts "IP 변경됨[ #{@my_ip} ]"
2580
+ else
2581
+ puts @my_ip
2582
+ puts '제시도...'
2583
+ sleep(3)
2584
+ robot_ip[]
2609
2585
  end
2610
- else
2611
- puts 'Failed to disable data. Error: ' + stderr2
2612
- end
2586
+ end
2587
+ robot_ip[]
2588
+
2613
2589
  else
2614
- puts 'adb error, unable to get devices. Error: ' + stderr
2590
+ puts 'adb error pass'
2615
2591
  end
2616
- end
2592
+ end
2617
2593
 
2618
2594
 
2619
2595
  check_success = 1
@@ -3320,11 +3296,42 @@ class Wordpress
3320
3296
  end
3321
3297
  end
3322
3298
 
3299
+ #if @data['포스트설정']['지도로변경'].checked?
3300
+ # @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3301
+ # content = content.split(i.force_encoding('utf-8')).join("<koreamap>"+@data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+"</koreamap>")
3302
+ # end
3303
+ #end
3323
3304
  if @data['포스트설정']['지도로변경'].checked?
3324
- @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3325
- content = content.split(i.force_encoding('utf-8')).join("<koreamap>"+@data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+"</koreamap>")
3305
+ # 지도 주소와 사용자 설정 단어들을 가져옵니다.
3306
+ map_address = @data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8')
3307
+
3308
+ # 여러 단어로 설정된 '지도로변경단어'를 분리하여 배열로 저장
3309
+ change_words = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',')
3310
+
3311
+ # content를 각 줄로 분할
3312
+ content_lines = content.split("\n")
3313
+
3314
+ content_lines.each_with_index do |line, index|
3315
+ # 각 단어에 대해 처리
3316
+ change_words.each do |change_word|
3317
+ # 'change_word'가 포함된 줄에 대해서만 처리
3318
+ if line.include?(change_word)
3319
+ # 설정된 단어 뒤에 괄호가 있는지 확인
3320
+ if line.include?("[") && line.include?("]")
3321
+ # 괄호 안의 주소를 찾아서 그 주소는 그대로 두고, 지도로 변경된 주소로 교체
3322
+ address_in_brackets = line.match(/\[(.*?)\]/)[1] # 괄호 안의 주소를 추출
3323
+ content_lines[index] = "<koreamap>#{address_in_brackets}</koreamap>"
3324
+ else
3325
+ # 괄호가 없다면 @data['포스트설정']['지도주소']를 추가
3326
+ content_lines[index] = "<koreamap>#{map_address}</koreamap>"
3327
+ end
3328
+ end
3329
+ end
3326
3330
  end
3327
- end
3331
+
3332
+ # 다시 content로 합치기
3333
+ content = content_lines.join("\n")
3334
+ end
3328
3335
 
3329
3336
  if @data['포스트설정']['인용구변경'].checked?
3330
3337
  if @data['포스트설정']['인용구문구설정'].checked?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy_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