terminal_image 0.2.0 → 0.3.0

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: b16055f18d2792f24876eba1985bc1c1cb270c50cb3fe824bd5d30b714194798
4
- data.tar.gz: c2579200f84591705dcc3b48fc0bd7b0c440805fd3f09e80cdea88e4bb5efc7a
3
+ metadata.gz: e81b808e453e3af8ffe4eaeae50732f0daa05ee2cf7920536b7259b7c71e2235
4
+ data.tar.gz: b7f755c2e7fc80447d4f3ec97ddc1da3d3514a29db6cbaae9568a263873e7467
5
5
  SHA512:
6
- metadata.gz: 64fec55d5edf74ff3c7f23aad8f6002f8225b2e653a9f6f56d82e3336e30f96407db93f2d392e5542189d11c4afdc1067ffa4fb1088fe752c7addc9a3be3788b
7
- data.tar.gz: 07266ff60380f468933a3912cc049dddb16eb5695f116c3638fb5003213e006d25c4ea771cd0cbe46bead07c47a04d3be717d8055b8805310c95760d71923c0e
6
+ metadata.gz: b6c16294048ae920e6ed965a57672f0a761779d4f0938e36adaaf19be9404ba1224bc48808ac91a4d1373c86d828d2b6d2a28dc8182e7ef574255ebd3a14ad3b
7
+ data.tar.gz: d6bf49d4f983ec45bd66761f351bba1f78eabbd4ce2176ab0933c0743fd36ceebc9031c602f07aa0377f7b37d7a50c2906179c14ff6a522a8bf91173b54c2bd3
@@ -0,0 +1,61 @@
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]
@@ -0,0 +1,5 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Metrics/LineLength:
5
+ Max: 120
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in terminal_image.gemspec
4
6
  gemspec
@@ -1,15 +1,63 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- terminal_image (0.2.0)
4
+ terminal_image (0.3.0)
5
5
  fastimage
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ ast (2.4.0)
11
+ codecov (0.1.14)
12
+ json
13
+ simplecov
14
+ url
15
+ coderay (1.1.2)
10
16
  diff-lcs (1.3)
17
+ docile (1.3.2)
11
18
  fastimage (2.1.7)
19
+ ffi (1.11.1)
20
+ formatador (0.2.5)
21
+ guard (2.15.1)
22
+ formatador (>= 0.2.4)
23
+ listen (>= 2.7, < 4.0)
24
+ lumberjack (>= 1.0.12, < 2.0)
25
+ nenv (~> 0.1)
26
+ notiffany (~> 0.0)
27
+ pry (>= 0.9.12)
28
+ shellany (~> 0.0)
29
+ thor (>= 0.18.1)
30
+ guard-compat (1.2.1)
31
+ guard-rspec (4.7.3)
32
+ guard (~> 2.1)
33
+ guard-compat (~> 1.1)
34
+ rspec (>= 2.99.0, < 4.0)
35
+ guard-rubocop (1.3.0)
36
+ 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)
46
+ nenv (0.3.0)
47
+ notiffany (0.1.3)
48
+ nenv (~> 0.1)
49
+ 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)
12
57
  rake (10.5.0)
58
+ rb-fsevent (0.10.3)
59
+ rb-inotify (0.10.0)
60
+ ffi (~> 1.0)
13
61
  rspec (3.8.0)
14
62
  rspec-core (~> 3.8.0)
15
63
  rspec-expectations (~> 3.8.0)
@@ -23,14 +71,38 @@ GEM
23
71
  diff-lcs (>= 1.2.0, < 2.0)
24
72
  rspec-support (~> 3.8.0)
25
73
  rspec-support (3.8.2)
74
+ rubocop (0.74.0)
75
+ jaro_winkler (~> 1.5.1)
76
+ parallel (~> 1.10)
77
+ parser (>= 2.6)
78
+ rainbow (>= 2.2.2, < 4.0)
79
+ 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)
83
+ shellany (0.0.1)
84
+ simplecov (0.17.0)
85
+ 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)
26
92
 
27
93
  PLATFORMS
28
94
  ruby
29
95
 
30
96
  DEPENDENCIES
31
97
  bundler (~> 2.0)
98
+ codecov
99
+ guard
100
+ guard-rspec
101
+ guard-rubocop
32
102
  rake (~> 10.0)
33
103
  rspec (~> 3.0)
104
+ rubocop
105
+ simplecov
34
106
  terminal_image!
35
107
 
36
108
  BUNDLED WITH
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ # directories %w(app lib config test spec features) \
8
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
9
+
10
+ ## Note: if you are using the `directories` clause above and you are not
11
+ ## watching the project directory ('.'), then you will want to move
12
+ ## the Guardfile to a watched dir and symlink it back, e.g.
13
+ #
14
+ # $ mkdir config
15
+ # $ mv Guardfile config/
16
+ # $ ln -s config/Guardfile .
17
+ #
18
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
+
20
+ # Note: The cmd option is now required due to the increasing number of ways
21
+ # rspec may be run, below are examples of the most common uses.
22
+ # * bundler: 'bundle exec rspec'
23
+ # * bundler binstubs: 'bin/rspec'
24
+ # * spring: 'bin/rspec' (This will use spring if running and you have
25
+ # installed the spring binstubs per the docs)
26
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
27
+ # * 'just' rspec: 'rspec'
28
+
29
+ guard :rspec, cmd: 'bundle exec rspec' do
30
+ require 'guard/rspec/dsl'
31
+ dsl = Guard::RSpec::Dsl.new(self)
32
+
33
+ # Feel free to open issues for suggestions and improvements
34
+
35
+ # RSpec files
36
+ rspec = dsl.rspec
37
+ watch(rspec.spec_helper) { rspec.spec_dir }
38
+ watch(rspec.spec_support) { rspec.spec_dir }
39
+ watch(rspec.spec_files)
40
+
41
+ # Ruby files
42
+ ruby = dsl.ruby
43
+ dsl.watch_spec_files_for(ruby.lib_files)
44
+ end
45
+
46
+ guard :rubocop do
47
+ watch(/.+\.rb$/)
48
+ watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
49
+ end
data/README.md CHANGED
@@ -1,7 +1,14 @@
1
1
  # TerminalImage
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/terminal_image.svg)](https://badge.fury.io/rb/terminal_image)
4
+ [![Code Climate](https://codeclimate.com/github/unhappychoice/terminal_image/badges/gpa.svg)](https://codeclimate.com/github/unhappychoice/terminal_image)
5
+ [![codecov](https://codecov.io/gh/unhappychoice/terminal_image/branch/master/graph/badge.svg)](https://codecov.io/gh/unhappychoice/terminal_image)
6
+ [![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/unhappychoice/terminal_image.svg)](https://libraries.io/github/unhappychoice/terminal_image)
7
+ ![](http://ruby-gem-downloads-badge.herokuapp.com/terminal_image?type=total)
8
+ ![GitHub](https://img.shields.io/github/license/unhappychoice/terminal_image.svg)
9
+
3
10
  TerminalImage is a library to show images on terminals.
4
- Supporting iTerm2 and terminals which has installed [libsixel](https://github.com/saitoha/libsixel).
11
+ Currently, this library supports [iTerm2](https://iterm2.com/index.html) and terminals which supports [libsixel](https://github.com/saitoha/libsixel).
5
12
 
6
13
  ![](./images/example.png)
7
14
 
@@ -13,12 +20,24 @@ Add this line to your application's Gemfile:
13
20
  gem 'terminal_image'
14
21
  ```
15
22
 
23
+ Terminals other than iTerm2:
24
+
25
+ Please install `libsixel`'s `img2sixel` command following https://github.com/saitoha/libsixel#install
26
+
16
27
  ## Usage
17
28
 
18
29
  ```ruby
19
- TerminalImage.show(File.open('your-image-path.png')) # will show image on your terminal
30
+ # Print image by File object
31
+ TerminalImage.show(File.open('your-image-path.png'))
32
+
33
+ # Print image from URL
20
34
  TerminalImage.show_url('https://raw.githubusercontent.com/unhappychoice/terminal_image/master/images/sample.png')
21
- puts TerminalImage.encode(File.open('your-image-path.png')) # will encode image to string which can be displayed in terminals
35
+
36
+ # Get encoded string ready to be displayed
37
+ string = TerminalImage.encode(File.open('your-image-path.png'))
38
+
39
+ # Get encoded string ready to be displayed from URL
40
+ string = TerminalImage.encode_url('https://raw.githubusercontent.com/unhappychoice/terminal_image/master/images/sample.png')
22
41
  ```
23
42
 
24
43
  ## Contributing
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'terminal_image'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ #! /usr/bin/env bash
4
+
5
+ set -o nounset # Exit, with error message, when attempting to use an undefined variable.
6
+ set -o errexit # Abort script at first error, when a command exits with non-zero status.
7
+ set -o pipefail # Return exit status of the last command in the pipe that returned a non-zero return value.
8
+ IFS=$'\n\t' # Defines newlines and tabs as delimiters for splitting words and iterating arrays.
9
+
10
+ bundle install
@@ -1,4 +1,6 @@
1
- require "terminal_image/version"
1
+ # frozen_string_literal: true
2
+
3
+ require 'terminal_image/version'
2
4
  require 'fastimage'
3
5
  require 'open-uri'
4
6
  require 'tempfile'
@@ -18,6 +20,13 @@ module TerminalImage
18
20
  puts encode(file)
19
21
  end
20
22
 
23
+ def encode_url(url)
24
+ tempfile = Tempfile.create
25
+ tempfile.binmode
26
+ URI.open(url) { |o| tempfile.write o.read }
27
+ TerminalImage.encode(tempfile)
28
+ end
29
+
21
30
  def encode(file)
22
31
  if ENV['TERM_PROGRAM'] == 'iTerm.app'
23
32
  encode_for_iterm2(file)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TerminalImage
2
- VERSION = "0.2.0"
4
+ VERSION = '0.3.0'
3
5
  end
@@ -1,34 +1,42 @@
1
- lib = File.expand_path("lib", __dir__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "terminal_image/version"
5
+ require 'terminal_image/version'
4
6
 
5
7
  Gem::Specification.new do |spec|
6
- spec.name = "terminal_image"
8
+ spec.name = 'terminal_image'
7
9
  spec.version = TerminalImage::VERSION
8
- spec.authors = ["Yuji Ueki"]
9
- spec.email = ["unhappychoice@gmail.com"]
10
+ spec.authors = ['Yuji Ueki']
11
+ spec.email = ['unhappychoice@gmail.com']
10
12
 
11
- spec.summary = %q{Display images on terminal}
12
- spec.description = %q{Displays images on terminal}
13
- spec.homepage = "https://github.com/unhappychoice/terminal_image"
14
- spec.license = "MIT"
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'
15
17
 
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = "https://github.com/unhappychoice/terminal_image"
18
- 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'
19
21
 
20
22
  # Specify which files should be added to the gem when it is released.
21
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
25
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
26
  end
25
- spec.bindir = "exe"
27
+ spec.bindir = 'exe'
26
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ["lib"]
29
+ spec.require_paths = ['lib']
28
30
 
29
31
  spec.add_dependency 'fastimage'
30
32
 
31
- spec.add_development_dependency "bundler", "~> 2.0"
32
- spec.add_development_dependency "rake", "~> 10.0"
33
- spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency 'bundler', '~> 2.0'
34
+ spec.add_development_dependency 'codecov'
35
+ spec.add_development_dependency 'guard'
36
+ spec.add_development_dependency 'guard-rspec'
37
+ spec.add_development_dependency 'guard-rubocop'
38
+ spec.add_development_dependency 'rake', '~> 10.0'
39
+ spec.add_development_dependency 'rspec', '~> 3.0'
40
+ spec.add_development_dependency 'rubocop'
41
+ spec.add_development_dependency 'simplecov'
34
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Ueki
@@ -38,6 +38,62 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: codecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
41
97
  - !ruby/object:Gem::Dependency
42
98
  name: rake
43
99
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +122,34 @@ dependencies:
66
122
  - - "~>"
67
123
  - !ruby/object:Gem::Version
68
124
  version: '3.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
69
153
  description: Displays images on terminal
70
154
  email:
71
155
  - unhappychoice@gmail.com
@@ -73,12 +157,17 @@ executables: []
73
157
  extensions: []
74
158
  extra_rdoc_files: []
75
159
  files:
160
+ - ".circleci/config.yml"
161
+ - ".rubocop.yml"
76
162
  - CODE_OF_CONDUCT.md
77
163
  - Gemfile
78
164
  - Gemfile.lock
165
+ - Guardfile
79
166
  - LICENSE.txt
80
167
  - README.md
81
168
  - Rakefile
169
+ - bin/console
170
+ - bin/setup
82
171
  - images/example.png
83
172
  - images/sample.png
84
173
  - lib/terminal_image.rb