cafe_buy_duo 0.0.79 → 0.1.30

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 +63 -107
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7d98aa3880f049ac882783d77ffa0a68cd626033c562c8bd08b9cea908f9e54
4
- data.tar.gz: 1c017e16ce6e215d7c7695f41738748cb598eb75832a19443fde167fc4d66a73
3
+ metadata.gz: 60d871a7fde4f54c26b5ee22cbfcb92794439f3f701731fb8c9873ea4d8d4d26
4
+ data.tar.gz: 388fbfc1471b59266b074365fe99a19a003cb68c3c39246c747b6face4cf3557
5
5
  SHA512:
6
- metadata.gz: 66a56101aad4f3cc130848bfe36d6924379c94fd3612380809716e23a1d86a79ab424c88db5bf0e5e2695acdbc88d9109a702f49a243daad425d87c64f45f14c
7
- data.tar.gz: d66c8426987455b8d3278bc8ef07d8711a7f7ff28b26f072e42f13d9f740295828a9974282831fca965563bf028bd19ab4f7e7d78f1c4cb52b16469667c96513
6
+ metadata.gz: 713af3ca90de7989cf97b9ee0932d1b6df33d78d861be790131db7c4672d187c604e9dd0b46ae5295ba2f222b63a2ae884b26fa70c15f5ec299602ccc0fccb01
7
+ data.tar.gz: 2fa37368789201645440b6448b788b2cc46f2809fcfa6f6a5e51c8ad38d11192307fcb021943742cd15d8ed3cb71bca1055d7782592b2b34dc5b56470403d609
data/lib/cafe_buy_duo.rb CHANGED
@@ -2380,20 +2380,27 @@ class Wordpress
2380
2380
 
2381
2381
  def save_image
2382
2382
  if @data['이미지설정']['이미지'].length == 0
2383
-
2383
+ return
2384
+ end
2385
+
2386
+ if @data['이미지설정']['순서사용'].checked?
2387
+ image_path = @data['이미지설정']['이미지'][@image_counter][2]
2388
+ @image_counter += 1
2389
+ if @image_counter > @data['이미지설정']['이미지'].length - 1
2390
+ @image_counter = 0
2391
+ end
2384
2392
  else
2385
- if @data['이미지설정']['순서사용'].checked?
2386
- image_path = @data['이미지설정']['이미지'][@image_counter][2]
2387
- @image_counter += 1
2388
- if @image_counter > @data['이미지설정']['이미지'].length-1
2389
- @image_counter = 0
2390
- end
2391
- else
2392
- image_path = @data['이미지설정']['이미지'].sample[2]
2393
+ # 초기화가 안됐거나 다 썼으면 새롭게 섞는다
2394
+ @shuffled_images ||= []
2395
+ if @shuffled_images.empty?
2396
+ @shuffled_images = @data['이미지설정']['이미지'].shuffle
2393
2397
  end
2394
- img = Magick::Image.read(image_path).first
2395
- img.write('./image/memory.png')
2398
+
2399
+ image_path = @shuffled_images.shift[2]
2396
2400
  end
2401
+
2402
+ img = Magick::Image.read(image_path).first
2403
+ img.write('./image/memory.png')
2397
2404
  end
2398
2405
 
2399
2406
  def change_image_size(w)
@@ -3181,128 +3188,77 @@ class Wordpress
3181
3188
  puts '내용사진자동삽입...'
