mireru 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/mireru/command/mireru.rb +38 -8
- data/lib/mireru/version.rb +1 -1
- data/lib/mireru/window.rb +10 -0
- data/test/test-container.rb +1 -1
- data/test/test-logger.rb +1 -1
- data/test/test-mireru.rb +69 -1
- data/test/test-widget.rb +1 -1
- data/test/test-window.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30b30b55a62ebb76c00bb13f7f8fd49c80ec6ade
|
4
|
+
data.tar.gz: 62cf52fd2780daa0e6d9e62a9d666536e64afb6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff475315e946a1aa82a60a21556899127c111f5b0a025428ded94fbb0c3a9e32dfd87a5de70c46eeff6d8fc69d536b061574e520296866e1522021077e49a509
|
7
|
+
data.tar.gz: ade0850157b14f64964c4c7d48997a7ec71c30f0bc061772a93651ca178165762559151e28017babab5601d3a0222dda82a2b4d5ea330ef86ced466d96176f5d
|
data/README.md
CHANGED
@@ -12,10 +12,14 @@ A friend of a keyboard.
|
|
12
12
|
|
13
13
|
### Launch
|
14
14
|
|
15
|
-
$ mireru [FILE...
|
15
|
+
$ mireru [OPTION]... [FILE]...
|
16
16
|
|
17
17
|
If no argument, then search current directory.
|
18
18
|
|
19
|
+
### Options
|
20
|
+
|
21
|
+
-d, --deep: deep search
|
22
|
+
|
19
23
|
### Keybind
|
20
24
|
|
21
25
|
#### Common
|
@@ -26,6 +30,8 @@ p: prev
|
|
26
30
|
|
27
31
|
r: reload
|
28
32
|
|
33
|
+
e: expand path
|
34
|
+
|
29
35
|
q: quit
|
30
36
|
|
31
37
|
#### Scroll
|
@@ -6,7 +6,7 @@ require "mireru/container"
|
|
6
6
|
module Mireru
|
7
7
|
module Command
|
8
8
|
class Mireru
|
9
|
-
USAGE = "Usage: mireru [FILE...
|
9
|
+
USAGE = "Usage: mireru [OPTION]... [FILE]..."
|
10
10
|
|
11
11
|
class << self
|
12
12
|
def run(*arguments)
|
@@ -19,17 +19,14 @@ module Mireru
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def run(arguments)
|
22
|
-
if arguments
|
23
|
-
files = Dir.glob("*")
|
24
|
-
file_container = ::Mireru::Container.new(files)
|
25
|
-
elsif /\A(-h|--help)\z/ =~ arguments[0]
|
22
|
+
if /\A(-h|--help)\z/ =~ arguments[0]
|
26
23
|
write_help_message
|
27
24
|
exit(true)
|
28
|
-
else
|
29
|
-
files = arguments
|
30
|
-
file_container = ::Mireru::Container.new(files)
|
31
25
|
end
|
32
26
|
|
27
|
+
files = files_from_arguments(arguments)
|
28
|
+
file_container = ::Mireru::Container.new(files)
|
29
|
+
|
33
30
|
if file_container.empty?
|
34
31
|
write_empty_message
|
35
32
|
exit(false)
|
@@ -42,14 +39,47 @@ module Mireru
|
|
42
39
|
end
|
43
40
|
|
44
41
|
private
|
42
|
+
def files_from_arguments(arguments)
|
43
|
+
if arguments.empty?
|
44
|
+
files = Dir.glob("*")
|
45
|
+
elsif /\A(-d|--deep)\z/ =~ arguments[0]
|
46
|
+
arguments.shift
|
47
|
+
if arguments.empty?
|
48
|
+
files = Dir.glob("**/*")
|
49
|
+
else
|
50
|
+
files = []
|
51
|
+
arguments.each do |f|
|
52
|
+
if File.directory?(f)
|
53
|
+
files << Dir.glob("#{f}/**/*")
|
54
|
+
else
|
55
|
+
files << f
|
56
|
+
end
|
57
|
+
end
|
58
|
+
files.flatten!
|
59
|
+
end
|
60
|
+
elsif arguments.all? {|v| File.directory?(v) }
|
61
|
+
files = []
|
62
|
+
arguments.each do |f|
|
63
|
+
files << Dir.glob("#{f}/*")
|
64
|
+
end
|
65
|
+
files.flatten!
|
66
|
+
else
|
67
|
+
files = arguments
|
68
|
+
end
|
69
|
+
files
|
70
|
+
end
|
71
|
+
|
45
72
|
def write_help_message
|
46
73
|
message = <<-EOM
|
47
74
|
#{USAGE}
|
48
75
|
If no argument, then search current directory.
|
76
|
+
Options:
|
77
|
+
-d, --deep: deep search
|
49
78
|
Keybind:
|
50
79
|
n: next
|
51
80
|
p: prev
|
52
81
|
r: reload
|
82
|
+
e: expand path
|
53
83
|
q: quit
|
54
84
|
|
55
85
|
scroll:
|
data/lib/mireru/version.rb
CHANGED
data/lib/mireru/window.rb
CHANGED
@@ -30,6 +30,8 @@ module Mireru
|
|
30
30
|
self.add_from_file(@file)
|
31
31
|
when Gdk::Keyval::GDK_KEY_r
|
32
32
|
self.add_from_file(@file)
|
33
|
+
when Gdk::Keyval::GDK_KEY_e
|
34
|
+
self.title = File.expand_path(@file)
|
33
35
|
when Gdk::Keyval::GDK_KEY_f
|
34
36
|
if Mireru::Widget.image?(@file)
|
35
37
|
pixbuf = Gdk::Pixbuf.new(@file, *self.size)
|
@@ -48,6 +50,14 @@ module Mireru
|
|
48
50
|
@scroll.vadjustment.value -= 17
|
49
51
|
when Gdk::Keyval::GDK_KEY_l
|
50
52
|
@scroll.hadjustment.value += 17
|
53
|
+
when Gdk::Keyval::GDK_KEY_H
|
54
|
+
@scroll.hadjustment.value -= 1000000
|
55
|
+
when Gdk::Keyval::GDK_KEY_J, Gdk::Keyval::GDK_KEY_G
|
56
|
+
@scroll.vadjustment.value += 1000000
|
57
|
+
when Gdk::Keyval::GDK_KEY_K
|
58
|
+
@scroll.vadjustment.value -= 1000000
|
59
|
+
when Gdk::Keyval::GDK_KEY_L
|
60
|
+
@scroll.hadjustment.value += 1000000
|
51
61
|
when Gdk::Keyval::GDK_KEY_q
|
52
62
|
Gtk.main_quit
|
53
63
|
end
|
data/test/test-container.rb
CHANGED
data/test/test-logger.rb
CHANGED
data/test/test-mireru.rb
CHANGED
@@ -1,4 +1,72 @@
|
|
1
1
|
require "mireru/command/mireru"
|
2
2
|
|
3
|
-
class
|
3
|
+
class MireruTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@mireru = Mireru::Command::Mireru.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_run_help_option
|
9
|
+
arguments = %w(--help)
|
10
|
+
mock(@mireru).write_help_message
|
11
|
+
assert_raise SystemExit do
|
12
|
+
@mireru.run(arguments)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_run_help_option_sugar
|
17
|
+
arguments = %w(-h)
|
18
|
+
mock(@mireru).write_help_message
|
19
|
+
assert_raise SystemExit do
|
20
|
+
@mireru.run(arguments)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_files_from_arguments_no_argument
|
25
|
+
arguments = %w()
|
26
|
+
expected = %w(dir1 file1 dir2)
|
27
|
+
mock(Dir).glob("*") { expected }
|
28
|
+
files = @mireru.__send__(:files_from_arguments, arguments)
|
29
|
+
assert_equal(files, expected)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_files_from_arguments_deep_option_only
|
33
|
+
arguments = %w(--deep)
|
34
|
+
expected = %w(dir1 file1 dir2 dir1/file1 dir1/file2 dir2/file1)
|
35
|
+
mock(Dir).glob("**/*") { expected }
|
36
|
+
files = @mireru.__send__(:files_from_arguments, arguments)
|
37
|
+
assert_equal(files, expected)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_files_from_arguments_deep_option_and_dir
|
41
|
+
arguments = %w(--deep dir1 file1 dir2)
|
42
|
+
expected_dir1 = %w(dir1/file1 dir1/file2)
|
43
|
+
expected_dir2 = %w(dir2/file1)
|
44
|
+
expected = [expected_dir1, "file1", expected_dir2].flatten
|
45
|
+
mock(File).directory?("dir1") { true }
|
46
|
+
mock(File).directory?("file1") { false }
|
47
|
+
mock(File).directory?("dir2") { true }
|
48
|
+
mock(Dir).glob("dir1/**/*") { expected_dir1 }
|
49
|
+
mock(Dir).glob("dir2/**/*") { expected_dir2 }
|
50
|
+
files = @mireru.__send__(:files_from_arguments, arguments)
|
51
|
+
assert_equal(files, expected)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_files_from_arguments_all_dir
|
55
|
+
arguments = %w(dir1 dir2)
|
56
|
+
expected_dir1 = %w(dir1/file1 dir1/file2)
|
57
|
+
expected_dir2 = %w(dir2/file1)
|
58
|
+
expected = [expected_dir1, expected_dir2].flatten
|
59
|
+
mock(File).directory?("dir1") { true }
|
60
|
+
mock(File).directory?("dir2") { true }
|
61
|
+
mock(Dir).glob("dir1/*") { expected_dir1 }
|
62
|
+
mock(Dir).glob("dir2/*") { expected_dir2 }
|
63
|
+
files = @mireru.__send__(:files_from_arguments, arguments)
|
64
|
+
assert_equal(files, expected)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_files_from_arguments_else
|
68
|
+
arguments = %w(dir1 file1 dir2)
|
69
|
+
files = @mireru.__send__(:files_from_arguments, arguments)
|
70
|
+
assert_equal(files, arguments)
|
71
|
+
end
|
4
72
|
end
|
data/test/test-widget.rb
CHANGED
data/test/test-window.rb
CHANGED
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
|
4
|
+
version: 0.1.0
|
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-
|
11
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gtk3
|