cafe_buy_duo 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_duo.rb +86 -43
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d65271cc0e81c8df5a7e404222b8e16659b2ba670495c888b42ecb4d1153877d
4
- data.tar.gz: d3fff9aff2a8d8476448a5b39b7dde0ad667c50fe378530c6994127f458612a7
3
+ metadata.gz: 62b5bdbc76a52f74d44f933c96ca76668575b5ad009d7d6f565c4915dee8f846
4
+ data.tar.gz: 4b23f2d5714c23cbc8df08e04c94fc7c92f7da6bf2eae3bdbb7a6389b9601215
5
5
  SHA512:
6
- metadata.gz: 62095cb35919abf1b7eb13b756ea6313c9ee9db6c9803935c26be17124baa50be4b7b94deff19b03ec308e1c1d922a12c85c4c481515b5994d09a3ae5b9817e9
7
- data.tar.gz: 3501381d70f6419eca40346adf31133bb85cbfb70617489c1875fcc1a3ea4ff621f185448265a0439f2fbcd93ee19ef4f6d6a8bd39a247215fa0f66531b81df1
6
+ metadata.gz: 5de9d54b03e3777c2f9f9d4fff197c4a6a8c66fc13b0967a116b06caadc62f03013d0c156857bb85dcd1481fd57e83fc32faa13ba4c2c8d783e87a080586d86a
7
+ data.tar.gz: 30e2304ac80f250ce69be1f4bbb8d3e8c94f062bc9cac1f981f2518f100ba01459509c1826b1444dbc31a2198e5c6583f8c999e0f1d149de524c83bf2a93639a
data/lib/cafe_buy_duo.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)
@@ -4102,20 +4122,34 @@ class Wordpress
4102
4122
  stretchy false
4103
4123
  text "내용폴더경로 ex)C:\\내용\\폴더1"
4104
4124
  }
4105
- button('폴더째로 불러오기'){
4106
-
4107
- on_clicked{
4108
- path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
4109
- Dir.entries(@data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')).each do |file|
4110
- if file == '.' or file == '..'
4125
+ button('폴더째로 불러오기') {
4126
+ on_clicked {
4127
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4111
4128
 
4112
- else
4113
- file_data = File.open(path+'/'+file,'r', :encoding => 'utf-8').read()
4114
- @data['내용설정']['내용'] << [false, file, file_data]
4129
+ # 경로가 유효한지 확인
4130
+ if Dir.exist?(path)
4131
+ Dir.entries(path).each do |file|
4132
+ if file == '.' or file == '..'
4133
+ next
4134
+ else
4135
+ begin
4136
+ # 파일을 열고 내용을 읽어서 추가
4137
+ file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4138
+ @data['내용설정']['내용'] << [false, file, file_data]
4139
+ rescue => e
4140
+ # 파일을 열 수 없는 경우, 오류 메시지 출력
4141
+ puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4142
+ end
4143
+ end
4115
4144
  end
4145
+
4146
+ # 내용 배열에서 마지막 빈 항목 제거
4147
+ @data['내용설정']['내용'] << []
4148
+ @data['내용설정']['내용'].pop
4149
+ else
4150
+ # 경로가 유효하지 않을 경우, 오류 메시지 출력
4151
+ puts "경로가 존재하지 않습니다: #{path}"
4116
4152
  end
4117
- @data['내용설정']['내용'] << []
4118
- @data['내용설정']['내용'].pop
4119
4153
  }
4120
4154
  }
4121
4155
  }
@@ -4200,19 +4234,28 @@ class Wordpress
4200
4234
  stretchy false
4201
4235
  text "사진폴더경로 ex)C:\\사진\\폴더2"
4202
4236
  }
4203
- button('폴더째로불러오기'){
4204
-
4205
- on_clicked{
4206
- path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')
4207
- Dir.entries(@data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')).each do |file|
4208
- if file == '.' or file == '..'
4209
-
4210
- else
4211
- @data['이미지설정']['이미지'] << [false, file, path+"\\"+file.force_encoding('utf-8')]
4237
+ button('폴더째로 불러오기') {
4238
+ on_clicked {
4239
+ path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')
4240
+
4241
+ # 경로가 유효한지 확인
4242
+ if Dir.exist?(path)
4243
+ Dir.entries(path).each do |file|
4244
+ if file == '.' or file == '..'
4245
+ next
4246
+ else
4247
+ # 폴더 내의 파일을 이미지 리스트에 추가
4248
+ @data['이미지설정']['이미지'] << [false, file, path + "\\" + file.force_encoding('utf-8')]
4249
+ end
4212
4250
  end
4251
+
4252
+ # 마지막 빈 항목 추가 후 제거 (원래 로직에 맞춰)
4253
+ @data['이미지설정']['이미지'] << []
4254
+ @data['이미지설정']['이미지'].pop
4255
+ else
4256
+ # 경로가 존재하지 않으면 경고 메시지 출력
4257
+ puts "경로가 존재하지 않습니다: #{path}"
4213
4258
  end
4214
- @data['이미지설정']['이미지'] << []
4215
- @data['이미지설정']['이미지'].pop
4216
4259
  }
4217
4260
  }
4218
4261
  }
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.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