nblog_duo 111.117.789 → 111.117.899

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/nblog_duo.rb +87 -43
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8aacf440b1da5f2bf2010e1e6a77d25bd64bd842e5fe05fc5e1106713279956f
4
- data.tar.gz: 465893a34609ca2146eeaea1ccb6d7d2b360775ad8ee29da454aa4b390ebde15
3
+ metadata.gz: 3dca8d43aa8ce9857fae764c20dfdc93c6de95eb315af750208ffeb8f4d92dd5
4
+ data.tar.gz: ca6e45937b0854f98f518e93379819dcce61ab1d97c3b5d91b22a099bd671b98
5
5
  SHA512:
6
- metadata.gz: 427d5445e0c14c2e83981478823477e186a0c333dac46b25ea4db0cc5bad7703042d37c4bb85cd86243fa6f32db59df1f1041dcb251bae1f7f97aba6a266dcb1
7
- data.tar.gz: 88bea7627f4c17ca3a2526c5f85daa3668b2513e7f7674d4bbfba90738813ea63afb1fcb6695dcee1c4ee583eca11596dead6636683e5be9de405e20a9ad8fd4
6
+ metadata.gz: b73e52c2b875f5ce875cbfa6d683004a226b27211a9126066c0df7f76766085aa17fe9b4d418ff016038f664a19bb545b27a4003578ee83b63f5ad44324f2711
7
+ data.tar.gz: d8a73b56344d7104ef740daaef7912a6bef2582fcc87e487c59d8843949833924d8e6b7f92673ce983754d1e7da4e4625c02bfba463683c9d42c96d979f38775
data/lib/nblog_duo.rb CHANGED
@@ -243,37 +243,37 @@ end
243
243
  class Naver
244
244
  def initialize
245
245
  @seed = 1
246
- kill_selenium_chrome #기존 창 모두 닫는 명령
247
- sleep(1)
246
+ #kill_selenium_chrome #기존 창 모두 닫는 명령
247
+ #sleep(1)
248
248
  end
249
249
 
250
- def kill_selenium_chrome #기존 창 모두 닫는 코드
251
- wmi = WIN32OLE.connect("winmgmts://")
252
- chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
250
+ #def kill_selenium_chrome #기존 창 모두 닫는 코드
251
+ # wmi = WIN32OLE.connect("winmgmts://")
252
+ # chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
253
253
 
254
- chrome_procs.each do |proc|
255
- cmd = proc.CommandLine
256
- if cmd && cmd.include?("user-data-dir=C:/naver_cookie")
257
- puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
258
- begin
259
- proc.Terminate
260
- rescue
254
+ # chrome_procs.each do |proc|
255
+ # cmd = proc.CommandLine
256
+ # if cmd && cmd.include?("user-data-dir=C:/naver_cookie")
257
+ # puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
258
+ # begin
259
+ # proc.Terminate
260
+ # rescue
261
261
  #puts "→ 이미 종료된 프로세스: #{proc.ProcessId}"
262
- end
263
- end
264
- end
262
+ # end
263
+ # end
264
+ # end
265
265
 
266
266
  # chromedriver도 같이 종료
267
- chromedrivers = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chromedriver.exe'")
268
- chromedrivers.each do |proc|
269
- puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
270
- begin
271
- proc.Terminate
272
- rescue
267
+ # chromedrivers = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chromedriver.exe'")
268
+ # chromedrivers.each do |proc|
269
+ # puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
270
+ # begin
271
+ # proc.Terminate
272
+ # rescue
273
273
  #puts "→ 이미 종료된 chromedriver: #{proc.ProcessId}"
274
- end
275
- end
276
- end
274
+ # end
275
+ # end
276
+ #end
277
277
 
278
278
 
279
279
  def chrome_setup(user_id, proxy)
@@ -2389,40 +2389,84 @@ class Wordpress
2389
2389
  img.write('./image/memory.png')
2390
2390
  end
2391
2391
 
