blurhash 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 381e067e655d0fd61e599af18c7951edc74633aecd10f772d51a62663fd5ed81
4
- data.tar.gz: ebf8bf63a7298910138bca9f3a5b474b20faf6fba714e37e29e4dcf2d9af220c
3
+ metadata.gz: 8b20f7dc194fc64dd01eb87018cf0b5d8ea946df2d8cef51b1b9af5a9a959a6e
4
+ data.tar.gz: 2f918982c095b65fe40d4b9c21d93375cd20ab7fe046369b494daea34966220d
5
5
  SHA512:
6
- metadata.gz: 3205e7819848acf8d93556798220a6ce35e0573ad9158d39a8d506bd9e4ce4eede390e48ca7d0267afd6d4900930348d933a50c9d150394cfc73f7d70dc491fa
7
- data.tar.gz: c13a6011e9b751b18f75c775528109f49ceb7b4e54c502425b859fd851c7887be82fe8737d1ef53df127edc3933d944dbbc645a75edc4647acf6a84d77f332ae
6
+ metadata.gz: 75960b20bab150322ff70bdac7a971583feacb3462e11b60f6cf9214631bb2b41fb47f64397b0ffbf1e044a5743d4706b6a70aa0ec2464bb6b9afd391c0893bf
7
+ data.tar.gz: bc3218e7b8da39367702976b208505b603ef0cd765783ba00c4f9c2713cbe95f92204b87fb8cfee10449b49a7f06cb5e70b229ecdc5261b3bca0caf26a9b350f
@@ -1,6 +1,7 @@
1
1
  name: Ruby Gem
2
2
 
3
3
  on:
4
+ workflow_dispatch:
4
5
  push:
5
6
  tags:
6
7
  - v*
@@ -12,23 +13,9 @@ jobs:
12
13
 
13
14
  steps:
14
15
  - uses: actions/checkout@master
15
- - name: Set up Ruby 2.6
16
- uses: actions/setup-ruby@v1
16
+ - uses: ruby/setup-ruby@v1.137.0
17
17
  with:
18
- version: 2.6.x
19
-
20
- - name: Publish to GPR
21
- run: |
22
- mkdir -p $HOME/.gem
23
- touch $HOME/.gem/credentials
24
- chmod 0600 $HOME/.gem/credentials
25
- printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
26
- gem build *.gemspec
27
- gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
28
- env:
29
- GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
30
- OWNER: Gargron
31
-
18
+ ruby-version: '3.0'
32
19
  - name: Publish to RubyGems
33
20
  run: |
34
21
  mkdir -p $HOME/.gem
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ Changelog
2
+ =========
3
+
4
+ All notable changes to this project will be documented in this file.
5
+
6
+ ## [0.1.6] - 2022-02-28
7
+ ### Fixed
8
+
9
+ - Fix missing `,` in Base 83 character set (noellabo)
data/Gemfile.lock CHANGED
@@ -1,14 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blurhash (0.1.5)
5
- ffi (~> 1.14)
4
+ blurhash (0.1.7)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  specs:
10
9
  diff-lcs (1.4.4)
11
- ffi (1.14.2)
12
10
  rake (13.0.3)
13
11
  rake-compiler (1.1.1)
14
12
  rake
@@ -37,4 +35,4 @@ DEPENDENCIES
37
35
  rspec (~> 3.0)
38
36
 
39
37
  BUNDLED WITH
40
- 2.2.7
38
+ 2.3.23
data/Rakefile CHANGED
@@ -8,8 +8,7 @@ require "rake/extensiontask"
8
8
  task :build => :compile
9
9
 
10
10
  Rake::ExtensionTask.new("blurhash") do |ext|
11
- ext.name = "encode"
12
- ext.lib_dir = "ext/blurhash"
11
+ ext.name = "blurhash_ext"
13
12
  end
14
13
 
15
14
  task :default => [:clobber, :compile, :spec]
data/blurhash.gemspec CHANGED
@@ -21,8 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ['lib']
22
22
  spec.extensions = ['ext/blurhash/extconf.rb']
23
23
 
24
- spec.add_dependency 'ffi', '~> 1.14'
25
-
26
24
  spec.add_development_dependency 'bundler', '~> 2.0'
27
25
  spec.add_development_dependency 'rake', '~> 13.0'
