iterm2-viewer 0.0.7 → 0.0.8

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
  SHA1:
3
- metadata.gz: 0e417f4367b8b80c7902713896212183aa1e99c9
4
- data.tar.gz: 91b35f01b824c186f706177764fd88d4b9dfde6a
3
+ metadata.gz: 82d2b04ac41d01e5c67ef2d497c1e537d2d840d4
4
+ data.tar.gz: 313c60595ee35131d632d56eb604630136ef8cd2
5
5
  SHA512:
6
- metadata.gz: f7dc4efb0b686d4a762cea57338bb603545095f5c54d8aa80767b872938347008451a4fe0a86c4afa75209b102a818a5c50555611cbe1e879221c6db37203fb2
7
- data.tar.gz: d602b0322a57604665cea12f58f36151b80c5f361e549d51e01a8ff6ed73f95db07be2f2c28715d9662d1a05b17d77e2058d00baf7536f5c89a227e146739906
6
+ metadata.gz: 90c4b8cc964335a74d3f2c6f57ab5f77ce2b2a76a2f96513697581af9adaa49650a854dd98176d147e2ad631b208c9a520c38e112f8b006070aa71712a80ddea
7
+ data.tar.gz: f8afa082227fb6e61f13dd081338e3a494bc08b7384e1d9796ed87d3a519ea0f73e245600930a0bf4e1169b37c4a0d0f88305fad7b49c6214a7ff0629f3b97af
data/Guardfile CHANGED
@@ -26,12 +26,12 @@ end
26
26
  guard :minitest, all_after_pass: true do
27
27
  #guard :minitest do
28
28
  # with Minitest::Unit
29
- watch(%r{^test/(.*)\/?test_(.*)\.rb$})
30
- watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
31
- watch(%r{^test/test_helper\.rb$}) { 'test' }
29
+ #watch(%r{^test/(.*)\/?test_(.*)\.rb$})
30
+ #watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
31
+ #watch(%r{^test/test_helper\.rb$}) { 'test' }
32
32
 
33
33
  # with Minitest::Spec
34
- # watch(%r{^spec/(.*)_spec\.rb$})
35
- # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
36
- # watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
34
+ watch(%r{^spec/(.*)\/?spec_(.*)\.rb$})
35
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "spec/#{m[1]}spec_#{m[2]}.rb" }
36
+ watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
37
37
  end
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'rake/testtask'
2
2
 
3
3
  Rake::TestTask.new do |t|
4
- t.libs << 'test'
5
- t.pattern = 'test/lib/**/test_*.rb'
4
+ t.libs << 'lib'
5
+ t.libs << 'spec'
6
+ t.pattern = 'spec/**/*_spec.rb'
6
7
  t.verbose = true
7
8
  end
8
9
 
@@ -16,35 +16,44 @@ module Iterm2
16
16
  class << self
17
17
  def show(arguments)
18
18
  # initialize whenever application called from iTerm2 with arguments
19
- return unless ENV['TERM_PROGRAM'] == 'iTerm.app' || arguments.nil?
19
+ return unless ENV['TERM_PROGRAM'] == 'iTerm.app' || !arguments.nil?
20
20
 
21
21
  # catch options
22
22
  if arguments[0] =~ /^(-\w|--\w{2,}?)$/
23
- # @todo refactoring
24
- # @todo add notification — command not found
23
+ # @todo Refactoring is needed
24
+ # @todo Notification, command not found
25
25
  version if arguments[0].to_s == '--version' || arguments[0].to_s == '-v'
26
26
  # switch to renders
27
27
  else
28
28
  # clean entire screen
29
- # todo: optimize (fit to enitre screen)
30
- print "\e[2J\e[f"
31
-
32
- # reveal media files
33
- arguments.each do |route|
34
- begin
35
- Render.new(Media.new route).reveal
36
- # skip incorrect routes
37
- rescue ArgumentError
38
- next
39
- end
29
+ # @todo Optimize (fit to enitre screen)
30
+
31
+ # prerapre media files for render
32
+ render arguments
33
+ end
34
+ end
35
+
36
+ # Preare routes argumetns to render
37
+ #
38
+ # @param routes [Array] parameters with path to file
39
+ def render(objects)
40
+ return if objects.nil?
41
+ print "\e[2J\e[f"
42
+ objects.each do |o|
43
+ begin
44
+ Render.new(Media.new o).reveal
45
+ rescue ArgumentError
46
+ next
40
47
  end
41
48
  end
42
49
  end
43
50
 
51
+ # Display current version of application
52
+ #
53
+ # @return [String] Constant of version of application
44
54
  def version
45
55
  abort VERSION
46
56
  end
47
-
48
57
  end
49
58
  end
50
59
  end
@@ -10,7 +10,6 @@ module Iterm2
10
10
  #
11
11
  # @param object [String] need to prepare to render
12
12
  def initialize(object)
13
-
14
13
  # Raise error if file doesn't exist
15
14
  fail ArgumentError, 'file doesn\'t exist' unless File.file? object
16
15
 
@@ -2,6 +2,6 @@ module Iterm2
2
2
  # Display media files in command line
3
3
  module Viewer
4
4
  # Current version of application