2392
+ def wrap_text_to_fit(draw, text, max_width, max_height, font_path, initial_size)
2393
+ size = initial_size
2394
+ draw.font = font_path
2395
+
2396
+ loop do
2397
+ draw.pointsize = size
2398
+ words = text.chars # 글자 단위로 자름 (한국어 기준)
2399
+ lines = []
2400
+ line = ""
2401
+
2402
+ words.each do |char|
2403
+ test_line = line + char
2404
+ metrics = draw.get_type_metrics(test_line)
2405
+ if metrics.width > max_width
2406
+ lines << line
2407
+ line = char
2408
+ else
2409
+ line = test_line
2410
+ end
2411
+ end
2412
+ lines << line unless line.empty?
2413
+
2414
+ line_height = draw.get_type_metrics("가").height
2415
+ total_height = line_height * lines.size
2416
+
2417
+ # 세로 초과 안 하면 성공
2418
+ if total_height <= max_height || size <= 10
2419
+ return [lines.join("\n"), size]
2420
+ else
2421
+ size -= 2
2422
+ end
2423
+ end
2424
+ end
2425
+
2426
+
2392
2427
  def image_text(text1, text2)
2393
2428
  begin
2394
2429
  color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
2395
- font = Dir.entries('./fonts')
2396
- img = Magick::Image.read('./image/memory.png').first
2397
- text = Magick::Draw.new
2430
+ font_files = Dir.entries('./fonts').select { |f| f.downcase.end_with?('.ttf') }
2431
+ font2 = './fonts/' + font_files.sample
2398
2432
  color2 = color.sample
2399
- font2 = './fonts/'+font.sample
2400
- message = text1.to_s+"\n"+text2.to_s
2433
+
2434
+ img = Magick::Image.read('./image/memory.png').first
2435
+ draw = Magick::Draw.new
2436
+
2437
+ raw_message = "#{text1}\n#{text2}".strip
2438
+ max_width = img.columns * 0.85
2439
+ max_height = img.rows * 0.6
2440
+
2401
2441
  begin
2402
2442
  size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
2403
2443
  rescue
2404
2444
  size = 30
2405
2445
  end
2446
+
2447
+ wrapped_message, adjusted_size = wrap_text_to_fit(draw, raw_message, max_width, max_height, font2, size)
2448
+
2406
2449
  if @data['이미지설정']['글자그림자'].checked?
2407
- img.annotate(text, 0,0, +3,+3, message) do
2408
- text.gravity = Magick::CenterGravity
2409
- text.pointsize = size
2410
- text.fill = '#000000'
2411
- text.font = font2
2450
+ img.annotate(draw, 0, 0, 2, 2, wrapped_message) do
2451
+ draw.gravity = Magick::CenterGravity
2452
+ draw.pointsize = adjusted_size
2453
+ draw.fill = '#000000'
2454
+ draw.font = font2
2412
2455
  end
2413
2456
  end
2414
-
2415
- img.annotate(text, 0,0,0,0, message) do
2416
- text.gravity = Magick::CenterGravity
2417
- text.pointsize = size
2457
+
2458
+ draw2 = Magick::Draw.new
2459
+ img.annotate(draw2, 0, 0, 0, 0, wrapped_message) do
2460
+ draw2.gravity = Magick::CenterGravity
2461
+ draw2.pointsize = adjusted_size
2462
+ draw2.fill = color2
2463
+ draw2.font = font2
2418
2464
  if @data['이미지설정']['글자테두리'].checked?
2419
- text.stroke_width = 2
2420
- text.stroke = '#000000'
2465
+ draw2.stroke_width = 2
2466
+ draw2.stroke = '#000000'
2421
2467
  end
2422
- text.fill = color2
2423
- text.font = font2
2424
2468
  end
2425
-
2469
+
2426
2470
  img.write('./image/memory.png')
2427
2471
  rescue
2428
2472
  puts '이미지 폰트 불러오기 오류 재시도...'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 111.117.789
4
+ version: 111.117.899
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-29 00:00:00.000000000 Z
10
+ date: 2025-05-30 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: mymin26@naver.com