cafe_buy 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.rb +63 -107
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 391b027b4ad69447e4c5c2783220585308a9c4df0cd7a537cabdd174c22f0ff0
4
- data.tar.gz: 3ada78c482f9873b354b783e6a2d054b9018e0d029de42ae4dd960af09d56d30
3
+ metadata.gz: 2a81adfdb6db38c7c18c803598e6765f8051ec7accbc45c322caaa886fdfaff7
4
+ data.tar.gz: 1c15e95def1d4c4a7bf955210898f20c964ce22fcbba62a7b6d19c37265b8d0e
5
5
  SHA512:
6
- metadata.gz: f3a9a10fd544f713bc63d96bb075ced429f43950b7062102906a1b71f0afb86be944e24c5ca0ba5118aa966c6879256de6a8251e1b94cd56d41d511c20de0b48
7
- data.tar.gz: a1ce3d0b99136395a735d0fc71c03802647e805fa7a4a08eef3bec9f6c90868e1e7a23cd1daba5a28ad5f2c97a836684023886ecbbd53fe452d9163d8a77645e
6
+ metadata.gz: fd664c0ee759c0b525b02908d6c7fd57f8d106052dc41ee645ca568685d9042c1565ea8ed91e488abf8c627f5407a16d703d2c6fa1408e10439f75559c6d0eae
7
+ data.tar.gz: 3ef6cb65abd99bb36b7143b05dcc9f0aa5efd389d6d1e557b58c0b2653a59e1d3c24f57638377f8e08f1b000396994360aa5aba8b4bcd167091d96191889dbeb
data/lib/cafe_buy.rb CHANGED
@@ -2312,20 +2312,27 @@ class Wordpress
2312
2312
 
2313
2313
  def save_image
2314
2314
  if @data['이미지설정']['이미지'].length == 0
2315
-
2315
+ return
2316
+ end
2317
+
2318
+ if @data['이미지설정']['순서사용'].checked?
2319
+ image_path = @data['이미지설정']['이미지'][@image_counter][2]
2320
+ @image_counter += 1
2321
+ if @image_counter > @data['이미지설정']['이미지'].length - 1
2322
+ @image_counter = 0
2323
+ end
2316
2324
  else
2317
- if @data['이미지설정']['순서사용'].checked?
2318
- image_path = @data['이미지설정']['이미지'][@image_counter][2]
2319
- @image_counter += 1
2320
- if @image_counter > @data['이미지설정']['이미지'].length-1
2321
- @image_counter = 0
2322
- end
2323
- else
2324
- image_path = @data['이미지설정']['이미지'].sample[2]
2325
+ # 초기화가 안됐거나 다 썼으면 새롭게 섞는다
2326
+ @shuffled_images ||= []
2327
+ if @shuffled_images.empty?
2328
+ @shuffled_images = @data['이미지설정']['이미지'].shuffle
2325
2329
  end
2326
- img = Magick::Image.read(image_path).first
2327
- img.write('./image/memory.png')
2330
+
2331
+ image_path = @shuffled_images.shift[2]
2328
2332
  end
2333
+
2334
+ img = Magick::Image.read(image_path).first
2335
+ img.write('./image/memory.png')
2329
2336
  end
2330
2337
 
2331
2338
  def change_image_size(w)
@@ -3113,128 +3120,77 @@ class Wordpress
3113
3120
  puts '내용사진자동삽입...'
