cafe_buy 0.0.9 → 0.0.11

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 +85 -42
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: becffcc5bd4c6d0a156c0ad299e5225d556e52b214ca3777c381d474ffce2748
4
- data.tar.gz: eaf916abe14b460dea6640ad29bb27adaa6e4d50a0d60080cf85b68b79f2dd61
3
+ metadata.gz: '097e3042fa63418919feea30c257d651b94ec2c738660f6a971505b67ff07977'
4
+ data.tar.gz: 927dce10fba1243e9ff16ecebf0397389a73e76bf995b26d10953954702f6525
5
5
  SHA512:
6
- metadata.gz: eeaef8b23d987b67d8b2677b23aeec7f34923c27b425ae416ab916af624f66d46548481c73e1647e8ba70ba4bf1d36ca0f68c5034086a81627f7fe40149d6621
7
- data.tar.gz: b72c60af46235900174c8381e424b5601714182265f590a81fa70f70859194c4ca4c97a38e9bf86a525739f20c046eb13b7b2f15e6edf87fc23ff92c64787e16
6
+ metadata.gz: 5cabc0a24a2600dce1e36574ac6731b46403b10bc99656d41f9168802728574e24be19b71e64e0f969c20be8df5853ea404df6bc96d070ecb9e09459e3238776
7
+ data.tar.gz: e0f6f7612c879caccec2fcc294f81ebef7777b76052b53136f0b857c081f96c7385adff2435c8ca6fa1ed33178b050243035d309ffe76b9438ae54faac5e7270
data/lib/cafe_buy.rb CHANGED
@@ -1040,20 +1040,43 @@ end
1040
1040
  if i2.to_s.include?('<img')
1041
1041
  path = i2.to_s.split('src="')[1].split('"')[0]
1042
1042
  path = URI.decode_www_form(path)[0][0]
1043
+ # 이미지 등록 버튼 클릭
1043
1044
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[1]/button').click
1044
- sleep(2)
1045
- Clipboard.copy(path.split('/').join("\\"))
1046
- key_down('ctrl')
1047
- key_stroke('v')
1048
- key_up('ctrl')
1049
1045
  sleep(3)
1050
- key_stroke('enter')
1046
+ key_stroke('escape')
1047
+
1048
+ # 파일 경로 변환 (슬래시 -> 백슬래시)
1049
+ file_path = path.split('/').join("\\") # 윈도우 스타일 경로로 변환
1050
+
1051
+ # 파일 입력 필드 찾기 (input[type="file"])
1052
+ file_input = @driver.find_element(:id, 'hidden-file')
1053
+
1054
+ # send_keys로 파일 경로를 직접 입력하여 파일 업로드
1055
+ file_input.send_keys(file_path)
1051
1056
  sleep(3)
1052
-
1057
+
1058
+
1059
+
1060
+ begin
1061
+ @driver.action.key_down(:up).key_up(:up).perform
1062
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
1063
+ #요소가 나타날 때까지 60초 동안 기다립니다.
1064
+ wait.until { @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]') }
1065
+ sleep(1)
1066
+ @driver.find_element(:xpath, '//*[@class="se-placeholder __se_placeholder se-ff-system se-fs13"]').click
1067
+ sleep(1)
1068
+ @driver.action.send_keys(title).perform
1069
+ sleep(1)
1070
+ @driver.action.key_down(:enter).key_up(:enter).perform #엔터
1071
+ sleep(1)
1072
+ rescue
1073
+ @driver.action.key_down(:down).key_up(:down).perform
1074
+ end
1075
+
1053
1076
 
1054
1077
  if i2.to_s.split('href="')[1] != nil
1055
1078
  href2 = i2.to_s.split('href="')[1].split('"')[0]
1056
- key_stroke('up')
1079
+ @driver.action.key_down(:up).key_up(:up).perform
1057
1080
  sleep(1)
1058
1081
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[7]/div/button').click
1059
1082
  sleep(1)
@@ -1126,14 +1149,13 @@ end
1126
1149
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[1]/ul/li[5]/div/div/button['+select_number+']').click
1127
1150
  sleep(1)
1128
1151
  Clipboard.copy(i2.text)
1129
- key_down('ctrl')
1130
- key_stroke('v')
1131
- key_up('ctrl')
1132
- sleep(3)
1152
+ sleep(1)
1153
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1154
+ sleep(1)
1133
1155
 
1134
- key_stroke('down')
1156
+ @driver.action.key_down(:down).key_up(:down).perform
1135
1157
  sleep(1)
1136
- key_stroke('down')
1158
+ @driver.action.key_down(:down).key_up(:down).perform
1137
1159
  sleep(1)
1138
1160
  @driver.action.key_down(:enter).key_up(:enter).perform
1139
1161
 
@@ -1528,7 +1550,7 @@ end
1528
1550
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/header/div[2]/ul/li[15]/div/div/button').click
1529
1551
  end
1530
1552
  sleep(1)
