nametrainer 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +0 -2
- data/bin/nametrainer +20 -0
- data/lib/nametrainer.rb +14 -16
- data/lib/nametrainer/gui.rb +5 -2
- data/lib/nametrainer/optionparser.rb +2 -2
- data/lib/nametrainer/version.rb +2 -2
- metadata +6 -6
data/README.md
CHANGED
@@ -57,8 +57,6 @@ Please note:
|
|
57
57
|
|
58
58
|
- Do not use special characters in file names; use underscore instead of space.
|
59
59
|
- Use UTF-8 encoding for TXT files.
|
60
|
-
- **On Windows, JPG files might not be supported** (depending on the Qt version).
|
61
|
-
In this case use PNG images instead.
|
62
60
|
|
63
61
|
Installation
|
64
62
|
------------
|
data/bin/nametrainer
CHANGED
@@ -8,6 +8,13 @@ module Nametrainer
|
|
8
8
|
|
9
9
|
ERRORCODE = {:general => 1, :usage => 2}
|
10
10
|
|
11
|
+
# Prints an error message, then exits with +code+
|
12
|
+
# (<tt>:general</tt> or <tt>:usage</tt>).
|
13
|
+
def self.fail(message, code = :general) #
|
14
|
+
warn "#{PROGNAME}: #{message}"
|
15
|
+
exit ERRORCODE[code]
|
16
|
+
end
|
17
|
+
|
11
18
|
# Prints an error message and a short help information, then exits.
|
12
19
|
def self.usage_fail(message) # :nodoc:
|
13
20
|
warn "#{PROGNAME}: #{message}"
|
@@ -25,6 +32,11 @@ rescue => e
|
|
25
32
|
Nametrainer.usage_fail(e.message)
|
26
33
|
end
|
27
34
|
|
35
|
+
# exit gracefully for missing Qt bindings
|
36
|
+
message = "missing Ruby Qt bindings (LoadError)\n"
|
37
|
+
message << "You should install the `qtbindings' gem."
|
38
|
+
Nametrainer.fail(message) if Nametrainer::QT_LOAD_ERROR
|
39
|
+
|
28
40
|
# set up demo mode
|
29
41
|
if options[:demo]
|
30
42
|
options[:collection] = File.expand_path("#{SRCPATH}/../demo_collection")
|
@@ -32,5 +44,13 @@ end
|
|
32
44
|
|
33
45
|
# start
|
34
46
|
app = Qt::Application.new ARGV
|
47
|
+
|
48
|
+
# try to add plugins path
|
49
|
+
begin
|
50
|
+
qtbindings_path = Gem::Specification.find_by_name('qtbindings').gem_dir
|
51
|
+
app.add_library_path("#{qtbindings_path}/bin/plugins")
|
52
|
+
rescue Gem::LoadError
|
53
|
+
end
|
54
|
+
|
35
55
|
Nametrainer::GUI.new(options)
|
36
56
|
app.exec
|
data/lib/nametrainer.rb
CHANGED
@@ -2,28 +2,17 @@
|
|
2
2
|
#
|
3
3
|
# nametrainer - name learning trainer
|
4
4
|
#
|
5
|
-
# == Synopsis
|
6
|
-
#
|
7
|
-
# nametrainer [options] [collection]
|
8
|
-
#
|
9
5
|
# == Description
|
10
6
|
#
|
11
7
|
# +nametrainer+ is a name learning trainer using Ruby and the Qt GUI toolkit.
|
12
8
|
# It will assist you in learning people's names from a collection of images.
|
13
9
|
#
|
14
|
-
# See
|
15
|
-
# https://github.com/stomar/nametrainer/
|
16
|
-
#
|
17
|
-
# == Options
|
18
|
-
#
|
19
|
-
# -d, --[no-]demo:: Start the application with a demo collection.
|
10
|
+
# == See also
|
20
11
|
#
|
21
|
-
#
|
22
|
-
# use non-random order, display names at once.
|
12
|
+
# Use <tt>nametrainer --help</tt> to display a brief help message.
|
23
13
|
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# -v, --version:: Prints a brief version information and exits.
|
14
|
+
# The full documentation for +nametrainer+ is available on the
|
15
|
+
# project home page.
|
27
16
|
#
|
28
17
|
# == Author
|
29
18
|
#
|
@@ -31,7 +20,16 @@
|
|
31
20
|
#
|
32
21
|
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
33
22
|
|
34
|
-
|
23
|
+
module Nametrainer; end
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'Qt'
|
27
|
+
Nametrainer::QT_LOAD_ERROR = false
|
28
|
+
rescue LoadError => e
|
29
|
+
Nametrainer::QT_LOAD_ERROR = e
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'nametrainer/gui' unless Nametrainer::QT_LOAD_ERROR
|
35
33
|
require 'nametrainer/person'
|
36
34
|
require 'nametrainer/collection'
|
37
35
|
require 'nametrainer/optionparser'
|
data/lib/nametrainer/gui.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'Qt'
|
2
1
|
require 'iconv' if RUBY_VERSION < '1.9' # utf-8 -> latin1 for QLabel
|
3
2
|
|
4
3
|
module Nametrainer
|
@@ -223,7 +222,11 @@ module Nametrainer
|
|
223
222
|
|
224
223
|
# Displays the image, scaled as large as possible.
|
225
224
|
def show_image
|
226
|
-
|
225
|
+
if @image.null?
|
226
|
+
@image_label.set_text "<i>Unable to display `#{File.basename(@person.image)}'.</i>"
|
227
|
+
else
|
228
|
+
@image_label.set_pixmap @image.scaled(@image_label.size, Qt::KeepAspectRatio)
|
229
|
+
end
|
227
230
|
end
|
228
231
|
|
229
232
|
# Chooses and displays the next person,
|
@@ -36,14 +36,14 @@ module Nametrainer
|
|
36
36
|
|
37
37
|
# process --version and --help first,
|
38
38
|
# exit successfully (GNU Coding Standards)
|
39
|
-
opt.on_tail('-h', '--help', '
|
39
|
+
opt.on_tail('-h', '--help', 'Print a brief help message and exit.') do
|
40
40
|
puts opt_parser
|
41
41
|
puts "\nReport bugs on the #{PROGNAME} home page: <#{HOMEPAGE}>"
|
42
42
|
exit
|
43
43
|
end
|
44
44
|
|
45
45
|
opt.on_tail('-v', '--version',
|
46
|
-
'
|
46
|
+
'Print a brief version information and exit.') do
|
47
47
|
puts "#{PROGNAME} #{VERSION}"
|
48
48
|
puts COPYRIGHT
|
49
49
|
exit
|
data/lib/nametrainer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nametrainer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &80165180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *80165180
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: minitest
|
27
|
-
requirement: &
|
27
|
+
requirement: &80164650 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *80164650
|
36
36
|
description: nametrainer is a name learning trainer using the Qt GUI toolkit. It will
|
37
37
|
assist you in learning people's names from a collection of images.
|
38
38
|
email: sto.mar@web.de
|