mireru 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +12 -0
- data/README.md +5 -1
- data/lib/mireru/command/mireru.rb +23 -4
- data/lib/mireru/version.rb +1 -1
- data/lib/mireru/widget.rb +1 -0
- data/lib/mireru/window.rb +6 -0
- data/test/test-mireru.rb +10 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4af6b308832832e50dca8694b82fa42b30620a10
|
4
|
+
data.tar.gz: ff89a104fb6b23923092d96215abfa0a0e96afe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebfdd64bdfd0b9fd2806cbf721952a3175c75982a45f4179649190e714d4525fa4f800713797a5b5f47097c3dfb772ec06c20dccf6922ab574f2264c14d77c7e
|
7
|
+
data.tar.gz: d8a4448a9adb13d360aa2f0dfc8ef326502911a3e831063d8f3ac6a90aa6c95ac7c574a0b7cb5182cd6727315eced4c3fcb88a9628c1710bf6465af7434d122d
|
data/NEWS.md
ADDED
data/README.md
CHANGED
@@ -28,6 +28,8 @@ module Mireru
|
|
28
28
|
exit(true)
|
29
29
|
end
|
30
30
|
|
31
|
+
font = purge_option(arguments, /\A(-f|--font)\z/, true)
|
32
|
+
|
31
33
|
files = files_from_arguments(arguments)
|
32
34
|
file_container = ::Mireru::Container.new(files)
|
33
35
|
|
@@ -37,6 +39,7 @@ module Mireru
|
|
37
39
|
end
|
38
40
|
|
39
41
|
window = ::Mireru::Window.new
|
42
|
+
window.font = font if font
|
40
43
|
window.add_container(file_container)
|
41
44
|
|
42
45
|
Gtk.main
|
@@ -46,8 +49,7 @@ module Mireru
|
|
46
49
|
def files_from_arguments(arguments)
|
47
50
|
if arguments.empty?
|
48
51
|
files = Dir.glob("*")
|
49
|
-
elsif /\A(-d|--deep)\z/
|
50
|
-
arguments.shift
|
52
|
+
elsif purge_option(arguments, /\A(-d|--deep)\z/)
|
51
53
|
if arguments.empty?
|
52
54
|
files = Dir.glob("**/*")
|
53
55
|
else
|
@@ -73,12 +75,26 @@ module Mireru
|
|
73
75
|
files
|
74
76
|
end
|
75
77
|
|
78
|
+
def purge_option(arguments, regexp, has_value=false)
|
79
|
+
index = arguments.find_index {|arg| regexp =~ arg }
|
80
|
+
return false unless index
|
81
|
+
if has_value
|
82
|
+
arguments.delete_at(index) # flag
|
83
|
+
arguments.delete_at(index) # value
|
84
|
+
else
|
85
|
+
arguments.delete_at(index)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
76
89
|
def write_help_message
|
77
90
|
message = <<-EOM
|
78
91
|
#{USAGE}
|
79
92
|
If no argument, then search current directory.
|
80
93
|
Options:
|
81
|
-
-d, --deep
|
94
|
+
-d, --deep
|
95
|
+
deep search as "**/*"
|
96
|
+
-f, --font
|
97
|
+
set font such as "Monospace 16"
|
82
98
|
Keybind:
|
83
99
|
n: next
|
84
100
|
p: prev
|
@@ -112,7 +128,10 @@ Warning: file not found.
|
|
112
128
|
#{USAGE}
|
113
129
|
If no argument, then search current directory.
|
114
130
|
Options:
|
115
|
-
-d, --deep
|
131
|
+
-d, --deep
|
132
|
+
deep search as "**/*"
|
133
|
+
-f, --font
|
134
|
+
set font such as "Monospace 16"
|
116
135
|
EOM
|
117
136
|
@logger.error(message)
|
118
137
|
end
|
data/lib/mireru/version.rb
CHANGED
data/lib/mireru/widget.rb
CHANGED
data/lib/mireru/window.rb
CHANGED
@@ -3,6 +3,7 @@ require "mireru/widget"
|
|
3
3
|
|
4
4
|
module Mireru
|
5
5
|
class Window < Gtk::Window
|
6
|
+
attr_accessor :font
|
6
7
|
def initialize
|
7
8
|
super
|
8
9
|
@scroll = Gtk::ScrolledWindow.new
|
@@ -36,6 +37,10 @@ module Mireru
|
|
36
37
|
if Mireru::Widget.image?(@file)
|
37
38
|
pixbuf = Gdk::Pixbuf.new(@file, *self.size)
|
38
39
|
@widget.pixbuf = pixbuf
|
40
|
+
elsif @widget.is_a?(Gtk::TextView)
|
41
|
+
font = @widget.pango_context.families.sample.name
|
42
|
+
@widget.override_font(Pango::FontDescription.new(font))
|
43
|
+
self.title = "#{File.basename(@file)} (#{font})"
|
39
44
|
end
|
40
45
|
when Gdk::Keyval::GDK_KEY_o
|
41
46
|
if Mireru::Widget.image?(@file)
|
@@ -69,6 +74,7 @@ module Mireru
|
|
69
74
|
@scroll.vadjustment.value = 0
|
70
75
|
@scroll.each {|child| @scroll.remove(child) }
|
71
76
|
@widget = Mireru::Widget.create(file, *self.size)
|
77
|
+
@widget.override_font(Pango::FontDescription.new(@font)) if @font
|
72
78
|
if @widget.is_a?(Gtk::Scrollable)
|
73
79
|
@scroll.add(@widget)
|
74
80
|
else
|
data/test/test-mireru.rb
CHANGED
@@ -88,4 +88,14 @@ class MireruTest < Test::Unit::TestCase
|
|
88
88
|
files = @mireru.__send__(:files_from_arguments, arguments)
|
89
89
|
assert_equal(files, arguments)
|
90
90
|
end
|
91
|
+
|
92
|
+
def test_purge_option
|
93
|
+
arguments = %w(--deep -f ubuntu dir1 file1 dir2)
|
94
|
+
flag = @mireru.__send__(:purge_option, arguments, /\A(-d|--deep)\z/)
|
95
|
+
assert_not_nil(flag)
|
96
|
+
assert_equal(%w(-f ubuntu dir1 file1 dir2), arguments)
|
97
|
+
value = @mireru.__send__(:purge_option, arguments, /\A-f\z/, true)
|
98
|
+
assert_equal("ubuntu", value)
|
99
|
+
assert_equal(%w(dir1 file1 dir2), arguments)
|
100
|
+
end
|
91
101
|
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.1.
|
4
|
+
version: 0.1.2
|
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-
|
11
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gtk3
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- .travis.yml
|
122
122
|
- Gemfile
|
123
123
|
- LICENSE.txt
|
124
|
+
- NEWS.md
|
124
125
|
- README.md
|
125
126
|
- Rakefile
|
126
127
|
- bin/mireru
|