1531
- key_stroke('right')
1553
+ @driver.action.key_down(:arrow_right).key_up(:arrow_right).perform
1532
1554
  sleep(1)
1533
1555
  end
1534
1556
  end
@@ -1582,9 +1604,8 @@ end
1582
1604
  sleep(3)
1583
1605
  # @driver.action.send_keys(soosick_1.text).perform
1584
1606
  Clipboard.copy(soosick_1.to_s)
1585
- key_down('ctrl')
1586
- key_stroke('v')
1587
- key_up('ctrl')
1607
+ sleep(1)
1608
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1588
1609
  sleep(2)
1589
1610
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/div[4]/div[2]/div/div/div[3]/div/button[2]').click
1590
1611
  sleep(3)
@@ -1602,9 +1623,8 @@ end
1602
1623
  sleep(3)
1603
1624
  # @driver.action.send_keys(soosick_2).perform
1604
1625
  Clipboard.copy(soosick_2.to_s)
1605
- key_down('ctrl')
1606
- key_stroke('v')
1607
- key_up('ctrl')
1626
+ sleep(1)
1627
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
1608
1628
  sleep(2)
1609
1629
  @driver.find_element(:xpath, '//*[@id="'+page_id+'"]/div[1]/div/div[4]/div[2]/div/div/div[3]/div/button[2]').click
1610
1630
  sleep(3)
@@ -4028,20 +4048,34 @@ class Wordpress
4028
4048
  stretchy false
4029
4049
  text "내용폴더경로 ex)C:\\내용\\폴더1"
4030
4050
  }
4031
- button('폴더째로 불러오기'){
4032
-
4033
- on_clicked{
4034
- path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
4035
- Dir.entries(@data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')).each do |file|
4036
- if file == '.' or file == '..'
4051
+ button('폴더째로 불러오기') {
4052
+ on_clicked {
4053
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4037
4054
 
4038
- else
4039
- file_data = File.open(path+'/'+file,'r', :encoding => 'utf-8').read()
4040
- @data['내용설정']['내용'] << [false, file, file_data]
4055
+ # 경로가 유효한지 확인
4056
+ if Dir.exist?(path)
4057
+ Dir.entries(path).each do |file|
4058
+ if file == '.' or file == '..'
4059
+ next
4060
+ else
4061
+ begin
4062
+ # 파일을 열고 내용을 읽어서 추가
4063
+ file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4064
+ @data['내용설정']['내용'] << [false, file, file_data]
4065
+ rescue => e
4066
+ # 파일을 열 수 없는 경우, 오류 메시지 출력
4067
+ puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4068
+ end
4069
+ end
4041
4070
  end
4071
+
4072
+ # 내용 배열에서 마지막 빈 항목 제거
4073
+ @data['내용설정']['내용'] << []
4074
+ @data['내용설정']['내용'].pop
4075
+ else
4076
+ # 경로가 유효하지 않을 경우, 오류 메시지 출력
4077
+ puts "경로가 존재하지 않습니다: #{path}"
4042
4078
  end
4043
- @data['내용설정']['내용'] << []
4044
- @data['내용설정']['내용'].pop
4045
4079
  }
4046
4080
  }
4047
4081
  }
@@ -4126,19 +4160,28 @@ class Wordpress
4126
4160
  stretchy false
4127
4161
  text "사진폴더경로 ex)C:\\사진\\폴더2"
4128
4162
  }
4129
- button('폴더째로불러오기'){
4130
-
4131
- on_clicked{
4132
- path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
4133
- Dir.entries(@data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')).each do |file|
4134
- if file == '.' or file == '..'
4163
+ button('폴더째로 불러오기') {
4164
+ on_clicked {
4165
+ path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')
4135
4166
 
4136
- else
4137
- @data['이미지설정']['이미지'] << [false, file, path+"\\"+file.force_encoding('utf-8')]
4167
+ # 경로가 유효한지 확인
4168
+ if Dir.exist?(path)
4169
+ Dir.entries(path).each do |file|
4170
+ if file == '.' or file == '..'
4171
+ next
4172
+ else
4173
+ # 폴더 내의 파일을 이미지 리스트에 추가
4174
+ @data['이미지설정']['이미지'] << [false, file, path + "\\" + file.force_encoding('utf-8')]
4175
+ end
4138
4176
  end
4177
+
4178
+ # 마지막 빈 항목 추가 후 제거 (원래 로직에 맞춰)
4179
+ @data['이미지설정']['이미지'] << []
4180
+ @data['이미지설정']['이미지'].pop
4181
+ else
4182
+ # 경로가 존재하지 않으면 경고 메시지 출력
4183
+ puts "경로가 존재하지 않습니다: #{path}"
4139
4184
  end
4140
- @data['이미지설정']['이미지'] << []
4141
- @data['이미지설정']['이미지'].pop
4142
4185
  }
4143
4186
  }
4144
4187
  }
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.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-16 00:00:00.000000000 Z
11
+ date: 2024-12-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com