3114
3121
  sn = @data['포스트설정']['내용사진자동삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
3115
3122
  en = @data['포스트설정']['내용사진자동삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
3123
+
3116
3124
  begin
3117
3125
  cn = rand(sn..en)
3118
3126
  rescue
3119
3127
  cn = 0
3120
3128
  puts 'cn = rand(sn..en) error cn = 1'
3121
3129
  end
3122
-
3130
+
3123
3131
  if cn != 0
3124
- position = Array.new
3132
+ # content5 구성 및 위치 배열 생성
3125
3133
  if @data['포스트설정']['내용과자동생성'].checked?
3126
- if @data['포스트설정']['자동글 수식에 입력'].checked?
3127
- for n in 1..cn
3128
- position << rand(0..(content.split("(자동생성글)")[0].split("\n").length-1))
3129
- sleep(2)
3130
- end
3131
- else
3132
- for n in 1..cn
3133
- position << rand(0..(content.split("(자동생성글)")[0].split("\n").length-1))
3134
- sleep(2)
3135
- end
3136
- end
3137
- # position.pop
3138
- else
3139
- for n in 1..cn
3140
- position << rand(0..(content.split("\n").length-2))
3141
- sleep(2)
3142
- end
3143
- end
3144
-
3145
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3146
3134
  if @data['포스트설정']['자동글 수식에 입력'].checked?
3147
3135
  content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3148
3136
  content55 = content.split("(자동생성글)")[1].to_s
3137
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3149
3138
  else
3150
3139
  content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3151
3140
  content55 = content.split("(자동생성글)")[1].to_s
3141
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3152
3142
  end
3143
+ elsif @data['포스트설정']['gpt키워드'].checked?
3144
+ content5 = content.split("(자동생성글)")[1].to_s.split("\n")
3145
+ content_prefix = content.split("(자동생성글)")[0].to_s
3146
+ content55 = ''
3147
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3153
3148
  else
3149
+ content5 = content.split("\n")
3154
3150
  content55 = ''
3155
- content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3151
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3156
3152
  end
3157
-
3158
- p content5
3159
- puts content55
3160
- p position
3161
-
3153
+
3154
+ # 중복 필터링 로직
3162
3155
  while true
3163
3156
  check11 = 0
3164
- for nn in 0..position.length-1
3165
- if content5[position[nn]].to_s.include?('style') or content5[position[nn]].to_s.include?('<') or content5[position[nn]].to_s.include?('>')
3157
+ position.each_with_index do |pos, idx|
3158
+ if content5[pos].to_s.include?('style') || content5[pos].to_s.include?('<') || content5[pos].to_s.include?('>')
3166
3159
  check11 = 1
3167
- position[nn] += 4
3160
+ position[idx] += 4
3168
3161
  end
3169
3162
  end
3170
- if check11 == 0
3171
- break
3172
- end
3163
+ break if check11 == 0
3173
3164
  end
3174
-
3175
- position = position.sort
3176
- ##여기서부터 이미지 순서대로 안되서 변경####-------------------------------------------------------------------------------
3177
- # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3178
- # image_url22 = get_image_file().force_encoding('utf-8')
3179
- # end
3180
-
3181
- # position.each do |i|
3182
- # image_url = get_image_file().force_encoding('utf-8')
3183
- # puts image_url
3184
-
3185
- # puts '사진넣는위치 => '+i.to_s
3186
- # if @data['포스트설정']['내용사진링크'].checked?
3187
- # 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>'+""
3188
- # content5.insert(i, '**image**')
3189
- # else
3190
- # image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'" class="aligncenter size-full">'+""
3191
- # content5.insert(i, '**image**')
3192
- # end
3193
- # end
3194
-
3195
- # if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3196
- # content = content5.join("\n")+'(자동생성글)'+content55
3197
- # iconv = Iconv.new('UTF-8', 'ASCII-8BIT')
3198
- # content = iconv.iconv(content)
3199
- # content = content.encode('UTF-8', 'binary', invalid: :replace, replace: '')
3200
- # puts content
3201
- # image_url = image_url22
3202
-
3203
- # if @data['포스트설정']['자동글 수식에 입력'].checked?
3204
-
3205
- # else
3206
- # if @data['포스트설정']['내용사진링크'].checked?
3207
- # content = content.split('(자동생성글)')[0]+""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
3208
- # else
3209
- # content = content.split('(자동생성글)')[0]+""+'<img src="'+image_url+'" alt="'+keyword+'" >'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
3210
- # end
3211
- # end
3212
- ###여기까지 이미지 순서대로 안되서 변경##-------------------------------------------------------------------------------
3213
-
3214
- ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
3215
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3165
+
3166
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
3167
+ sleep(2)
3168
+ puts '이미지 자동 세탁 중 · · · '
3169
+ end
3170
+
3171
+ p content5
3172
+ puts content55
3173
+ p position
3174
+
3216
3175
  sleep(2)
3217
- puts '이미지 자동 세탁 중 · · · '
3218
- end
3219
- sleep(2)
3220
- position.each do |i|
3221
- image_url22 = get_image_file().force_encoding('utf-8')
3222
- puts image_url22
3223
- puts '사진넣는위치 => '+i.to_s
3224
- if @data['포스트설정']['내용사진링크'].checked?
3225
- 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>'+""
3226
- content5.insert(i, '**image**')
3227
- else
3228
- image_memory << ""+'<img src="'+image_url22+'" alt="'+keyword+'" class="aligncenter size-full">'+""
3229
- content5.insert(i, '**image**')
3176
+ position.each do |i|
3177
+ image_url22 = get_image_file().force_encoding('utf-8')
3178
+ if @data['포스트설정']['내용사진링크'].checked?
3179
+ image_tag = '<a href="' + @data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8') +
3180
+ '"><img src="' + image_url22 + '" alt="' + keyword.force_encoding('utf-8') + '" class="aligncenter size-full"></a>'
3181
+ else
3182
+ image_tag = '<img src="' + image_url22 + '" alt="' + keyword + '" class="aligncenter size-full">'
3183
+ end
3184
+ content5.insert(i, image_tag)
3230
3185
  end
3231
- end
3232
- sleep(2)
3233
- puts '이미지 자동 세탁 완료 · · · '
3234
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3235
- content = content5.join("\n")+'(자동생성글)'+content55
3236
- puts content
3237
- ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
3186
+
3187
+ sleep(2)
3188
+ puts '이미지 자동 세탁 완료 · · · '
3189
+
3190
+ if @data['포스트설정']['내용과자동생성'].checked?
3191
+ content = content5.join("\n") + '(자동생성글)' + content55
3192
+ elsif @data['포스트설정']['gpt키워드'].checked?
3193
+ content = content_prefix + "(자동생성글)" + content5.join("\n")
3238
3194
  else
3239
3195
  content = content5.join("\n")
3240
3196
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy
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: []