5
- VERSION = '0.0.7'
5
+ VERSION = '0.0.8'
6
6
  end
7
7
  end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ describe Iterm2::Viewer::Media do
4
+ it 'media will not be created without route argument' do
5
+ assert_raises ArgumentError do
6
+ Iterm2::Viewer::Media.new
7
+ end
8
+ end
9
+
10
+ it 'media will not be created with incorrect route argument' do
11
+ assert_raises ArgumentError do
12
+ Iterm2::Viewer::Media.new 'String'
13
+ end
14
+ end
15
+
16
+ it 'media will be created if route and mime argument is correct' do
17
+ file = File.absolute_path(File.dirname(__FILE__) + '../../../../support/supported.png')
18
+ Iterm2::Viewer::Media.new(file).wont_be_empty
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+
3
+ describe Iterm2::Viewer::Render do
4
+ it 'renderer will not be created without media object as argument' do
5
+ assert_raises ArgumentError do
6
+ Iterm2::Viewer::Render.new
7
+ end
8
+ end
9
+
10
+ it 'renderer will not be initialized with incorrect object argument' do
11
+ assert_raises ArgumentError do
12
+ Iterm2::Viewer::Render.new 'String'
13
+ end
14
+ end
15
+
16
+ it 'render will be initialized if object type will be correct' do
17
+ file = File.absolute_path(File.dirname(__FILE__) + '../../../../support/supported.png')
18
+ media = Iterm2::Viewer::Media.new(file)
19
+
20
+ Iterm2::Viewer::Render.new(media).wont_be_nil
21
+ end
22
+ end
@@ -4,6 +4,7 @@ if ENV['CODECLIMATE_REPO_TOKEN']
4
4
  end
5
5
 
6
6
  require 'minitest/autorun'
7
- require 'minitest/unit'
7
+ require 'minitest/spec'
8
8
  require 'minitest/pride'
9
+
9
10
  require File.expand_path('../../lib/iterm2/viewer.rb', __FILE__)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iterm2-viewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Antipov
@@ -274,12 +274,12 @@ files:
274
274
  - lib/iterm2/viewer/media.rb
275
275
  - lib/iterm2/viewer/render.rb
276
276
  - lib/iterm2/viewer/version.rb
277
- - test/lib/iterm2/viewer/test_media.rb
278
- - test/lib/iterm2/viewer/test_render.rb
279
- - test/lib/iterm2/viewer/test_version.rb
280
- - test/media/supported.png
281
- - test/media/unsupported.txt
282
- - test/test_helper.rb
277
+ - spec/lib/iterm2/viewer/media_spec.rb
278
+ - spec/lib/iterm2/viewer/render_spec.rb
279
+ - spec/lib/iterm2/viewer/version_spec.rb
280
+ - spec/support/supported.png
281
+ - spec/support/unsupported.txt
282
+ - spec/test_helper.rb
283
283
  homepage: https://github.com/AndreyAntipov/iterm2-viewer
284
284
  licenses:
285
285
  - MIT
@@ -305,10 +305,10 @@ signing_key:
305
305
  specification_version: 4
306
306
  summary: Utility for view images in the terminal
307
307
  test_files:
308
- - test/lib/iterm2/viewer/test_media.rb
309
- - test/lib/iterm2/viewer/test_render.rb
310
- - test/lib/iterm2/viewer/test_version.rb
311
- - test/media/supported.png
312
- - test/media/unsupported.txt
313
- - test/test_helper.rb
308
+ - spec/lib/iterm2/viewer/media_spec.rb
309
+ - spec/lib/iterm2/viewer/render_spec.rb
310
+ - spec/lib/iterm2/viewer/version_spec.rb
311
+ - spec/support/supported.png
312
+ - spec/support/unsupported.txt
313
+ - spec/test_helper.rb
314
314
  has_rdoc:
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe Iterm2::Viewer::Media do
4
- it 'media will not be created without route argument' do
5
- assert_raises ArgumentError do
6
- Iterm2::Viewer::Media.new
7
- end
8
- end
9
-
10
- it 'media will not be created with incorrect route argument' do
11
- assert_raises ArgumentError do
12
- Iterm2::Viewer::Media.new 'String'
13
- end
14
- end
15
-
16
- it 'media will be created if route and mime argument is correct' do
17
- file = File.absolute_path(__dir__ + '/../../../media/supported.png')
18
- Iterm2::Viewer::Media.new(file).wont_be_empty
19
- end
20
- end
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
-
4
- describe Iterm2::Viewer::Render do
5
- it 'renderer will not be created without media object as argument' do
6
- assert_raises ArgumentError do
7
- Iterm2::Viewer::Render.new
8
- end
9
- end
10
-
11
- it 'renderer will not be initialized with incorrect object argument' do
12
- assert_raises ArgumentError do
13
- Iterm2::Viewer::Render.new 'String'
14
- end
15
- end
16
-
17
- it 'render will be initialized if object type will be correct' do
18
- file = File.absolute_path(__dir__ + '/../../../media/supported.png')
19
- media = Iterm2::Viewer::Media.new(file)
20
-
21
- Iterm2::Viewer::Render.new(media).wont_be_nil
22
- end
23
- end