cafe_basics 0.1.52 → 0.1.53

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_basics.rb +19 -15
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bff9e36488c3054952fb1a1efddfa003d4dee61ca2486a0c18ea572871d6d5c6
4
- data.tar.gz: 476445e25e0d71fda3cb4918642121515f337d9e9f59592f323cfb1696b3a251
3
+ metadata.gz: 1d0451aa966f88b0f13e3da4eab576aa33f5963cb34e6a8bd4d4c415e4bc5104
4
+ data.tar.gz: 86ed985fe0ea99eaa3e09f4dc9993ac41f81808e840d0f8c9ece283826023bab
5
5
  SHA512:
6
- metadata.gz: 17fc8f553e4ff891b2ac22e3fb913b938446c2784ff2aad52afa7f306b0217ca7a747cfe0d936756d22149d6e6457ca9f3d5ae376e78430d025d39d6d5c93d25
7
- data.tar.gz: 3843e6b48a29828279bcafe8e71c0f519a4e6bc1153a2145999ce9c4b335e42cf51f7406738bbecee65ffdc796690a43d58c059c98532b019267ae974183bbaa
6
+ metadata.gz: b08db72d293ebde33a55ac524785316cc62130f4c18b63f0c37ce8703ece4aeeb59094688b6812e46e0abb62877bc86f6d53fc6cf4cf0ea4fcb41d1b35bd6421
7
+ data.tar.gz: 2a1fd28e15ce350458c5ab6f7e9dcf688d5b9e4eb227b46b387f1d71d299b126643788a0ec7c0a39bdf46baecae4062548406ef30c0f538b84327c89d07559f9
data/lib/cafe_basics.rb CHANGED
@@ -2030,24 +2030,28 @@ class Wordpress
2030
2030
 
2031
2031
 
2032
2032
  def crop_image_height_under_width(path, min_crop_ratio = 0.625)
2033
- img = Magick::Image.read(path).first
2034
- width = img.columns
2035
- height = img.rows
2036
-
2037
-
2033
+ img = Magick::Image.read(path).first
2034
+ width = img.columns
2035
+ height = img.rows
2038
2036
 
2039
- if height > width
2040
- min_height = (width * min_crop_ratio).to_i
2041
- new_height = rand(min_height..width)
2042
- crop_top = ((height - new_height) / 2.0).round
2037
+ if height > width
2038
+ min_height = (width * min_crop_ratio).to_i
2039
+ new_height = rand(min_height..width)
2040
+ crop_top = ((height - new_height) / 2.0).round
2043
2041
 
2044
- cropped = img.crop(0, crop_top, width, new_height, true)
2045
- cropped.write(path)
2042
+ cropped = img.crop(0, crop_top, width, new_height, true)
2046
2043
 
2047
-
2048
- else
2049
-
2050
- end
2044
+ retries = 0
2045
+ begin
2046
+ cropped.write(path)
2047
+ rescue => e
2048
+ retries += 1
2049
+ puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
2050
+ sleep(1)
2051
+ retry if retries < 5
2052
+ raise "이미지 저장 실패: #{e.message}"
2053
+ end
2054
+ end
2051
2055
  end
2052
2056
 
2053
2057
  def auto_image(keyword = nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.52
4
+ version: 0.1.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon