mireru 0.0.3 → 0.0.4

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: 99d2d11f881eb11ebd1ad245293dfccf27686ae2
4
- data.tar.gz: 5bc6780adf13074b891b4977fd80cbc3b174ccc1
3
+ metadata.gz: 823a644a352283dc2d0c090875be91cde1f7d75a
4
+ data.tar.gz: eb39688fba3a36c2ec61493682cb039f0ddb68a6
5
5
  SHA512:
6
- metadata.gz: 5bb1cc7ecce29d04e7caad8d4979cbbd4d4fcd6895caf60eed6e1ef01a9ac5335b582fae03a1764378dcdd9fe8740238dd3f945f95923b124fe2309f5962c6f6
7
- data.tar.gz: 0151c89f4dc77a50f5a26b537d80c7df609d7f7037e4e562520a4d01461aff8baf03815c6b4937170e67b190e8211351b49c05ac43a32eeeb7cc6ad3967957c2
6
+ metadata.gz: f9e1c55ebb8637c5f0cfee8a7096293a47a105c8e59756413929807c06f6b3e756f8a7ad70786aa14ac9bf42e1a010f6755f27d7c862ffec08dc20f922d2784c
7
+ data.tar.gz: c4228458940f3f334b19afd37871c936d14d8c27f4e17c038b5a4a5b61c46e6b56abbb9bdf6b4ffa09dbf745ee547855e924918990e030370f3666c3692e4256
data/README.md CHANGED
@@ -1,24 +1,14 @@
1
- # Mireru - Lightweight File Viewer for CLI
1
+ # Mireru - Flexible File Viewer
2
2
 
3
- Mireru is a lightweight file viewer. It can launch from CLI. Powered by Ruby/GTK3.
3
+ A file viewer with a focus on flexibility by Ruby/GTK3.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'mireru'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
7
  $ gem install mireru
18
8
 
19
9
  ## Usage
20
10
 
21
- $ mireru <file path>
11
+ $ mireru [FILE...]
22
12
 
23
13
  ## Contributing
24
14
 
@@ -3,7 +3,7 @@ require 'gtk3'
3
3
  module Mireru
4
4
  module Command
5
5
  class Mireru
6
- USAGE = "Usage: mireru <file path>"
6
+ USAGE = "Usage: mireru [FILE...]"
7
7
 
8
8
  class << self
9
9
  def run(*arguments)
@@ -15,40 +15,88 @@ module Mireru
15
15
  end
16
16
 
17
17
  def run(arguments)
18
+ if arguments.empty?
19
+ file_container = Dir.glob("*")
20
+ else
21
+ file_container = arguments
22
+ end
23
+
24
+ file_container.select! {|f| support_file?(f) }
25
+
26
+ if file_container.empty?
27
+ puts("Warning: valid file not found.")
28
+ puts(USAGE)
29
+ puts("Support file types: png, gif, jpeg(jpg). The others are...yet.")
30
+ exit(false)
31
+ end
32
+
33
+ image = Gtk::Image.new
34
+ image.file = file_container.shift
35
+
36
+ window = Gtk::Window.new
37
+
38
+ window.signal_connect("key_press_event") do |w, e|
39
+ case e.keyval
40
+ when Gdk::Keyval::GDK_KEY_n
41
+ file_container.push(image.file)
42
+ image.file = file_container.shift
43
+ when Gdk::Keyval::GDK_KEY_p
44
+ file_container.unshift(image.file)
45
+ image.file = file_container.pop
46
+ when Gdk::Keyval::GDK_KEY_q
47
+ Gtk.main_quit
48
+ end
49
+ end
50
+
51
+ window.signal_connect("destroy") do
52
+ Gtk.main_quit
53
+ end
54
+
55
+ window.add(image)
56
+ window.show_all
57
+
58
+ Gtk.main
59
+ end
60
+
61
+ private
62
+ def valid?(arguments)
18
63
  file = arguments[0]
19
64
 
20
65
  unless file
21
66
  puts("Error: no argument.")
22
67
  puts(USAGE)
23
- exit(false)
68
+ return false
24
69
  end
25
70
 
26
71
  unless File.file?(file)
27
72
  puts("Error: missing file.")
28
73
  puts(USAGE)
29
- exit(false)
74
+ return false
30
75
  end
31
76
 
32
77
  unless /\.(png|jpe?g|gif)$/i =~ file
33
78
  puts("Error: this file type is not support as yet.")
34
79
  puts(USAGE)
35
- exit(false)
80
+ return false
36
81
  end
37
82
 
38
- image = Gtk::Image.new
39
- image.file = file
40
-
41
- window = Gtk::Window.new
83
+ true
84
+ end
42
85
 
43
- window.signal_connect("destroy") do
44
- Gtk.main_quit
86
+ def support_file?(file)
87
+ unless file
88
+ return false
45
89
  end
46
90
 
47
- window.border_width = 10
48
- window.add(image)
49
- window.show_all
50
-
51
- Gtk.main
91
+ unless File.file?(file)
92
+ return false
93
+ end
94
+
95
+ unless /\.(png|jpe?g|gif)$/i =~ file
96
+ return false
97
+ end
98
+
99
+ true
52
100
  end
53
101
  end
54
102
  end
@@ -1,3 +1,3 @@
1
1
  module Mireru
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Mireru::VERSION
9
9
  spec.authors = ["Masafumi Yokoyama"]
10
10
  spec.email = ["myokoym@gmail.com"]
11
- spec.summary = %q{Lightweight file viewer for CLI}
12
- spec.description = %q{Mireru is a lightweight file viewer. It can launch from CLI. Powered by Ruby/GTK3.}
11
+ spec.summary = %q{Flexible File Viewer}
12
+ spec.description = %q{A file viewer with a focus on flexibility by Ruby/GTK3.}
13
13
  spec.homepage = "https://github.com/myokoym/mireru"
14
14
  spec.license = "MIT"
15
15
 
@@ -20,6 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency("gtk3")
22
22
 
23
+ spec.add_development_dependency("test-unit")
24
+ spec.add_development_dependency("test-unit-notify")
25
+ spec.add_development_dependency("test-unit-rr")
23
26
  spec.add_development_dependency("bundler", "~> 1.3")
24
27
  spec.add_development_dependency("rake")
25
28
  end
Binary file
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "test-unit"
4
+ require "test/unit/notify"
5
+ require "test/unit/rr"
6
+
7
+ base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
8
+ $LOAD_PATH.unshift(File.join(base_dir, "lib"))
9
+ $LOAD_PATH.unshift(File.join(base_dir, "test"))
10
+
11
+ exit Test::Unit::AutoRunner.run(true)
@@ -0,0 +1,57 @@
1
+ require "mireru/command/mireru"
2
+ require "stringio"
3
+
4
+ module ValidTests
5
+ def test_no_argument
6
+ s = ""
7
+ io = StringIO.new(s)
8
+ $stdout = io
9
+ valid = @mireru.__send__(:valid?, [])
10
+ $stdout = STDOUT
11
+ assert_false(valid)
12
+ assert_equal(<<-EOT, s)
13
+ Error: no argument.
14
+ #{Mireru::Command::Mireru::USAGE}
15
+ EOT
16
+ end
17
+
18
+ def test_missing_file
19
+ s = ""
20
+ io = StringIO.new(s)
21
+ $stdout = io
22
+ valid = @mireru.__send__(:valid?, ["hoge"])
23
+ $stdout = STDOUT
24
+ assert_false(valid)
25
+ assert_equal(<<-EOT, s)
26
+ Error: missing file.
27
+ #{Mireru::Command::Mireru::USAGE}
28
+ EOT
29
+ end
30
+
31
+ def test_not_support_file_type
32
+ s = ""
33
+ io = StringIO.new(s)
34
+ $stdout = io
35
+ valid = @mireru.__send__(:valid?, [__FILE__])
36
+ $stdout = STDOUT
37
+ assert_false(valid)
38
+ assert_equal(<<-EOT, s)
39
+ Error: this file type is not support as yet.
40
+ #{Mireru::Command::Mireru::USAGE}
41
+ EOT
42
+ end
43
+
44
+ def test_png_file
45
+ file = File.join(File.dirname(__FILE__), "fixtures", "nijip.png")
46
+ valid = @mireru.__send__(:valid?, [file])
47
+ assert_true(valid)
48
+ end
49
+ end
50
+
51
+ class TestMireru < Test::Unit::TestCase
52
+ def setup
53
+ @mireru = Mireru::Command::Mireru.new
54
+ end
55
+
56
+ include ValidTests
57
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mireru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masafumi Yokoyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-03 00:00:00.000000000 Z
11
+ date: 2013-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gtk3
@@ -24,6 +24,48 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit-notify
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: test-unit-rr
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'
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: bundler
29
71
  requirement: !ruby/object:Gem::Requirement
@@ -52,8 +94,7 @@ dependencies:
52
94
  - - '>='
53
95
  - !ruby/object:Gem::Version
54
96
  version: '0'
55
- description: Mireru is a lightweight file viewer. It can launch from CLI. Powered
56
- by Ruby/GTK3.
97
+ description: A file viewer with a focus on flexibility by Ruby/GTK3.
57
98
  email:
58
99
  - myokoym@gmail.com
59
100
  executables:
@@ -71,6 +112,9 @@ files:
71
112
  - lib/mireru/command/mireru.rb
72
113
  - lib/mireru/version.rb
73
114
  - mireru.gemspec
115
+ - test/fixtures/nijip.png
116
+ - test/run-test.rb
117
+ - test/test-mireru.rb
74
118
  homepage: https://github.com/myokoym/mireru
75
119
  licenses:
76
120
  - MIT
@@ -94,6 +138,9 @@ rubyforge_project:
94
138
  rubygems_version: 2.0.0
95
139
  signing_key:
96
140
  specification_version: 4
97
- summary: Lightweight file viewer for CLI
98
- test_files: []
141
+ summary: Flexible File Viewer
142
+ test_files:
143
+ - test/fixtures/nijip.png
144
+ - test/run-test.rb
145
+ - test/test-mireru.rb
99
146
  has_rdoc: