terminal_image 0.3.0 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e81b808e453e3af8ffe4eaeae50732f0daa05ee2cf7920536b7259b7c71e2235
4
- data.tar.gz: b7f755c2e7fc80447d4f3ec97ddc1da3d3514a29db6cbaae9568a263873e7467
3
+ metadata.gz: 5600c245730f7c4fba89e5e8f42d7a84c870fd830cd50f72a38ac8bad4a0455c
4
+ data.tar.gz: 3ef875b2704787ba0f8ee646283a125811b38ffac7195eaa96f7cc7faceaa607
5
5
  SHA512:
6
- metadata.gz: b6c16294048ae920e6ed965a57672f0a761779d4f0938e36adaaf19be9404ba1224bc48808ac91a4d1373c86d828d2b6d2a28dc8182e7ef574255ebd3a14ad3b
7
- data.tar.gz: d6bf49d4f983ec45bd66761f351bba1f78eabbd4ce2176ab0933c0743fd36ceebc9031c602f07aa0377f7b37d7a50c2906179c14ff6a522a8bf91173b54c2bd3
6
+ metadata.gz: d4e0f9662a5d5a4aae9cd2ca1669c15b4413e77962efb54358f602871b8f2b4637dee648bb458aa2b47781976a12e213021ef9f2317d6faa6600cba098c65772
7
+ data.tar.gz: 351d705af6f80741fa669f9c51d7b794320d33e0c4b59b82159bd113c00447429a2f9d88609390d1092ec62ab4a002a97d904a719de23ff3980a2a805186e8fa
@@ -0,0 +1,31 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "12:00"
8
+ timezone: Asia/Tokyo
9
+ open-pull-requests-limit: 20
10
+ reviewers:
11
+ - unhappychoice
12
+ allow:
13
+ - dependency-type: direct
14
+ - dependency-type: indirect
15
+ ignore:
16
+ - dependency-name: codecov
17
+ versions:
18
+ - ">= 0.2.14.a, < 0.2.15"
19
+ - dependency-name: rubocop
20
+ versions:
21
+ - 1.12.1
22
+ - dependency-name: listen
23
+ versions:
24
+ - 3.5.0
25
+ - dependency-name: codecov
26
+ versions:
27
+ - 0.5.0
28
+ - dependency-name: regexp_parser
29
+ versions:
30
+ - 2.1.0
31
+ - 2.1.1
@@ -0,0 +1,21 @@
1
+ name: release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ jobs:
6
+ push:
7
+ name: Push gem to RubyGems.org
8
+ runs-on: ubuntu-latest
9
+ environment:
10
+ name: release
11
+ permissions:
12
+ id-token: write
13
+ contents: write
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ bundler-cache: true
20
+ ruby-version: .ruby-version
21
+ - uses: rubygems/release-gem@v1
@@ -0,0 +1,52 @@
1
+ name: test
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ lint:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@master
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: .ruby-version
14
+ - name: Install bundler
15
+ run: gem install bundler
16
+ - name: Install dependencies
17
+ run: bundle install --jobs 4
18
+ - name: Run test
19
+ run: bundle exec rubocop lib
20
+ test:
21
+ runs-on: ubuntu-latest
22
+ services:
23
+ redis:
24
+ image: redis
25
+ options: >-
26
+ --health-cmd "redis-cli ping"
27
+ --health-interval 10s
28
+ --health-timeout 5s
29
+ --health-retries 5
30
+ ports:
31
+ - 6379:6379
32
+ strategy:
33
+ matrix:
34
+ ruby: ['3.4.4', '3.3.8', '3.2.8', '3.1.7']
35
+ steps:
36
+ - uses: actions/checkout@master
37
+ - name: Set up Rub
38
+ uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby }}
41
+ - name: Install libsixel
42
+ run: sudo apt-get install libsixel-bin
43
+ - name: Install bundler
44
+ run: gem install bundler
45
+ - name: Install dependencies
46
+ run: bundle install --jobs 4
47
+ - name: Run test
48
+ env:
49
+ COVERAGE: true
50
+ CODECOV_TOKEN: d3d0fd4f-db2c-439b-9331-8e1d992813ad
51
+ AWS_REGION: ap-northeast-1
52
+ run: bundle exec rspec
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format doc
3
+ --require spec_helper
data/.rubocop.yml CHANGED
@@ -1,3 +1,7 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 3.1
4
+
1
5
  Style/Documentation:
2
6
  Enabled: false
3
7
 
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.4
data/Gemfile.lock CHANGED
@@ -1,30 +1,33 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- terminal_image (0.3.0)
4
+ terminal_image (1.0.0)
5
+ base64 (~> 0.3)
5
6
  fastimage
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
- ast (2.4.0)
11
- codecov (0.1.14)
12
- json
13
- simplecov
14
- url
15
- coderay (1.1.2)
16
- diff-lcs (1.3)
17
- docile (1.3.2)
18
- fastimage (2.1.7)
19
- ffi (1.11.1)
20
- formatador (0.2.5)
21
- guard (2.15.1)
11
+ ast (2.4.2)
12
+ base64 (0.3.0)
13
+ codecov (0.6.0)
14
+ simplecov (>= 0.15, < 0.22)
15
+ coderay (1.1.3)
16
+ diff-lcs (1.6.0)
17
+ docile (1.4.1)
18
+ fastimage (2.4.0)
19
+ ffi (1.17.1-x86_64-darwin)
20
+ ffi (1.17.1-x86_64-linux-gnu)
21
+ formatador (1.1.0)
22
+ guard (2.19.1)
22
23
  formatador (>= 0.2.4)
23
24
  listen (>= 2.7, < 4.0)
25
+ logger (~> 1.6)
24
26
  lumberjack (>= 1.0.12, < 2.0)
25
27
  nenv (~> 0.1)
26
28
  notiffany (~> 0.0)
27
- pry (>= 0.9.12)
29
+ ostruct (~> 0.6)
30
+ pry (>= 0.13.0)
28
31
  shellany (~> 0.0)
29
32
  thor (>= 0.18.1)
30
33
  guard-compat (1.2.1)
@@ -32,66 +35,73 @@ GEM
32
35
  guard (~> 2.1)
33
36
  guard-compat (~> 1.1)
34
37
  rspec (>= 2.99.0, < 4.0)
35
- guard-rubocop (1.3.0)
38
+ guard-rubocop (1.5.0)
36
39
  guard (~> 2.0)
37
- rubocop (~> 0.20)
38
- jaro_winkler (1.5.3)
39
- json (2.2.0)
40
- listen (3.1.5)
41
- rb-fsevent (~> 0.9, >= 0.9.4)
42
- rb-inotify (~> 0.9, >= 0.9.7)
43
- ruby_dep (~> 1.2)
44
- lumberjack (1.0.13)
45
- method_source (0.9.2)
40
+ rubocop (< 2.0)
41
+ listen (3.9.0)
42
+ rb-fsevent (~> 0.10, >= 0.10.3)
43
+ rb-inotify (~> 0.9, >= 0.9.10)
44
+ logger (1.7.0)
45
+ lumberjack (1.2.10)
46
+ method_source (1.1.0)
46
47
  nenv (0.3.0)
47
48
  notiffany (0.1.3)
48
49
  nenv (~> 0.1)
49
50
  shellany (~> 0.0)
50
- parallel (1.17.0)
51
- parser (2.6.4.1)
52
- ast (~> 2.4.0)
53
- pry (0.12.2)
54
- coderay (~> 1.1.0)
55
- method_source (~> 0.9.0)
56
- rainbow (3.0.0)
57
- rake (10.5.0)
58
- rb-fsevent (0.10.3)
59
- rb-inotify (0.10.0)
51
+ ostruct (0.6.1)
52
+ parallel (1.24.0)
53
+ parser (3.3.7.1)
54
+ ast (~> 2.4.1)
55
+ racc
56
+ pry (0.15.2)
57
+ coderay (~> 1.1)
58
+ method_source (~> 1.0)
59
+ racc (1.8.1)
60
+ rainbow (3.1.1)
61
+ rake (13.2.1)
62
+ rb-fsevent (0.11.2)
63
+ rb-inotify (0.11.1)
60
64
  ffi (~> 1.0)
61
- rspec (3.8.0)
62
- rspec-core (~> 3.8.0)
63
- rspec-expectations (~> 3.8.0)
64
- rspec-mocks (~> 3.8.0)
65
- rspec-core (3.8.2)
66
- rspec-support (~> 3.8.0)
67
- rspec-expectations (3.8.4)
65
+ regexp_parser (2.10.0)
66
+ rexml (3.4.1)
67
+ rspec (3.13.0)
68
+ rspec-core (~> 3.13.0)
69
+ rspec-expectations (~> 3.13.0)
70
+ rspec-mocks (~> 3.13.0)
71
+ rspec-core (3.13.3)
72
+ rspec-support (~> 3.13.0)
73
+ rspec-expectations (3.13.3)
68
74
  diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.8.0)
70
- rspec-mocks (3.8.1)
75
+ rspec-support (~> 3.13.0)
76
+ rspec-mocks (3.13.2)
71
77
  diff-lcs (>= 1.2.0, < 2.0)
72
- rspec-support (~> 3.8.0)
73
- rspec-support (3.8.2)
74
- rubocop (0.74.0)
75
- jaro_winkler (~> 1.5.1)
78
+ rspec-support (~> 3.13.0)
79
+ rspec-support (3.13.2)
80
+ rubocop (1.28.2)
76
81
  parallel (~> 1.10)
77
- parser (>= 2.6)
82
+ parser (>= 3.1.0.0)
78
83
  rainbow (>= 2.2.2, < 4.0)
84
+ regexp_parser (>= 1.8, < 3.0)
85
+ rexml
86
+ rubocop-ast (>= 1.17.0, < 2.0)
79
87
  ruby-progressbar (~> 1.7)
80
- unicode-display_width (>= 1.4.0, < 1.7)
81
- ruby-progressbar (1.10.1)
82
- ruby_dep (1.5.0)
88
+ unicode-display_width (>= 1.4.0, < 3.0)
89
+ rubocop-ast (1.17.0)
90
+ parser (>= 3.1.1.0)
91
+ ruby-progressbar (1.13.0)
83
92
  shellany (0.0.1)
84
- simplecov (0.17.0)
93
+ simplecov (0.21.2)
85
94
  docile (~> 1.1)
86
- json (>= 1.8, < 3)
87
- simplecov-html (~> 0.10.0)
88
- simplecov-html (0.10.2)
89
- thor (0.20.3)
90
- unicode-display_width (1.6.0)
91
- url (0.3.2)
95
+ simplecov-html (~> 0.11)
96
+ simplecov_json_formatter (~> 0.1)
97
+ simplecov-html (0.13.1)
98
+ simplecov_json_formatter (0.1.4)
99
+ thor (1.2.2)
100
+ unicode-display_width (2.6.0)
92
101
 
93
102
  PLATFORMS
94
- ruby
103
+ x86_64-darwin-24
104
+ x86_64-linux
95
105
 
96
106
  DEPENDENCIES
97
107
  bundler (~> 2.0)
@@ -99,11 +109,11 @@ DEPENDENCIES
99
109
  guard
100
110
  guard-rspec
101
111
  guard-rubocop
102
- rake (~> 10.0)
112
+ rake (~> 13.0)
103
113
  rspec (~> 3.0)
104
114
  rubocop
105
115
  simplecov
106
116
  terminal_image!
107
117
 
108
118
  BUNDLED WITH
109
- 2.0.2
119
+ 2.4.14
data/Guardfile CHANGED
@@ -17,7 +17,7 @@
17
17
  #
18
18
  # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
19
 
20
- # Note: The cmd option is now required due to the increasing number of ways
20
+ # NOTE: The cmd option is now required due to the increasing number of ways
21
21
  # rspec may be run, below are examples of the most common uses.
22
22
  # * bundler: 'bundle exec rspec'
