alexandria-book-collection-manager 0.7.2 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/ruby.yml +77 -0
- data/.gitignore +5 -1
- data/.hound.yml +2 -0
- data/.rubocop.yml +87 -37
- data/.rubocop_todo.yml +62 -191
- data/.simplecov +5 -2
- data/CHANGELOG.md +63 -0
- data/Gemfile +4 -3
- data/INSTALL.md +26 -14
- data/README.md +52 -42
- data/Rakefile +93 -109
- data/TODO.md +9 -1
- data/alexandria-book-collection-manager.gemspec +50 -43
- data/bin/alexandria +30 -53
- data/doc/FAQ +2 -6
- data/doc/dependency_decisions.yml +27 -8
- data/lib/alexandria.rb +27 -37
- data/lib/alexandria/about.rb +50 -50
- data/lib/alexandria/book_providers.rb +90 -97
- data/lib/alexandria/book_providers/adlibris.rb +41 -76
- data/lib/alexandria/book_providers/amazon_aws.rb +96 -100
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +295 -322
- data/lib/alexandria/book_providers/barnes_and_noble.rb +48 -45
- data/lib/alexandria/book_providers/douban.rb +26 -42
- data/lib/alexandria/book_providers/proxis.rb +44 -55
- data/lib/alexandria/book_providers/pseudomarc.rb +77 -85
- data/lib/alexandria/book_providers/siciliano.rb +64 -65
- data/lib/alexandria/book_providers/thalia.rb +42 -41
- data/lib/alexandria/book_providers/web.rb +15 -33
- data/lib/alexandria/book_providers/worldcat.rb +70 -97
- data/lib/alexandria/book_providers/z3950.rb +160 -173
- data/lib/alexandria/config.rb +1 -1
- data/lib/alexandria/console.rb +8 -21
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +15 -13
- data/lib/alexandria/export_format.rb +47 -0
- data/lib/alexandria/export_library.rb +193 -300
- data/lib/alexandria/import_library.rb +108 -141
- data/lib/alexandria/import_library_csv.rb +43 -46
- data/lib/alexandria/library_collection.rb +79 -0
- data/lib/alexandria/library_sort_order.rb +45 -0
- data/lib/alexandria/library_store.rb +233 -0
- data/lib/alexandria/logging.rb +11 -13
- data/lib/alexandria/models/book.rb +13 -20
- data/lib/alexandria/models/library.rb +81 -353
- data/lib/alexandria/net.rb +5 -6
- data/lib/alexandria/preferences.rb +73 -87
- data/lib/alexandria/scanners.rb +2 -2
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +20 -18
- data/lib/alexandria/scanners/keyboard.rb +8 -8
- data/lib/alexandria/smart_library.rb +133 -170
- data/lib/alexandria/ui.rb +15 -15
- data/lib/alexandria/ui/about_dialog.rb +49 -0
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +119 -136
- data/lib/alexandria/ui/alert_dialog.rb +64 -0
- data/lib/alexandria/ui/bad_isbns_dialog.rb +41 -0
- data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +16 -15
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +39 -52
- data/lib/alexandria/ui/book_properties_dialog_base.rb +318 -0
- data/lib/alexandria/ui/builder_base.rb +7 -27
- data/lib/alexandria/ui/calendar_popup.rb +58 -0
- data/lib/alexandria/ui/callbacks.rb +189 -183
- data/lib/alexandria/ui/completion_models.rb +10 -23
- data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
- data/lib/alexandria/ui/dndable.rb +7 -7
- data/lib/alexandria/ui/error_dialog.rb +25 -0
- data/lib/alexandria/ui/export_dialog.rb +142 -0
- data/lib/alexandria/ui/icons.rb +47 -63
- data/lib/alexandria/ui/iconview.rb +12 -10
- data/lib/alexandria/ui/iconview_tooltips.rb +41 -54
- data/lib/alexandria/ui/import_dialog.rb +157 -0
- data/lib/alexandria/ui/init.rb +21 -33
- data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +36 -0
- data/lib/alexandria/ui/libraries_combo.rb +16 -14
- data/lib/alexandria/ui/listview.rb +73 -87
- data/lib/alexandria/ui/main_app.rb +24 -26
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +28 -41
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +156 -194
- data/lib/alexandria/ui/new_book_dialog_manual.rb +139 -0
- data/lib/alexandria/ui/new_provider_dialog.rb +100 -0
- data/lib/alexandria/ui/new_smart_library_dialog.rb +74 -0
- data/lib/alexandria/ui/preferences_dialog.rb +313 -0
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +95 -0
- data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
- data/lib/alexandria/ui/really_delete_dialog.rb +53 -0
- data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +56 -68
- data/lib/alexandria/ui/skip_entry_dialog.rb +33 -0
- data/lib/alexandria/ui/smart_library_properties_dialog.rb +60 -0
- data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +242 -0
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +11 -13
- data/lib/alexandria/ui/ui_manager.rb +236 -251
- data/lib/alexandria/undo_manager.rb +1 -0
- data/lib/alexandria/version.rb +4 -19
- data/lib/alexandria/web_themes.rb +22 -21
- data/po/Makefile +2 -2
- data/po/cs.po +993 -880
- data/po/cy.po +957 -874
- data/po/de.po +990 -869
- data/po/el.po +989 -869
- data/po/es.po +985 -865
- data/po/fr.po +986 -870
- data/po/ga.po +907 -823
- data/po/gl.po +981 -865
- data/po/it.po +986 -868
- data/po/ja.po +969 -853
- data/po/mk.po +983 -863
- data/po/nb.po +979 -863
- data/po/nl.po +983 -864
- data/po/pl.po +1017 -974
- data/po/pt.po +988 -861
- data/po/pt_BR.po +984 -868
- data/po/ru.po +992 -873
- data/po/sk.po +987 -869
- data/po/sv.po +977 -861
- data/po/uk.po +975 -865
- data/po/zh_TW.po +976 -860
- data/schemas/alexandria.schemas +25 -3
- data/share/alexandria/glade/acquire_dialog__builder.glade +15 -12
- data/share/alexandria/glade/book_properties_dialog__builder.glade +171 -299
- data/share/alexandria/glade/main_app__builder.glade +24 -33
- data/share/alexandria/glade/new_book_dialog__builder.glade +27 -59
- data/share/alexandria/glade/preferences_dialog__builder.glade +250 -290
- data/share/gnome/help/alexandria/C/introduction.xml +0 -8
- data/share/gnome/help/alexandria/C/searching.xml +1 -1
- data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
- data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
- data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
- data/share/gnome/help/alexandria/ja/introduction.xml +0 -8
- data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
- data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
- data/spec/alexandria/book_providers_spec.rb +75 -171
- data/spec/alexandria/book_spec.rb +12 -10
- data/spec/alexandria/console_spec.rb +27 -0
- data/spec/alexandria/export_library_spec.rb +130 -0
- data/spec/alexandria/library_spec.rb +128 -172
- data/spec/alexandria/library_store_spec.rb +37 -0
- data/spec/alexandria/preferences_spec.rb +44 -17
- data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
- data/spec/alexandria/smart_library_spec.rb +30 -25
- data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/export_dialog_spec.rb +36 -0
- data/spec/alexandria/ui/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +7 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +46 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +7 -34
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
- data/spec/alexandria/ui/new_book_dialog_spec.rb +22 -0
- data/spec/alexandria/ui/new_provider_dialog_spec.rb +30 -0
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +39 -0
- data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +34 -0
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
- data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +49 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +43 -20
- data/spec/end_to_end/basic_run_spec.rb +52 -0
- data/spec/spec_helper.rb +65 -33
- data/tasks/setup.rb +2 -2
- data/tasks/spec.rake +16 -3
- data/util/rake/fileinstall.rb +39 -35
- data/util/rake/gettextgenerate.rb +7 -7
- data/util/rake/omfgenerate.rb +7 -7
- metadata +178 -45
- data/dogtail/basic_run_test.py +0 -9
- data/lib/alexandria/book_providers/deastore.rb +0 -265
- data/lib/alexandria/book_providers/mcu.rb +0 -182
- data/lib/alexandria/book_providers/renaud.rb +0 -149
- data/lib/alexandria/ui/dialogs/about_dialog.rb +0 -61
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -72
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +0 -51
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +0 -426
- data/lib/alexandria/ui/dialogs/export_dialog.rb +0 -171
- data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -196
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +0 -87
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +0 -154
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -74
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -568
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -59
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +0 -420
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
- data/spec/alexandria/ui/dialogs_spec.rb +0 -96
- data/spec/alexandria/ui/sidepane_spec.rb +0 -29
- data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
- data/spec/alexandria/utilities_spec.rb +0 -52
- data/tasks/dogtail.rake +0 -6
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is part of Alexandria.
|
4
|
+
#
|
5
|
+
# See the file README.md for authorship and licensing information.
|
6
|
+
|
7
|
+
require "gnome_app_driver"
|
8
|
+
require "tmpdir"
|
9
|
+
|
10
|
+
describe "The Alexandria application" do
|
11
|
+
let(:driver) { GnomeAppDriver.new "alexandria" }
|
12
|
+
|
13
|
+
before do
|
14
|
+
ENV["HOME"] = Dir.mktmpdir
|
15
|
+
driver.boot
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
driver.cleanup
|
20
|
+
end
|
21
|
+
|
22
|
+
it "starts and can be quit with the menu" do
|
23
|
+
frame = driver.frame
|
24
|
+
menu = frame.find_role :menu_item, /Quit/
|
25
|
+
menu.do_action 0
|
26
|
+
|
27
|
+
status = driver.cleanup
|
28
|
+
expect(status.exitstatus).to eq 0
|
29
|
+
end
|
30
|
+
|
31
|
+
it "can be interacted with" do
|
32
|
+
frame = driver.frame
|
33
|
+
frame.find_role(:menu_item, /Title contains/).do_action 0
|
34
|
+
frame.find_role(:menu_item, /View as Icons/).do_action 0
|
35
|
+
frame.find_role(:menu_item, /View as List/).do_action 0
|
36
|
+
frame.find_role(:table_column_header, /Title/).do_action 0
|
37
|
+
|
38
|
+
table_cell = frame.find_role(:table_cell)
|
39
|
+
|
40
|
+
table_cell.n_actions.times do |idx|
|
41
|
+
name = table_cell.get_action_name idx
|
42
|
+
table_cell.do_action idx if name == "activate"
|
43
|
+
end
|
44
|
+
|
45
|
+
frame = driver.frame
|
46
|
+
menu = frame.find_role :menu_item, /Quit/
|
47
|
+
menu.do_action 0
|
48
|
+
|
49
|
+
status = driver.cleanup
|
50
|
+
expect(status.exitstatus).to eq 0
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,47 +1,79 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
4
|
-
# Copyright (C) 2014, 2016 Matijs van Zuijlen
|
3
|
+
# This file is part of Alexandria.
|
5
4
|
#
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
# You should have received a copy of the GNU General Public
|
17
|
-
# License along with Alexandria; see the file COPYING. If not,
|
18
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
19
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
6
|
+
|
7
|
+
require "rspec"
|
8
|
+
require "alexandria"
|
9
|
+
require "webmock/rspec"
|
10
|
+
require "pry"
|
11
|
+
|
12
|
+
LIBDIR = File.expand_path("data/libraries", __dir__)
|
13
|
+
TESTDIR = File.join(LIBDIR, "test")
|
20
14
|
|
21
|
-
|
15
|
+
def an_artist_of_the_floating_world
|
16
|
+
Alexandria::Book.new("An Artist of the Floating World",
|
17
|
+
["Kazuo Ishiguro"],
|
18
|
+
"9780571147168",
|
19
|
+
"Faber and Faber", 1999,
|
20
|
+
"Paperback")
|
21
|
+
end
|
22
22
|
|
23
|
-
|
23
|
+
def assert_correct_search_result(provider, query,
|
24
|
+
search_type = Alexandria::BookProviders::SEARCH_BY_ISBN)
|
25
|
+
begin
|
26
|
+
results = provider.instance.search(query, search_type)
|
27
|
+
rescue SocketError
|
28
|
+
skip "Service is offline"
|
29
|
+
end
|
24
30
|
|
25
|
-
|
26
|
-
|
31
|
+
expect(results).to be_instance_of(Array), "Results are not an array for #{provider}"
|
32
|
+
expect(results).not_to be_empty, "Results are empty for #{provider}"
|
27
33
|
|
28
|
-
|
29
|
-
|
30
|
-
# FileUtils.cp_r(libVersion, TESTDIR)
|
31
|
-
# end
|
34
|
+
if search_type == Alexandria::BookProviders::SEARCH_BY_ISBN
|
35
|
+
expect(results.length).to be <= 2, "Results are greater than 2 for #{provider}"
|
32
36
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
book = results.first
|
38
|
+
|
39
|
+
expect(book).to be_instance_of(Alexandria::Book),
|
40
|
+
"Result is not a Book for #{provider}"
|
41
|
+
|
42
|
+
canonical_query = Alexandria::Library.canonicalise_ean(query)
|
43
|
+
canonical_result = Alexandria::Library.canonicalise_ean(book.isbn)
|
44
|
+
expect(canonical_query)
|
45
|
+
.to eq(canonical_result),
|
46
|
+
"Result's isbn #{book.isbn} is not equivalent" \
|
47
|
+
" to the requested isbn #{query} for #{provider}"
|
48
|
+
|
49
|
+
if results.length == 2
|
50
|
+
cover_url = results.last
|
51
|
+
if cover_url
|
52
|
+
expect(cover_url)
|
53
|
+
.to be_instance_of(String),
|
54
|
+
"Unexpected cover_url #{cover_url.inspect} for #{provider}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
else
|
58
|
+
expect(results.first.first)
|
59
|
+
.to be_instance_of(Alexandria::Book), "Result item is not a Book for #{provider}"
|
60
|
+
end
|
61
|
+
results
|
39
62
|
end
|
40
63
|
|
41
64
|
Alexandria::UI::Icons.init
|
42
65
|
|
43
|
-
|
44
|
-
|
45
|
-
|
66
|
+
test_store = Alexandria::LibraryStore.new(TESTDIR)
|
67
|
+
Alexandria::LibraryCollection.instance.library_store = test_store
|
68
|
+
|
69
|
+
RSpec.configure do |config|
|
70
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
71
|
+
|
72
|
+
config.before do
|
73
|
+
FileUtils.rm_rf(TESTDIR)
|
74
|
+
end
|
75
|
+
|
76
|
+
config.after do
|
77
|
+
FileUtils.rm_rf(TESTDIR)
|
46
78
|
end
|
47
79
|
end
|
data/tasks/setup.rb
CHANGED
@@ -24,9 +24,9 @@
|
|
24
24
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
25
25
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
26
|
#++
|
27
|
-
require
|
27
|
+
require "rake/clean"
|
28
28
|
|
29
29
|
# Load the other rake files in the tasks folder
|
30
30
|
tasks_dir = __dir__
|
31
|
-
rakefiles = Dir.glob(File.join(tasks_dir,
|
31
|
+
rakefiles = Dir.glob(File.join(tasks_dir, "*.rake")).sort
|
32
32
|
import(*rakefiles)
|
data/tasks/spec.rake
CHANGED
@@ -26,8 +26,21 @@
|
|
26
26
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
27
|
#++
|
28
28
|
|
29
|
-
require
|
29
|
+
require "rspec/core/rake_task"
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
namespace "spec" do
|
32
|
+
RSpec::Core::RakeTask.new("unit") do |t|
|
33
|
+
t.pattern = "spec/alexandria/**/*_spec.rb"
|
34
|
+
t.ruby_opts = ["-rbundler/setup -rsimplecov -Ilib -w"]
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec::Core::RakeTask.new("end_to_end") do |t|
|
38
|
+
t.pattern = "spec/end_to_end/**/*_spec.rb"
|
39
|
+
t.ruby_opts = ["-rbundler/setup -rsimplecov -Ilib -w"]
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Runs all unit and end-to-end specs"
|
43
|
+
task "all" => ["spec:unit", "spec:end_to_end"]
|
33
44
|
end
|
45
|
+
|
46
|
+
task spec: "spec:all"
|
data/util/rake/fileinstall.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# -*- ruby -*-
|
4
4
|
#--
|
5
5
|
# Copyright (C) 2009 Cathal Mc Ginley
|
6
|
-
# Copyright (C) 2011 Matijs van Zuijlen
|
6
|
+
# Copyright (C) 2011, 2020 Matijs van Zuijlen
|
7
7
|
#
|
8
8
|
# This file is part of the Alexandria build system.
|
9
9
|
#
|
@@ -27,10 +27,10 @@
|
|
27
27
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
28
|
#++
|
29
29
|
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
30
|
+
require "fileutils"
|
31
|
+
require "pathname"
|
32
|
+
require "set"
|
33
|
+
require "rake/tasklib"
|
34
34
|
|
35
35
|
# A file installer task, capable of installing into the system
|
36
36
|
# directories, or doing a staged install to a given directory
|
@@ -84,8 +84,8 @@ class FileInstallTask < Rake::TaskLib
|
|
84
84
|
|
85
85
|
# INSTALL TASK
|
86
86
|
|
87
|
-
description =
|
88
|
-
description +=
|
87
|
+
description = "Install package files"
|
88
|
+
description += " to staging directory" if @stage_dir
|
89
89
|
desc description
|
90
90
|
task tasknames[:install] do
|
91
91
|
@file_groups.each { |g| g.install(@stage_dir) }
|
@@ -105,7 +105,7 @@ class FileInstallTask < Rake::TaskLib
|
|
105
105
|
@dirs_to_remove_globs.each do |glob|
|
106
106
|
regex = glob2regex(glob)
|
107
107
|
all_dirs.each do |dir|
|
108
|
-
dir +=
|
108
|
+
dir += "/" unless dir.end_with?("/")
|
109
109
|
to_delete << Regexp.last_match[1] if regex =~ dir
|
110
110
|
end
|
111
111
|
end
|
@@ -116,8 +116,8 @@ class FileInstallTask < Rake::TaskLib
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
uninstall_description =
|
120
|
-
uninstall_description +=
|
119
|
+
uninstall_description = "Uninstall package files"
|
120
|
+
uninstall_description += " from staging directory" if @stage_dir
|
121
121
|
desc uninstall_description
|
122
122
|
task tasknames[:uninstall] => [tasknames[:uninstall_files],
|
123
123
|
tasknames[:uninstall_dirs]]
|
@@ -145,7 +145,7 @@ class FileInstallTask < Rake::TaskLib
|
|
145
145
|
|
146
146
|
# Install icon files. This method splits up the source file name and
|
147
147
|
# determines where they should be put in the destination hierarchy.
|
148
|
-
def install_icons(file_globs, dest_dir, theme =
|
148
|
+
def install_icons(file_globs, dest_dir, theme = "hicolor", icon_type = "apps")
|
149
149
|
file_globs.each do |fg|
|
150
150
|
files = FileList.new(fg)
|
151
151
|
files.each do |f|
|
@@ -154,7 +154,7 @@ class FileInstallTask < Rake::TaskLib
|
|
154
154
|
icon_size = Pathname.new(icon_dir).basename
|
155
155
|
icon_dest_dir = "#{dest_dir}/#{theme}/#{icon_size}/#{icon_type}"
|
156
156
|
group = FileGroup.new(icon_dir, f, icon_dest_dir)
|
157
|
-
group.description =
|
157
|
+
group.description = "icons"
|
158
158
|
@file_groups << group
|
159
159
|
end
|
160
160
|
end
|
@@ -169,16 +169,16 @@ class FileInstallTask < Rake::TaskLib
|
|
169
169
|
private
|
170
170
|
|
171
171
|
def calculate_ruby_dir
|
172
|
-
ruby_prefix = RbConfig::CONFIG[
|
172
|
+
ruby_prefix = RbConfig::CONFIG["prefix"]
|
173
173
|
|
174
174
|
ruby_libdir = if @install_to_rubylibdir
|
175
|
-
RbConfig::CONFIG[
|
175
|
+
RbConfig::CONFIG["rubylibdir"]
|
176
176
|
else
|
177
|
-
RbConfig::CONFIG[
|
177
|
+
RbConfig::CONFIG["sitelibdir"]
|
178
178
|
end
|
179
|
-
ruby_libdir = ENV[
|
179
|
+
ruby_libdir = ENV["RUBYLIBDIR"] if ENV.key?("RUBYLIBDIR")
|
180
180
|
|
181
|
-
@prefix = ENV[
|
181
|
+
@prefix = ENV["PREFIX"] || ruby_prefix
|
182
182
|
if @prefix == ruby_prefix
|
183
183
|
@rubylib = ruby_libdir
|
184
184
|
elsif ruby_libdir.index(ruby_prefix).zero?
|
@@ -190,12 +190,12 @@ class FileInstallTask < Rake::TaskLib
|
|
190
190
|
end
|
191
191
|
|
192
192
|
def glob2regex(pathglob)
|
193
|
-
pathglob +=
|
194
|
-
real_parts = pathglob.split(
|
193
|
+
pathglob += "/" if pathglob.end_with?("**")
|
194
|
+
real_parts = pathglob.split("**/")
|
195
195
|
real_parts.each do |part|
|
196
|
-
part.gsub!(
|
197
|
-
part.gsub!(
|
198
|
-
part.gsub!(
|
196
|
+
part.gsub!(".", '\\.')
|
197
|
+
part.gsub!("*", '[^\\/]*')
|
198
|
+
part.gsub!("?", '[^\\/]')
|
199
199
|
end
|
200
200
|
pattern = real_parts.join("([^\/]+\/)*")
|
201
201
|
/(#{pattern})/
|
@@ -210,15 +210,16 @@ class FileInstallTask < Rake::TaskLib
|
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
|
-
# Delete the directory at the given Pathname +
|
213
|
+
# Delete the directory at the given Pathname +path+ if all its children
|
214
214
|
# can be similarly deleted, and if it is then empty.
|
215
|
-
def delete_if_empty(
|
216
|
-
return false unless
|
217
|
-
|
215
|
+
def delete_if_empty(path)
|
216
|
+
return false unless path.directory?
|
217
|
+
|
218
|
+
path.children.each do |c|
|
218
219
|
delete_if_empty(c)
|
219
220
|
end
|
220
|
-
if
|
221
|
-
|
221
|
+
if path.children.empty?
|
222
|
+
path.delete # TODO: optional verbose output here
|
222
223
|
true
|
223
224
|
else
|
224
225
|
false
|
@@ -228,12 +229,13 @@ class FileInstallTask < Rake::TaskLib
|
|
228
229
|
class FileGroup
|
229
230
|
attr_reader :mode
|
230
231
|
attr_accessor :description
|
232
|
+
|
231
233
|
def initialize(src_dir, file_glob, dest_dir, mode = 0o644)
|
232
234
|
@src_dir = src_dir
|
233
235
|
@file_glob = file_glob
|
234
236
|
@dest_dir = dest_dir
|
235
237
|
@mode = mode
|
236
|
-
@description =
|
238
|
+
@description = "files"
|
237
239
|
end
|
238
240
|
|
239
241
|
def to_s
|
@@ -250,7 +252,9 @@ class FileInstallTask < Rake::TaskLib
|
|
250
252
|
else
|
251
253
|
dest_basedir = Pathname.new(@dest_dir)
|
252
254
|
end
|
253
|
-
|
255
|
+
if source_file.file?
|
256
|
+
source_path = source_file.dirname.relative_path_from(source_basedir)
|
257
|
+
end
|
254
258
|
dest = source_path ? dest_basedir + source_path : dest_basedir
|
255
259
|
dest.to_s
|
256
260
|
end
|
@@ -263,8 +267,8 @@ class FileInstallTask < Rake::TaskLib
|
|
263
267
|
puts "Installing #{@description} to #{base_dir}#{@dest_dir}"
|
264
268
|
files.each do |f|
|
265
269
|
dest = dest_dir(f, base_dir)
|
266
|
-
FileUtils.mkdir_p(dest) unless test(
|
267
|
-
FileUtils.install(f, dest, mode: mode) if test(
|
270
|
+
FileUtils.mkdir_p(dest) unless test("d", dest)
|
271
|
+
FileUtils.install(f, dest, mode: mode) if test("f", f)
|
268
272
|
end
|
269
273
|
end
|
270
274
|
|
@@ -273,7 +277,7 @@ class FileInstallTask < Rake::TaskLib
|
|
273
277
|
dest = dest_dir(f, base_dir)
|
274
278
|
filename = File.basename(f)
|
275
279
|
file = File.join(dest, filename)
|
276
|
-
if test(
|
280
|
+
if test("f", file)
|
277
281
|
FileUtils::Verbose.rm_f(file) # , :noop => true)
|
278
282
|
end
|
279
283
|
end
|
@@ -287,5 +291,5 @@ class FileInstallTask < Rake::TaskLib
|
|
287
291
|
all_dirs_set << File.dirname(file)
|
288
292
|
end
|
289
293
|
end
|
290
|
-
end
|
291
|
-
end
|
294
|
+
end
|
295
|
+
end
|
@@ -26,9 +26,9 @@
|
|
26
26
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
27
|
#++
|
28
28
|
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
29
|
+
require "fileutils"
|
30
|
+
require "pathname"
|
31
|
+
require "rake/tasklib"
|
32
32
|
|
33
33
|
class GettextGenerateTask < Rake::TaskLib
|
34
34
|
def initialize(projectname)
|
@@ -39,7 +39,7 @@ class GettextGenerateTask < Rake::TaskLib
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def make_task
|
42
|
-
desc
|
42
|
+
desc "Generate gettext localization files"
|
43
43
|
task gettext: @generated_files
|
44
44
|
|
45
45
|
@generated_files.each { |gen| CLOBBER << gen } if CLOBBER
|
@@ -49,7 +49,7 @@ class GettextGenerateTask < Rake::TaskLib
|
|
49
49
|
@po_dir = po_dir
|
50
50
|
@po_files_glob = file_glob
|
51
51
|
@mo_dir = dest_dir
|
52
|
-
@mo_files_regex =
|
52
|
+
@mo_files_regex = %r{.*/(.+)/LC_MESSAGES/.+\.mo}
|
53
53
|
|
54
54
|
# create MO files
|
55
55
|
rule(/\.mo$/ => [->(dest) { source_file(dest) }]) do |t|
|
@@ -72,14 +72,14 @@ class GettextGenerateTask < Rake::TaskLib
|
|
72
72
|
begin
|
73
73
|
`intltool-merge --version`
|
74
74
|
rescue Errno::ENOENT
|
75
|
-
raise
|
75
|
+
raise "Need to install intltool"
|
76
76
|
end
|
77
77
|
system("intltool-merge -d #{@po_dir} #{infile} #{outfile}")
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
def locales
|
82
|
-
po_files.map { |po| File.basename(po).split(
|
82
|
+
po_files.map { |po| File.basename(po).split(".")[0] }
|
83
83
|
end
|
84
84
|
|
85
85
|
def mo_files
|
data/util/rake/omfgenerate.rb
CHANGED
@@ -26,9 +26,9 @@
|
|
26
26
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
27
|
#++
|
28
28
|
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
29
|
+
require "fileutils"
|
30
|
+
require "pathname"
|
31
|
+
require "rake/tasklib"
|
32
32
|
|
33
33
|
class OmfGenerateTask < Rake::TaskLib
|
34
34
|
def initialize(projectname)
|
@@ -39,7 +39,7 @@ class OmfGenerateTask < Rake::TaskLib
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def make_task
|
42
|
-
desc
|
42
|
+
desc "Generate Open Metadata Framework files"
|
43
43
|
task omf: @generated_files
|
44
44
|
|
45
45
|
@generated_files.each { |gen| CLOBBER << gen } if CLOBBER
|
@@ -55,7 +55,7 @@ class OmfGenerateTask < Rake::TaskLib
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def omf_files
|
58
|
-
in_files.map { |f| f.sub(/.omf.in/,
|
58
|
+
in_files.map { |f| f.sub(/.omf.in/, ".omf") }
|
59
59
|
end
|
60
60
|
|
61
61
|
attr_writer :gnome_helpfiles_dir
|
@@ -64,13 +64,13 @@ class OmfGenerateTask < Rake::TaskLib
|
|
64
64
|
@source_dir = src_dir
|
65
65
|
@source_files_glob = file_glob
|
66
66
|
|
67
|
-
rule
|
67
|
+
rule ".omf" => [".omf.in"] do |t|
|
68
68
|
path = File.join(@gnome_helpfiles_dir, @projectname,
|
69
69
|
locale_for(t.name), "#{@projectname}.xml")
|
70
70
|
data = IO.read(t.source)
|
71
71
|
data.sub!(/PATH_TO_DOC_FILE/, path)
|
72
72
|
puts "Generating #{t.name}..."
|
73
|
-
File.open(t.name,
|
73
|
+
File.open(t.name, "w") { |io| io.puts data }
|
74
74
|
end
|
75
75
|
omf_files.each { |o| @generated_files << o }
|
76
76
|
end
|