flipbook 0.4.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/.codespellignore +0 -0
- data/.yamllint +16 -0
- data/CHANGELOG.md +4 -0
- data/lib/flipbook/apng/writer.rb +3 -16
- data/lib/flipbook/gif/writer.rb +3 -16
- data/lib/flipbook/output.rb +37 -0
- data/lib/flipbook/version.rb +1 -1
- data/lib/flipbook.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9abd6bb4146e33beb424bec0c939348c93aa8ac9e80c3154b2cddc6bbc1f274d
|
|
4
|
+
data.tar.gz: 0210edbf204724a000f096fbdcec2cd58ee0af871805410083a90f60c3b982b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5aafee5ed88fa52d775ff31ef699fea4dc37f6dddaaaf4dea883aba1ee59ff92c8c0f4cab238a560c8aa1ef634c99c31ff9145a958fa182edf515edd0ce8a9e
|
|
7
|
+
data.tar.gz: 06307e57f4225bb88a2894953d6f3ccac17366a2065308017c0043b969edc05bb06f5de651d32d1b1285624cf111e0f63f1c6cc499cd52e03d134aaf3ec93bad
|
data/.codespellignore
ADDED
|
File without changes
|
data/.yamllint
ADDED
data/CHANGELOG.md
CHANGED
data/lib/flipbook/apng/writer.rb
CHANGED
|
@@ -5,21 +5,8 @@ require "stringio"
|
|
|
5
5
|
module Flipbook
|
|
6
6
|
module APNG
|
|
7
7
|
class Writer
|
|
8
|
-
def self.open(path, **options)
|
|
9
|
-
|
|
10
|
-
writer = new(io, **options)
|
|
11
|
-
writer.instance_variable_set(:@owns_io, true)
|
|
12
|
-
return writer unless block_given?
|
|
13
|
-
|
|
14
|
-
begin
|
|
15
|
-
yield writer
|
|
16
|
-
ensure
|
|
17
|
-
writer.close
|
|
18
|
-
end
|
|
19
|
-
path
|
|
20
|
-
rescue StandardError
|
|
21
|
-
io&.close unless io&.closed?
|
|
22
|
-
raise
|
|
8
|
+
def self.open(path, **options, &block)
|
|
9
|
+
Output.open(self, path, **options, &block)
|
|
23
10
|
end
|
|
24
11
|
|
|
25
12
|
def initialize(io, width:, height:, loop: true, optimize: true, buffered: nil)
|
|
@@ -71,7 +58,7 @@ module Flipbook
|
|
|
71
58
|
patch_animation_control
|
|
72
59
|
end
|
|
73
60
|
@closed = true
|
|
74
|
-
@io
|
|
61
|
+
Output.finish(@io, @target_path, @target_mode) if @owns_io
|
|
75
62
|
self
|
|
76
63
|
end
|
|
77
64
|
|
data/lib/flipbook/gif/writer.rb
CHANGED
|
@@ -3,21 +3,8 @@
|
|
|
3
3
|
module Flipbook
|
|
4
4
|
module GIF
|
|
5
5
|
class Writer
|
|
6
|
-
def self.open(path, **options)
|
|
7
|
-
|
|
8
|
-
writer = new(io, **options)
|
|
9
|
-
writer.instance_variable_set(:@owns_io, true)
|
|
10
|
-
return writer unless block_given?
|
|
11
|
-
|
|
12
|
-
begin
|
|
13
|
-
yield writer
|
|
14
|
-
ensure
|
|
15
|
-
writer.close
|
|
16
|
-
end
|
|
17
|
-
path
|
|
18
|
-
rescue StandardError
|
|
19
|
-
io&.close unless io&.closed?
|
|
20
|
-
raise
|
|
6
|
+
def self.open(path, **options, &block)
|
|
7
|
+
Output.open(self, path, **options, &block)
|
|
21
8
|
end
|
|
22
9
|
|
|
23
10
|
def initialize(io, width:, height:, loop: true, palette: :per_frame, colors: 256, dither: :floyd_steinberg, transparent_index: nil, optimize: true)
|
|
@@ -100,7 +87,7 @@ module Flipbook
|
|
|
100
87
|
write_pending(@pending_frame[:transparent] ? 2 : 1)
|
|
101
88
|
@io << ";".b
|
|
102
89
|
@closed = true
|
|
103
|
-
@io
|
|
90
|
+
Output.finish(@io, @target_path, @target_mode) if @owns_io
|
|
104
91
|
self
|
|
105
92
|
end
|
|
106
93
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "tempfile"
|
|
4
|
+
|
|
5
|
+
module Flipbook
|
|
6
|
+
module Output
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
def open(writer_class, path, **options)
|
|
10
|
+
target = File.expand_path(path)
|
|
11
|
+
mode = File.exist?(target) ? File.stat(target).mode & 0o777 : 0o666 & ~File.umask
|
|
12
|
+
io = Tempfile.new(".flipbook-", File.dirname(target))
|
|
13
|
+
io.binmode
|
|
14
|
+
writer = writer_class.new(io, **options)
|
|
15
|
+
writer.instance_variable_set(:@owns_io, true)
|
|
16
|
+
writer.instance_variable_set(:@target_path, target)
|
|
17
|
+
writer.instance_variable_set(:@target_mode, mode)
|
|
18
|
+
return writer unless block_given?
|
|
19
|
+
|
|
20
|
+
yield writer
|
|
21
|
+
writer.close
|
|
22
|
+
path
|
|
23
|
+
rescue Exception
|
|
24
|
+
io&.close!
|
|
25
|
+
raise
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def finish(io, target, mode)
|
|
29
|
+
io.close unless io.closed?
|
|
30
|
+
File.chmod(mode, io.path)
|
|
31
|
+
File.rename(io.path, target)
|
|
32
|
+
rescue Exception
|
|
33
|
+
io.close!
|
|
34
|
+
raise
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/flipbook/version.rb
CHANGED
data/lib/flipbook.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flipbook
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yudai Takada
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: tessel
|
|
@@ -66,6 +66,8 @@ executables: []
|
|
|
66
66
|
extensions: []
|
|
67
67
|
extra_rdoc_files: []
|
|
68
68
|
files:
|
|
69
|
+
- ".codespellignore"
|
|
70
|
+
- ".yamllint"
|
|
69
71
|
- CHANGELOG.md
|
|
70
72
|
- LICENSE.txt
|
|
71
73
|
- README.md
|
|
@@ -84,6 +86,7 @@ files:
|
|
|
84
86
|
- lib/flipbook/gif/lzw.rb
|
|
85
87
|
- lib/flipbook/gif/reader.rb
|
|
86
88
|
- lib/flipbook/gif/writer.rb
|
|
89
|
+
- lib/flipbook/output.rb
|
|
87
90
|
- lib/flipbook/timing.rb
|
|
88
91
|
- lib/flipbook/version.rb
|
|
89
92
|
- sig/flipbook.rbs
|