cafe_buy 0.1.53 → 0.1.57

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 +67 -21
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 377206e549689ca46032b752398b86bddfdb202779e465a904faaf90045c5ab6
4
- data.tar.gz: a59c83c0b4ab6966c9c039caa7eb5aa82834bd85a95518e9b1ee637a2418882f
3
+ metadata.gz: 52cd8856cfd50d9896d4a00ffaeb1592464dd77d524a66388a7099672271a5ec
4
+ data.tar.gz: 26d4fc276e61179de3cb9b4a8e90bcbf9e90429dad62e7e5c7806f1d45ce6748
5
5
  SHA512:
6
- metadata.gz: b37d8f1d406ec35b5ae6dd9cf68b4d757c43f2297921c36aedafdda45a8d6fc478cc557afdfe16a970f54948162b6a6ddc0d9913609c349223ce466de2d859a1
7
- data.tar.gz: 0a66c5866111aaad5471e8e024662a1d3d881496691a86b71c86d2589849f69f1f03d98626b13697b575a54e68294d54c914bf996cb6f7698cd8134ec3608022
6
+ metadata.gz: 2f85498f113ae3743a318746e5bdc20942d848c99b428366b727d286b17607244691a5a9420ae3b4a9fade36e5068c94dd16eb513a3dc949a4e1888b03883bb0
7
+ data.tar.gz: 6e93c8f4fb5a81a0aff47285032c7fd4ce33505f4ed2551189cd6b19712dd7134d2139d5544046a1fa6ce56028919af84e85af2a08042d53ae990c8d3e177892
data/lib/cafe_buy.rb CHANGED
@@ -511,19 +511,29 @@ class Naver
511
511
  begin
512
512
  wait = Selenium::WebDriver::Wait.new(:timeout => 7)
513
513
  #요소가 나타날 때까지 3초 동안 기다립니다.
514
- wait.until { @driver.find_element(:xpath, '//*[@for="switch"]') }
515
- sleep(1.5)
516
- @driver.find_element(:xpath, '//*[@id="login_keep_wrap"]/div[1]/label').click
517
- sleep(1.5)
518
- @driver.find_element(:xpath, '//*[@id="id"]').click
514
+ wait.until { @driver.find_element(:xpath, '//*[@id="id" and @name="id"]') }
515
+ @driver.find_element(:xpath, '//*[@id="id" and @name="id"]').click
519
516
  Clipboard.copy(user_id)
520
517
  @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
521
518
  sleep(1.5)
522
- @driver.find_element(:xpath, '//*[@id="pw"]').click
519
+ @driver.find_element(:xpath, '//*[@id="pw" and @name="pw"]').click
523
520
  Clipboard.copy(user_pw)
524
521
  @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
525
522
  sleep(1.5)
526
- @driver.find_element(:xpath, '//*[@id="log.login"]').click
523
+
524
+ begin
525
+ smart_level_value = @driver.find_element(id: 'smart_LEVEL').attribute('value')
526
+ if smart_level_value == '1'
527
+ @driver.find_element(xpath: '//label[@for="switch" and @class="switch_btn"]').click
528
+ sleep(1.5)
529
+ end
530
+ rescue
531
+ end
532
+
533
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
534
+ #요소가 나타날 때까지 3초 동안 기다립니다.
535
+ wait.until { @driver.find_element(xpath: '//button[@type="submit" and @id="log.login"]') }
536
+ @driver.find_element(xpath: '//button[@type="submit" and @id="log.login"]').click
527
537
  sleep(2.5)
528
538
  rescue => e
529
539
  puts '-[√] 로딩 지연 접속 실패.......'.red
@@ -536,9 +546,8 @@ class Naver
536
546
  puts "Failed to close tab: #{e.message}"
537
547
  end
538
548
  end
539
- @driver.quit
540
549
  return 0
541
-
550
+ @driver.quit
542
551
  end
543
552
 
544
553
  else
@@ -546,9 +555,9 @@ class Naver
546
555
  end
547
556
 
548
557
  begin
549
- wait = Selenium::WebDriver::Wait.new(:timeout => 3)
558
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
550
559
  #요소가 나타날 때까지 3초 동안 기다립니다.
551
- wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__btn_logout___bsTOJ"]') }
560
+ wait.until { @driver.find_element(:xpath, '//*[@type="button" and @class="MyView-module__btn_logout___bsTOJ"]') }
552
561
 
553
562
  rescue => e
554
563
  puts '-[√] 로그인 실패.......'.red
@@ -561,9 +570,8 @@ class Naver
561
570
  puts "Failed to close tab: #{e.message}"
562
571
  end
563
572
  end
564
- @driver.quit
565
573
  return 0
566
-
574
+ @driver.quit
567
575
  end
568
576
  end
569
577
 
@@ -3938,15 +3946,34 @@ class Wordpress
3938
3946
  # title = content.split("\n")[0]
3939
3947
  #end
3940
3948
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
3941
- # 콘텐츠를 줄 단위로 분리
3942
3949
  content_lines = content.split("\n")
3943
-
3944
- # 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
3945
- title = content_lines.find { |line| !line.start_with?('<img src=') }
3946
-
3947
- # 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
3948
- title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
3949
-
3950
+
3951
+ title = content_lines.find do |line|
3952
+ line = line.strip
3953
+ !line.empty? && !line.start_with?('<img src=')
3954
+ end
3955
+
3956
+ title ||= content_lines[1]
3957
+
3958
+ if title
3959
+ # 마침표(.) 포함 첫 문장 추출
3960
+ first_part = title[/.*?\./]
3961
+ first_part = first_part ? first_part.strip : title.strip
3962
+
3963
+ # 200bytes 제한 (한글 100자 내외)
3964
+ bytes_limit = 200
3965
+ truncated = ""
3966
+ current_bytes = 0
3967
+
3968
+ first_part.each_char do |char|
3969
+ char_bytes = char.bytesize
3970
+ break if current_bytes + char_bytes > bytes_limit
3971
+ truncated << char
3972
+ current_bytes += char_bytes
3973
+ end
3974
+
3975
+ title = truncated
3976
+ end
3950
3977
  end
3951
3978
 
3952
3979
  if @data['포스트설정']['제목을내용첫줄입력'].checked?
@@ -3970,6 +3997,25 @@ class Wordpress
3970
3997
  @data['table'] << []
3971
3998
  @data['table'].pop
3972
3999
 
4000
+ # content를 줄 단위로 쪼갬
4001
+ lines = content.lines
4002
+
4003
+ # 맨 앞부터 빈 줄(공백 또는 빈 문자열) 갯수 계산
4004
+ empty_line_count = 0
4005
+ lines.each do |line|
4006
+ if line.strip.empty?
4007
+ empty_line_count += 1
4008
+ else
4009
+ break
4010
+ end
4011
+ end
4012
+
4013
+ # 앞 빈 줄 제거
4014
+ lines = lines.drop(empty_line_count)
4015
+
4016
+ # 다시 content로 합침
4017
+ content = lines.join
4018
+
3973
4019
  p option
3974
4020
 
3975
4021
  dd_time = @data['table'][index][9].to_s.force_encoding('utf-8').to_i
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.53
4
+ version: 0.1.57
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-26 00:00:00.000000000 Z
10
+ date: 2025-07-08 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: mymin26@naver.com