23
23
  # * bundler binstubs: 'bin/rspec'
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  ![GitHub](https://img.shields.io/github/license/unhappychoice/terminal_image.svg)
9
9
 
10
10
  TerminalImage is a library to show images on terminals.
11
- Currently, this library supports [iTerm2](https://iterm2.com/index.html) and terminals which supports [libsixel](https://github.com/saitoha/libsixel).
11
+ Currently, this library supports [iTerm2](https://iterm2.com/index.html) and terminals with [libsixel](https://github.com/saitoha/libsixel) installed.
12
12
 
13
13
  ![](./images/example.png)
14
14
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TerminalImage
4
- VERSION = '0.3.0'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'terminal_image/version'
4
+ require 'base64'
4
5
  require 'fastimage'
5
6
  require 'open-uri'
6
7
  require 'tempfile'
@@ -12,7 +13,7 @@ module TerminalImage
12
13
  def show_url(url)
13
14
  tempfile = Tempfile.create
14
15
  tempfile.binmode
15
- URI.open(url) { |o| tempfile.write o.read }
16
+ URI.parse(url).open { |o| tempfile.write o.read }
16
17
  TerminalImage.show(tempfile)
17
18
  end
18
19
 
@@ -23,17 +24,17 @@ module TerminalImage
23
24
  def encode_url(url)
24
25
  tempfile = Tempfile.create
25
26
  tempfile.binmode
26
- URI.open(url) { |o| tempfile.write o.read }
27
+ URI.parse(url).open { |o| tempfile.write o.read }
27
28
  TerminalImage.encode(tempfile)
28
29
  end
29
30
 
30
31
  def encode(file)
31
- if ENV['TERM_PROGRAM'] == 'iTerm.app'
32
+ if ENV.fetch('TERM_PROGRAM', nil) == 'iTerm.app'
32
33
  encode_for_iterm2(file)
33
34
  elsif which 'img2sixel'
34
35
  encode_for_libsixel(file)
35
36
  else
36
- puts 'Use iTerm2 or install libsixel according to https://github.com/saitoha/libsixel#install'
37
+ warn 'Use iTerm2 or install libsixel according to https://github.com/saitoha/libsixel#install'
37
38
  raise UnsupportedTerminal, 'Unsupported terminal'
38
39
  end
39
40
  end
@@ -42,7 +43,7 @@ module TerminalImage
42
43
 
43
44
  def encode_for_iterm2(file)
44
45
  width, height = FastImage.size(file)
45
- "\033]1337;File=inline=1;width=#{width}px;height=#{height}px:#{Base64.strict_encode64(file.read)}\a\n"
46
+ "\033]1337;File=inline=1;width=#{width}px;height=#{height}px:#{Base64.strict_encode64(file.read)}\a"
46
47
  end
47
48
 
48
49
  def encode_for_libsixel(file)
@@ -5,19 +5,20 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'terminal_image/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'terminal_image'
9
- spec.version = TerminalImage::VERSION
10
- spec.authors = ['Yuji Ueki']
11
- spec.email = ['unhappychoice@gmail.com']
8
+ spec.name = 'terminal_image'
9
+ spec.version = TerminalImage::VERSION
10
+ spec.required_ruby_version = '>= 3.1'
11
+ spec.authors = ['Yuji Ueki']
12
+ spec.email = ['unhappychoice@gmail.com']
13
+ spec.summary = 'Display images on terminal'
14
+ spec.description = 'Displays images on terminal'
15
+ spec.homepage = 'https://github.com/unhappychoice/terminal_image'
16
+ spec.license = 'MIT'
12
17
 
13
- spec.summary = 'Display images on terminal'
14
- spec.description = 'Displays images on terminal'
15
- spec.homepage = 'https://github.com/unhappychoice/terminal_image'
16
- spec.license = 'MIT'
17
-
18
- spec.metadata['homepage_uri'] = spec.homepage
19
- spec.metadata['source_code_uri'] = 'https://github.com/unhappychoice/terminal_image'
20
- spec.metadata['changelog_uri'] = 'https://github.com/unhappychoice/terminal_image'
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/unhappychoice/terminal_image'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/unhappychoice/terminal_image'
21
+ spec.metadata['rubygems_mfa_required'] = 'true'
21
22
 
22
23
  # Specify which files should be added to the gem when it is released.
23
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -28,6 +29,7 @@ Gem::Specification.new do |spec|
28
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
30
  spec.require_paths = ['lib']
30
31
 
32
+ spec.add_dependency 'base64', '~> 0.3'
31
33
  spec.add_dependency 'fastimage'
32
34
 
33
35
  spec.add_development_dependency 'bundler', '~> 2.0'
@@ -35,7 +37,7 @@ Gem::Specification.new do |spec|
35
37
  spec.add_development_dependency 'guard'
36
38
  spec.add_development_dependency 'guard-rspec'
37
39
  spec.add_development_dependency 'guard-rubocop'
38
- spec.add_development_dependency 'rake', '~> 10.0'
40
+ spec.add_development_dependency 'rake', '~> 13.0'
39
41
  spec.add_development_dependency 'rspec', '~> 3.0'
40
42
  spec.add_development_dependency 'rubocop'
41
43
  spec.add_development_dependency 'simplecov'
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Ueki
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2019-09-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: base64
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.3'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.3'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: fastimage
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +113,14 @@ dependencies:
100
113
  requirements:
101
114
  - - "~>"
102
115
  - !ruby/object:Gem::Version
103
- version: '10.0'
116
+ version: '13.0'
104
117
  type: :development
105
118
  prerelease: false
106
119
  version_requirements: !ruby/object:Gem::Requirement
107
120
  requirements:
108
121
  - - "~>"
109
122
  - !ruby/object:Gem::Version
110
- version: '10.0'
123
+ version: '13.0'
111
124
  - !ruby/object:Gem::Dependency
112
125
  name: rspec
113
126
  requirement: !ruby/object:Gem::Requirement
@@ -157,8 +170,12 @@ executables: []
157
170
  extensions: []
158
171
  extra_rdoc_files: []
159
172
  files:
160
- - ".circleci/config.yml"
173
+ - ".github/dependabot.yml"
174
+ - ".github/workflows/release.yaml"
175
+ - ".github/workflows/test.yaml"
176
+ - ".rspec"
161
177
  - ".rubocop.yml"
178
+ - ".ruby-version"
162
179
  - CODE_OF_CONDUCT.md
163
180
  - Gemfile
164
181
  - Gemfile.lock
@@ -180,7 +197,7 @@ metadata:
180
197
  homepage_uri: https://github.com/unhappychoice/terminal_image
181
198
  source_code_uri: https://github.com/unhappychoice/terminal_image
182
199
  changelog_uri: https://github.com/unhappychoice/terminal_image
183
- post_install_message:
200
+ rubygems_mfa_required: 'true'
184
201
  rdoc_options: []
185
202
  require_paths:
186
203
  - lib
@@ -188,15 +205,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
205
  requirements:
189
206
  - - ">="
190
207
  - !ruby/object:Gem::Version
191
- version: '0'
208
+ version: '3.1'
192
209
  required_rubygems_version: !ruby/object:Gem::Requirement
193
210
  requirements:
194
211
  - - ">="
195
212
  - !ruby/object:Gem::Version
196
213
  version: '0'
197
214
  requirements: []
198
- rubygems_version: 3.0.3
199
- signing_key:
215
+ rubygems_version: 3.6.7
200
216
  specification_version: 4
201
217
  summary: Display images on terminal
202
218
  test_files: []
data/.circleci/config.yml DELETED
@@ -1,61 +0,0 @@
1
- version: 2.1
2
-
3
- update_bundler: &update_bundler
4
- run:
5
- name: update bundler
6
- command: gem update bundler
7
-
8
- bundle_install: &bundle_install
9
- run:
10
- name: bundle install
11
- command: bundle update --bundler && bundle install --path vendor/bundle --jobs 4
12
-
13
- restore_bundle_cache: &restore_bundle_cache
14
- restore_cache:
15
- key: cache-bundler-{{ checksum "Gemfile.lock" }}
16
-
17
- jobs:
18
- build:
19
- docker:
20
- - image: circleci/ruby
21
- steps:
22
- - checkout
23
- - *restore_bundle_cache
24
- - *update_bundler
25
- - *bundle_install
26
- - save_cache:
27
- key: cache-bundler-{{ checksum "Gemfile.lock" }}
28
- paths:
29
- - vendor/bundle
30
- rubocop:
31
- docker:
32
- - image: circleci/ruby
33
- steps:
34
- - checkout
35
- - *restore_bundle_cache
36
- - *update_bundler
37
- - *bundle_install
38
- - run: bundle exec rubocop
39
- rspec:
40
- docker:
41
- - image: circleci/ruby
42
- steps:
43
- - checkout
44
- - *restore_bundle_cache
45
- - *update_bundler
46
- - *bundle_install
47
- - run:
48
- environment:
49
- RAILS_ENV: test
50
- COVERAGE: true
51
- CODECOV_TOKEN: d9091f65-2e14-4029-86e6-f6ec9c59ecec
52
- command: bundle exec rspec
53
- workflows:
54
- version: 2.1
55
- rspec:
56
- jobs:
57
- - build
58
- - rubocop:
59
- requires: [build]
60
- - rspec:
61
- requires: [build]