28
26
  spec.add_development_dependency 'rake-compiler'
@@ -2,6 +2,7 @@
2
2
 
3
3
  #include <string.h>
4
4
  #include <math.h>
5
+ #include <ruby.h>
5
6
 
6
7
  #ifndef M_PI
7
8
  #define M_PI 3.14159265358979323846
@@ -135,3 +136,22 @@ static char *encode_int(int value, int length, char *destination) {
135
136
  }
136
137
  return destination;
137
138
  }
139
+
140
+ VALUE rb_blur_hash_for_pixels(VALUE m, VALUE x_comp, VALUE y_comp, VALUE width, VALUE height, VALUE p)
141
+ {
142
+ const char * buf = blurHashForPixels(NUM2INT(x_comp),
143
+ NUM2INT(y_comp),
144
+ NUM2INT(width),
145
+ NUM2INT(height),
146
+ (uint8_t *)StringValuePtr(p),
147
+ NUM2INT(width) * 3);
148
+
149
+ return rb_str_new2(buf);
150
+ }
151
+
152
+ void Init_blurhash_ext()
153
+ {
154
+ VALUE mBlurhash = rb_define_module("Blurhash");
155
+ VALUE mUnstable = rb_define_module_under(mBlurhash, "Unstable");
156
+ rb_define_singleton_method(mUnstable, "blurHashForPixels", rb_blur_hash_for_pixels, 5);
157
+ }
@@ -1,4 +1,5 @@
1
1
  require 'mkmf'
2
2
 
3
3
  $CFLAGS += ' -std=c99 -lm'
4
- create_makefile 'encode'
4
+
5
+ create_makefile 'blurhash_ext'
@@ -1,3 +1,3 @@
1
1
  module Blurhash
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/blurhash.rb CHANGED
@@ -1,14 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'blurhash/version'
4
- require 'ffi'
4
+ require 'blurhash_ext'
5
5
 
6
6
  module Blurhash
7
7
  def self.encode(width, height, pixels, x_comp: 4, y_comp: 3)
8
- FFI::MemoryPointer.new(:u_int8_t, pixels.size) do |p|
9
- p.write_array_of_uint8(pixels)
10
- return Unstable.blurHashForPixels(x_comp, y_comp, width, height, p, width * 3)
11
- end
8
+ p = pixels.pack("C#{pixels.size}")
9
+ return Unstable.blurHashForPixels(x_comp, y_comp, width, height, p)
12
10
  end
13
11
 
14
12
  def self.components(str)
@@ -21,12 +19,6 @@ module Blurhash
21
19
  [x_comp, y_comp]
22
20
  end
23
21
 
24
- module Unstable
25
- extend FFI::Library
26
- ffi_lib File.join(File.expand_path(File.dirname(__FILE__)), '..', 'ext', 'blurhash', 'encode.' + RbConfig::CONFIG['DLEXT'])
27
- attach_function :blurHashForPixels, %i(int int int int pointer size_t), :string
28
- end
29
-
30
22
  module Base83
31
23
  DIGIT_CHARACTERS = %w(
32
24
  0 1 2 3 4 5 6 7 8 9
@@ -35,7 +27,7 @@ module Blurhash
35
27
  U V W X Y Z a b c d
36
28
  e f g h i j k l m n
37
29
  o p q r s t u v w x
38
- y z # $ % * + - .
30
+ y z # $ % * + , - .
39
31
  : ; = ? @ [ ] ^ _ {
40
32
  | } ~
41
33
  ).freeze
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blurhash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Rochko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-20 00:00:00.000000000 Z
11
+ date: 2023-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ffi
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.14'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.14'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +78,7 @@ files:
92
78
  - ".gitignore"
93
79
  - ".rspec"
94
80
  - ".travis.yml"
81
+ - CHANGELOG.md
95
82
  - CODE_OF_CONDUCT.md
96
83
  - Gemfile
97
84
  - Gemfile.lock
@@ -125,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
112
  - !ruby/object:Gem::Version
126
113
  version: '0'
127
114
  requirements: []
128
- rubygems_version: 3.0.3
115
+ rubygems_version: 3.2.33
129
116
  signing_key:
130
117
  specification_version: 4
131
118
  summary: Encode an image as a small string that can saved in the database and used