3182
3189
  sn = @data['포스트설정']['내용사진자동삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
3183
3190
  en = @data['포스트설정']['내용사진자동삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
3191
+
3184
3192
  begin
3185
3193
  cn = rand(sn..en)
3186
3194
  rescue
3187
3195
  cn = 0
3188
3196
  puts 'cn = rand(sn..en) error cn = 1'
3189
3197
  end
3190
-
3198
+
3191
3199
  if cn != 0
3192
- position = Array.new
3200
+ # content5 구성 및 위치 배열 생성
3193
3201
  if @data['포스트설정']['내용과자동생성'].checked?
3194
- if @data['포스트설정']['자동글 수식에 입력'].checked?
3195
- for n in 1..cn
3196
- position << rand(0..(content.split("(자동생성글)")[0].split("\n").length-1))
3197
- sleep(2)
3198
- end
3199
- else
3200
- for n in 1..cn
3201
- position << rand(0..(content.split("(자동생성글)")[0].split("\n").length-1))
3202
- sleep(2)
3203
- end
3204
- end
3205
- # position.pop
3206
- else
3207
- for n in 1..cn
3208
- position << rand(0..(content.split("\n").length-2))
3209
- sleep(2)
3210
- end
3211
- end
3212
-
3213
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3214
3202
  if @data['포스트설정']['자동글 수식에 입력'].checked?
3215
3203
  content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3216
3204
  content55 = content.split("(자동생성글)")[1].to_s
3205
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3217
3206
  else
3218
3207
  content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3219
3208
  content55 = content.split("(자동생성글)")[1].to_s
3209
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3220
3210
  end
3211
+ elsif @data['포스트설정']['gpt키워드'].checked?
3212
+ content5 = content.split("(자동생성글)")[1].to_s.split("\n")
3213
+ content_prefix = content.split("(자동생성글)")[0].to_s
3214
+ content55 = ''
3215
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3221
3216
  else
3217
+ content5 = content.split("\n")
3222
3218
  content55 = ''
3223
- content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3219
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3224
3220
  end
3225
-
3226
- p content5
3227
- puts content55
3228
- p position
3229
-
3221
+
3222
+ # 중복 필터링 로직
3230
3223
  while true
3231
3224
  check11 = 0
3232
- for nn in 0..position.length-1
3233
- if content5[position[nn]].to_s.include?('style') or content5[position[nn]].to_s.include?('<') or content5[position[nn]].to_s.include?('>')
3225
+ position.each_with_index do |pos, idx|
3226
+ if content5[pos].to_s.include?('style') || content5[pos].to_s.include?('<') || content5[pos].to_s.include?('>')
3234
3227
  check11 = 1
3235
- position[nn] += 4
3228
+ position[idx] += 4
3236
3229
  end
3237
3230
  end
3238
- if check11 == 0
3239
- break
3240
- end
3231
+ break if check11 == 0
3241
3232
  end
3242
-
3243
- position = position.sort
3244
- ##여기서부터 이미지 순서대로 안되서 변경####-------------------------------------------------------------------------------
3245
- # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3246
- # image_url22 = get_image_file().force_encoding('utf-8')
3247
- # end
3248
-
3249
- # position.each do |i|
3250
- # image_url = get_image_file().force_encoding('utf-8')
3251
- # puts image_url
3252
-
3253
- # puts '사진넣는위치 => '+i.to_s
3254
- # if @data['포스트설정']['내용사진링크'].checked?
3255
- # image_memory << ""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword.force_encoding('utf-8')+'"></a>'+""
3256
- # content5.insert(i, '**image**')
3257
- # else
3258
- # image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'" class="aligncenter size-full">'+""
3259
- # content5.insert(i, '**image**')
3260
- # end
3261
- # end
3262
-
3263
- # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3264
- # content = content5.join("\n")+'(자동생성글)'+content55
3265
- # iconv = Iconv.new('UTF-8', 'ASCII-8BIT')
3266
- # content = iconv.iconv(content)
3267
- # content = content.encode('UTF-8', 'binary', invalid: :replace, replace: '')
3268
- # puts content
3269
- # image_url = image_url22
3270
-
3271
- # if @data['포스트설정']['자동글 수식에 입력'].checked?
3272
-
3273
- # else
3274
- # if @data['포스트설정']['내용사진링크'].checked?
3275
- # content = content.split('(자동생성글)')[0]+""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
3276
- # else
3277
- # content = content.split('(자동생성글)')[0]+""+'<img src="'+image_url+'" alt="'+keyword+'" >'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
3278
- # end
3279
- # end
3280
- ###여기까지 이미지 순서대로 안되서 변경##-------------------------------------------------------------------------------
3281
-
3282
- ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
3283
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3233
+
3234
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
3235
+ sleep(2)
3236
+ puts '이미지 자동 세탁 중 · · · '
3237
+ end
3238
+
3239
+ p content5
3240
+ puts content55
3241
+ p position
3242
+
3284
3243
  sleep(2)
3285
- puts '이미지 자동 세탁 중 · · · '
3286
- end
3287
- sleep(2)
3288
- position.each do |i|
3289
- image_url22 = get_image_file().force_encoding('utf-8')
3290
- puts image_url22
3291
- puts '사진넣는위치 => '+i.to_s
3292
- if @data['포스트설정']['내용사진링크'].checked?
3293
- image_memory << ""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+'"><img src="'+image_url22+'" alt="'+keyword.force_encoding('utf-8')+'"></a>'+""
3294
- content5.insert(i, '**image**')
3295
- else
3296
- image_memory << ""+'<img src="'+image_url22+'" alt="'+keyword+'" class="aligncenter size-full">'+""
3297
- content5.insert(i, '**image**')
3244
+ position.each do |i|
3245
+ image_url22 = get_image_file().force_encoding('utf-8')
3246
+ if @data['포스트설정']['내용사진링크'].checked?
3247
+ image_tag = '<a href="' + @data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8') +
3248
+ '"><img src="' + image_url22 + '" alt="' + keyword.force_encoding('utf-8') + '" class="aligncenter size-full"></a>'
3249
+ else
3250
+ image_tag = '<img src="' + image_url22 + '" alt="' + keyword + '" class="aligncenter size-full">'
3251
+ end
3252
+ content5.insert(i, image_tag)
3298
3253
  end
3299
- end
3300
- sleep(2)
3301
- puts '이미지 자동 세탁 완료 · · · '
3302
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3303
- content = content5.join("\n")+'(자동생성글)'+content55
3304
- puts content
3305
- ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
3254
+
3255
+ sleep(2)
3256
+ puts '이미지 자동 세탁 완료 · · · '
3257
+
3258
+ if @data['포스트설정']['내용과자동생성'].checked?
3259
+ content = content5.join("\n") + '(자동생성글)' + content55
3260
+ elsif @data['포스트설정']['gpt키워드'].checked?
3261
+ content = content_prefix + "(자동생성글)" + content5.join("\n")
3306
3262
  else
3307
3263
  content = content5.join("\n")
3308
3264
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.79
4
+ version: 0.1.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-03-12 00:00:00.000000000 Z
10
+ date: 2025-04-17 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: File to Clipboard gem
14
13
  email: mymin26@naver.com
@@ -21,7 +20,6 @@ homepage: ''
21
20
  licenses:
22
21
  - zon
23
22
  metadata: {}
24
- post_install_message:
25
23
  rdoc_options: []
26
24
  require_paths:
27
25
  - lib
@@ -36,8 +34,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
36
34
  - !ruby/object:Gem::Version
37
35
  version: '0'
38
36
  requirements: []
39
- rubygems_version: 3.3.7
40
- signing_key:
37
+ rubygems_version: 3.6.7
41
38
  specification_version: 4
42
39
  summary: file to clipboard
43
40
  test_files: []