cafe_buy 0.0.36 → 0.0.39

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.rb +62 -28
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a2b86e82d287673f6aeb5c149ae38ef7601a9bc7332a5c4e94a4430bb8b2b5e
4
- data.tar.gz: fd2fd84e201f97bc3af3253d37aa0cdd50217db4656a0b1090eaa5d78f055337
3
+ metadata.gz: 770e4ff2cb7dc9f603cc0e1c550f9e81ab69bf935fd079ce1dc40dd69e0a5a19
4
+ data.tar.gz: dc94edba8336c8e6367e641026c12a7c67d33f158c5b6651a0f8ccddc894f1e7
5
5
  SHA512:
6
- metadata.gz: 9e4f2a16a2fc2790b10ce4c28ec83a7656ec1441c22a830a29533b18001074d082cbb2440d886dc777ba28fe4a06e9d1d490e2171e46e4f5d26d6b763b1f8300
7
- data.tar.gz: ba36cfc6801e4c1d6f28f896f9f3df56a1068ed1197c458ea22c0476e295043a98255576b5ef7203bea26486f0b3a88c6f5ad50adacd7fa374849c47e5323a67
6
+ metadata.gz: a513632a966cb20bf9877e98e19d3d9001a7dd9e53ba9cd6af7565a29a88a6c7ca6292ddd5dcc923742f49b515d0728159bd36e45c8df84e2f8511f2659daca8
7
+ data.tar.gz: ff1f5f3aea886cf248d2a64240665194275b91459d0daf50222fbad7e9c64bd52a7642959362676aedbd2e1f4814cdc6f732b9dfe66aeb1e5120c0ba5ed7b859
data/lib/cafe_buy.rb CHANGED
@@ -359,6 +359,7 @@ class Naver
359
359
  end
360
360
  end
361
361
  return 0
362
+ @driver.quit
362
363
  end
363
364
 
364
365
  else
@@ -382,6 +383,7 @@ class Naver
382
383
  end
383
384
  end
384
385
  return 0
386
+ @driver.quit
385
387
  end
386
388
  end
387
389
 
@@ -1020,7 +1022,8 @@ end
1020
1022
  puts "Failed to close tab: #{e.message}"
1021
1023
  end
1022
1024
  end
1023
- return 0
1025
+ return 0
1026
+ @driver.quit
1024
1027
  end
1025
1028
 
1026
1029
 
@@ -1049,6 +1052,7 @@ end
1049
1052
  end
1050
1053
  end
1051
1054
  return 0
1055
+ @driver.quit
1052
1056
  end
1053
1057
  sleep(2)
1054
1058
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
@@ -1970,6 +1974,7 @@ end
1970
1974
  puts "Failed to close tab: #{e.message}"
1971
1975
  end
1972
1976
  end
1977
+ @driver.quit
1973
1978
  rescue
1974
1979
 
1975
1980
  end
@@ -2447,37 +2452,66 @@ class Wordpress
2447
2452
  puts table[10]
2448
2453
  if table[7].to_i > table[10].to_i
2449
2454
  if @data['포스트설정']['테더링'].checked?
2450
- puts 'tedering ip change...'
2451
- stdout, stderr, status = Open3.capture3('./adb devices')
2452
- if status.success?
2453
- device_id = stdout.split("\n")[1].split("\t")[0]
2454
- puts device_id
2455
- puts 'adb -s '+device_id+' shell svc data disable'
2456
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2457
- sleep(3)
2458
- puts 'adb -s '+device_id+' shell svc data enable'
2459
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2460
- sleep(3)
2461
- puts 'adb ok'
2462
- sleep(8)
2463
- robot_ip = lambda do
2464
- http = HTTP.get('https://www.findip.kr/')
2465
- noko = Nokogiri::HTML(http.to_s)
2466
- if noko.xpath('/html/body/header/h2').text != @my_ip
2467
- @my_ip = noko.xpath('/html/body/header/h2').text
2468
- else
2469
- puts @my_ip
2470
- puts '재시도...'
2471
- sleep(3)
2472
- robot_ip[]
2473
- end
2455
+ puts 'tethering ip change...'
2456
+
2457
+ # ADB devices 확인
2458
+ stdout, stderr, status = Open3.capture3('./adb devices')
2459
+ if status.success?
2460
+ device_id = stdout.split("\n")[1].split("\t")[0]
2461
+ puts device_id
2462
+ puts 'adb -s ' + device_id + ' shell svc data disable'
2463
+
2464
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2465
+ if status2.success?
2466
+ sleep(3)
2467
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2468
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2469
+ sleep(3)
2470
+ puts 'adb ok'
2471
+ sleep(8)
2472
+
2473
+ # IP 확인 및 재시도 (반복문 사용)
2474
+ retry_count = 0
2475
+ max_retries = 5
2476
+ current_ip = nil
2477
+
2478
+ # 무한 루프 방지
2479
+ while retry_count < max_retries
2480
+ begin
2481
+ http = HTTP.get('https://www.findip.kr/')
2482
+ noko = Nokogiri::HTML(http.to_s)
2483
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
2484
+
2485
+ puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2486
+
2487
+ # IP가 변경되었으면 @my_ip를 갱신하고 종료
2488
+ if new_ip != @my_ip
2489
+ @my_ip = new_ip
2490
+ puts "IP 변경됨: #{@my_ip}"
2491
+ break
2492
+ else
2493
+ puts 'IP가 변경되지 않음. 재시도...'
2494
+ retry_count += 1
2495
+ sleep(3) # 3초 후 재시도
2496
+ end
2497
+ rescue => e
2498
+ retry_count += 1
2499
+ sleep(3) # 3초 후 재시도
2474
2500
  end
2475
- robot_ip[]
2501
+
2502
+ # 최대 재시도 횟수를 초과하면 예외 발생시키기
2503
+ if retry_count >= max_retries
2504
+ raise "최대 재시도 횟수 초과. IP 변경 실패."
2505
+ end
2506
+ end
2476
2507
  else
2477
- puts 'adb error pass'
2508
+ puts 'Failed to disable data. Error: ' + stderr2
2478
2509
  end
2510
+ else
2511
+ puts 'adb error, unable to get devices. Error: ' + stderr
2512
+ end
2479
2513
  end
2480
-
2514
+
2481
2515
  check_success = 1
2482
2516
  @data['table'][index][-1] = 0
2483
2517
  if @data['제목설정']['제목'].length == 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.36
4
+ version: 0.0.39
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-06 00:00:00.000000000 Z
11
+ date: 2025-02-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com