Piggy 0.4.2.4 → 0.4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +15 -0
- data/INSTALL.txt +9 -4
- data/README.txt +8 -6
- data/bin/directory_diff +1 -1
- data/bin/ftp_browser +1 -1
- data/bin/piggy +1 -1
- data/lib/directory_diff.rb +8 -6
- data/lib/ftp_browser.rb +8 -6
- data/lib/icons/connect.ico +0 -0
- data/lib/icons/hide_details.ico +0 -0
- data/lib/icons/show_details.ico +0 -0
- data/lib/piggy-core/alive_check.rb +4 -4
- data/lib/piggy-core/debug.rb +4 -4
- data/lib/piggy-core/environment.rb +24 -26
- data/lib/piggy-core/exifr_adapter.rb +11 -11
- data/lib/piggy-core/file_info.rb +61 -61
- data/lib/piggy-core/ftp_adapter.rb +24 -24
- data/lib/piggy-core/htmlgen.rb +41 -45
- data/lib/piggy-core/nconvert_thumbsgen.rb +22 -22
- data/lib/piggy-core/options.rb +25 -19
- data/lib/piggy-core/options_persistence.rb +8 -8
- data/lib/piggy-core/progress.rb +7 -7
- data/lib/piggy-core/rmagick_thumbnail_page_generator.rb +14 -14
- data/lib/piggy-core/thumbnail_generator.rb +26 -26
- data/lib/piggy-core/thumbnail_page_generator.rb +234 -230
- data/lib/piggy-core/upload_info.rb +22 -22
- data/lib/piggy-core/version.rb +7 -7
- data/lib/piggy-core/winshell.rb +136 -80
- data/lib/piggy-gui/dir_chooser.rb +14 -14
- data/lib/piggy-gui/directory_diff_widget.rb +177 -160
- data/lib/piggy-gui/filtered_file_list.rb +87 -87
- data/lib/piggy-gui/fox_thumbsgen.rb +4 -4
- data/lib/piggy-gui/ftp_browser_widget.rb +211 -155
- data/lib/piggy-gui/fullscreen.rb +4 -4
- data/lib/piggy-gui/html_generation_dialog.rb +42 -115
- data/lib/piggy-gui/html_options_widget.rb +97 -0
- data/lib/piggy-gui/image_processor.rb +58 -58
- data/lib/piggy-gui/modal_dialog.rb +11 -5
- data/lib/piggy-gui/multiimagecanvas.rb +59 -59
- data/lib/piggy-gui/options_dialog.rb +170 -48
- data/lib/piggy-gui/piggy_image_browser.rb +382 -340
- data/lib/piggy-gui/pipe_log.rb +17 -17
- data/lib/piggy-gui/progress_with_dialog.rb +8 -8
- data/lib/piggy-gui/require-fox.rb +23 -8
- data/lib/piggy.rb +7 -5
- data/lib/templates/styles/basic/style.css +16 -14
- data/lib/templates/styles/black/style.css +28 -29
- data/lib/templates/styles/roundedbox/style.css +28 -31
- data/lib/templates/styles/shadow/style.css +26 -26
- data/lib/templates/styles/shadow_D9F5F3/style.css +1 -1
- data/lib/templates/styles/shadow_black/lo.jpg +0 -0
- data/lib/templates/styles/shadow_black/lu.jpg +0 -0
- data/lib/templates/styles/shadow_black/ro.jpg +0 -0
- data/lib/templates/styles/shadow_black/ru.jpg +0 -0
- data/lib/templates/styles/shadow_black/style.css +78 -0
- data/lib/templates/styles/shadow_bowers/style.css +48 -51
- data/lib/templates/styles/sylvester/sh.png +0 -0
- data/lib/templates/styles/sylvester/style.css +74 -0
- data/lib/templates/styles/sylvester/wunderkerze.jpg +0 -0
- data/test/file_info_test.rb +29 -29
- metadata +52 -38
data/CHANGES.txt
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
Changes in 0.4.3-0
|
2
|
+
- Bugfix (Vista): LOCAL_APPDATA path
|
3
|
+
solved with win32-dir
|
4
|
+
- Bugfix (Vista): Shortcuts like "Sample pictures"
|
5
|
+
- Bugfix: Some Unicode issues
|
6
|
+
- More options visible to user
|
7
|
+
- Refactorings: Ruby naming conventions
|
8
|
+
(and other Netbeans warnings)
|
9
|
+
- New style "sylvester"
|
10
|
+
- Style samples (on Piggy website)
|
11
|
+
- Link to style samples in help menu
|
12
|
+
- FTP-Browser layout:
|
13
|
+
hide connection dynamically
|
14
|
+
=> no foursplitter necessary
|
15
|
+
|
1
16
|
Changes in 0.4.2-4
|
2
17
|
- Bugfix for opening browsers
|
3
18
|
- Bugfix utf8 conversion of comments
|
data/INSTALL.txt
CHANGED
@@ -9,9 +9,9 @@ Intallation includes the following applications
|
|
9
9
|
- directory_diff
|
10
10
|
- ftp_browser
|
11
11
|
|
12
|
-
|
13
|
-
Windows NT
|
14
|
-
|
12
|
+
---------------------------
|
13
|
+
Windows NT, 2000, XP, Vista
|
14
|
+
---------------------------
|
15
15
|
|
16
16
|
You might be using the Ruby Windows Installer, so you
|
17
17
|
probably have FXRuby and most of the other required libraries
|
@@ -26,7 +26,8 @@ Rubygems will check if the required gems rubyzip and exifr are installed on your
|
|
26
26
|
system.
|
27
27
|
|
28
28
|
(Note that for now the gem command won't check if FXRuby is installed
|
29
|
-
on your system, so you'll be able to install FXRuby via gem or from source.
|
29
|
+
on your system, so you'll be able to install FXRuby via gem or from source.
|
30
|
+
FXRuby version 1.6 is recommended.)
|
30
31
|
|
31
32
|
Gem installation might fail if you don't have the rights
|
32
33
|
to write the gem directories. You'll need to become admin
|
@@ -130,3 +131,7 @@ In most cases, setting the HTTP_PROXY environment variable will help:
|
|
130
131
|
|
131
132
|
For more information on this topic see
|
132
133
|
http://wiki.rubyonrails.org/rails/pages/GemRails
|
134
|
+
|
135
|
+
If you still got problems: Download all required gems and install each with
|
136
|
+
gem install <downloaded_file>
|
137
|
+
|
data/README.txt
CHANGED
@@ -9,17 +9,19 @@ I've created this application for:
|
|
9
9
|
|
10
10
|
|
11
11
|
Basically it is a simple image viewer which allows you to
|
12
|
-
rotate and
|
13
|
-
|
14
|
-
via ftp.
|
12
|
+
- rotate and comment images (without changing the original files),
|
13
|
+
- select some images and create an internet gallery with thumbnail preview,
|
14
|
+
- upload this gallery via ftp.
|
15
|
+
|
16
|
+
Piggy uses exif metainfo to guess initial rotations and comments.
|
15
17
|
|
16
18
|
-----------
|
17
19
|
Limitations
|
18
20
|
-----------
|
19
21
|
|
20
|
-
Piggy is currently developed under Windows
|
22
|
+
Piggy is currently developed under Windows Vista.
|
21
23
|
Additional tests include Windows XP and Linux.
|
22
|
-
It is not tested on
|
24
|
+
It is not tested on Mac.
|
23
25
|
|
24
26
|
Piggy is not meant as general purpose tool for image manipulations:
|
25
27
|
- Image rotation reduces the quality of the image
|
@@ -30,4 +32,4 @@ Zipfile will include original images including all metadata.
|
|
30
32
|
Uncheck this option if this metadata includes personal information
|
31
33
|
that you do not want to publish.
|
32
34
|
(See http://netzreport.googlepages.com/hidden_data_in_jpeg_files.html
|
33
|
-
for more information on this topic.)
|
35
|
+
for more information on this topic.)
|
data/bin/directory_diff
CHANGED
data/bin/ftp_browser
CHANGED
data/bin/piggy
CHANGED
data/lib/directory_diff.rb
CHANGED
@@ -7,18 +7,18 @@
|
|
7
7
|
require 'piggy-core/options_persistence'
|
8
8
|
require 'piggy-gui/directory_diff_widget'
|
9
9
|
|
10
|
-
def
|
10
|
+
def run_directory_diff
|
11
11
|
# Make application
|
12
|
-
application = Fox::FXApp.new("Piggy Directory Diff", "Sascha D�rdelmann")
|
12
|
+
application = Fox::FXApp.new("Piggy Directory Diff", "Sascha D�rdelmann")
|
13
13
|
|
14
|
-
|
15
|
-
options =
|
14
|
+
option_store = PiggyOptionsPersistence.new
|
15
|
+
options = option_store.load_yaml
|
16
16
|
|
17
17
|
# Make window
|
18
18
|
window = DirectoryDiffMainWindow.new(application, options)
|
19
19
|
|
20
20
|
# Handle interrupts to terminate program gracefully
|
21
|
-
application.addSignal("SIGINT", window.method(:
|
21
|
+
application.addSignal("SIGINT", window.method(:on_terminate))
|
22
22
|
|
23
23
|
# Create it
|
24
24
|
application.create
|
@@ -28,8 +28,10 @@ def runDirectoryDiff
|
|
28
28
|
application.run
|
29
29
|
end
|
30
30
|
|
31
|
+
alias :runDirectoryDiff :run_directory_diff
|
32
|
+
|
31
33
|
if $0 == __FILE__
|
32
|
-
|
34
|
+
run_directory_diff
|
33
35
|
end
|
34
36
|
|
35
37
|
|
data/lib/ftp_browser.rb
CHANGED
@@ -7,18 +7,18 @@
|
|
7
7
|
require 'piggy-core/options_persistence'
|
8
8
|
require 'piggy-gui/ftp_browser_widget'
|
9
9
|
|
10
|
-
def
|
10
|
+
def run_uploader
|
11
11
|
# Make application
|
12
|
-
application = Fox::FXApp.new("Piggy FTP Browser", "Sascha D�rdelmann")
|
12
|
+
application = Fox::FXApp.new("Piggy FTP Browser", "Sascha D�rdelmann")
|
13
13
|
|
14
|
-
|
15
|
-
options =
|
14
|
+
option_store = PiggyOptionsPersistence.new
|
15
|
+
options = option_store.load_yaml
|
16
16
|
|
17
17
|
# Make window
|
18
18
|
window = FtpBrowserMainWindow.new(application, options)
|
19
19
|
|
20
20
|
# Handle interrupts to terminate program gracefully
|
21
|
-
application.addSignal("SIGINT", window.method(:
|
21
|
+
application.addSignal("SIGINT", window.method(:on_terminate))
|
22
22
|
|
23
23
|
# Create it
|
24
24
|
application.create
|
@@ -28,6 +28,8 @@ def runUploader
|
|
28
28
|
application.run
|
29
29
|
end
|
30
30
|
|
31
|
+
alias :runUploader :run_uploader
|
32
|
+
|
31
33
|
if $0 == __FILE__
|
32
|
-
|
34
|
+
run_uploader
|
33
35
|
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -24,17 +24,17 @@ class AliveCheck
|
|
24
24
|
def check
|
25
25
|
checked_thread = Thread.current
|
26
26
|
@alive = true
|
27
|
-
|
27
|
+
alive_checker = Thread.new {
|
28
28
|
while(@alive) do
|
29
|
-
|
30
|
-
|
29
|
+
@alive = false
|
30
|
+
sleep(@sec)
|
31
31
|
end
|
32
32
|
checked_thread.raise(Timeout::Error, @ex_msg) if checked_thread.alive?
|
33
33
|
}
|
34
34
|
begin
|
35
35
|
yield
|
36
36
|
ensure
|
37
|
-
|
37
|
+
alive_checker.kill if alive_checker and alive_checker.alive?
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
data/lib/piggy-core/debug.rb
CHANGED
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
# Global methods temporaryly used for debugging.
|
4
4
|
# Inspired by the book
|
5
|
-
# "Programmieren mit Ruby" by R�hrl/Schmiedl/Weyss"
|
5
|
+
# "Programmieren mit Ruby" by R�hrl/Schmiedl/Weyss"
|
6
6
|
|
7
|
-
def
|
7
|
+
def begin_trace
|
8
8
|
$stderr.puts "Begin Trace in: #{caller.first}"
|
9
9
|
set_trace_func proc {
|
10
10
|
|event, file, line, id, binding, classname|
|
11
11
|
unless File.basename(file) == 'debug.rb'
|
12
12
|
$stderr.printf("%8s %s-, %-2d %10s %8s\n",
|
13
|
-
|
13
|
+
event, file, line, id, classname)
|
14
14
|
end
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def end_trace
|
19
19
|
$stderr.set_trace_func(nil)
|
20
20
|
puts "End Trace in: #{caller.first}"
|
21
21
|
end
|
@@ -19,42 +19,29 @@
|
|
19
19
|
# paths relative to PIGGY_PATH.
|
20
20
|
|
21
21
|
begin
|
22
|
-
require 'rubygems'
|
23
|
-
require 'piggy-core/version.rb'
|
24
|
-
|
25
22
|
# Try to find lib directory of this specific Piggy gem version
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
return d.gsub(/\\/, '/')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
puts "Checking Gems"
|
35
|
-
piggyGemDir = "Piggy-#{PiggyVersion.versionString.gsub(/-/, '.')}"
|
36
|
-
all = Gem::path.collect { |gempath|
|
37
|
-
File.join(gempath, 'gems', piggyGemDir)
|
38
|
-
}.select { |f|
|
39
|
-
File.directory?(f)
|
40
|
-
}
|
41
|
-
return all.empty? ? '.' : File.join(all.first, 'lib')
|
23
|
+
def find_piggy_directory
|
24
|
+
require 'rubygems'
|
25
|
+
require 'piggy-core/winshell'
|
26
|
+
require 'piggy-core/file_info'
|
27
|
+
return FilePath.one_dir_up(File.dirname(WinShell.instance.ruby_path(__FILE__)))
|
42
28
|
end
|
43
|
-
PIGGY_PATH =
|
44
|
-
puts "Successfully
|
29
|
+
PIGGY_PATH = find_piggy_directory
|
30
|
+
puts "Successfully detected piggy gem lib in #{PIGGY_PATH}"
|
45
31
|
rescue LoadError
|
46
|
-
PIGGY_PATH =
|
32
|
+
PIGGY_PATH = "#{__FILE__}/.."
|
33
|
+
puts "Workaround for LoadError; assuming piggy gem lib is #{PIGGY_PATH}"
|
47
34
|
end
|
48
35
|
|
49
36
|
# Temporary change working dir while executing a given block
|
50
|
-
# (
|
51
|
-
def
|
52
|
-
|
37
|
+
# (deprecated)
|
38
|
+
def in_path(path, &block)
|
39
|
+
working_dir_sik = Dir.getwd
|
53
40
|
begin
|
54
41
|
Dir.chdir(path)
|
55
42
|
block.call
|
56
43
|
ensure
|
57
|
-
Dir.chdir(
|
44
|
+
Dir.chdir(working_dir_sik)
|
58
45
|
end
|
59
46
|
end
|
60
47
|
|
@@ -64,3 +51,14 @@ begin
|
|
64
51
|
rescue LoadError
|
65
52
|
RMAGICK_AVAILIABLE = false
|
66
53
|
end
|
54
|
+
|
55
|
+
def get_style_list
|
56
|
+
style_dir = File.join(PIGGY_PATH, 'templates/styles')
|
57
|
+
Dir[File.join(style_dir, '*')].entries.reject {
|
58
|
+
|f|
|
59
|
+
f =~ /^\.+$/
|
60
|
+
}.collect {
|
61
|
+
|folder|
|
62
|
+
File.basename(folder)
|
63
|
+
}
|
64
|
+
end
|
@@ -7,7 +7,7 @@ require 'exifr'
|
|
7
7
|
# layer between Piggy and EXIFR.
|
8
8
|
class ExifrAdapter
|
9
9
|
def initialize(file)
|
10
|
-
@exif =
|
10
|
+
@exif = load_exif(file)
|
11
11
|
end
|
12
12
|
|
13
13
|
def exif?
|
@@ -31,7 +31,7 @@ class ExifrAdapter
|
|
31
31
|
elsif @exif.comment.class == Array
|
32
32
|
desc += "\tcomments: "
|
33
33
|
@exif.comment.each { |c|
|
34
|
-
|
34
|
+
desc += "\t\t#{c}\n"
|
35
35
|
}
|
36
36
|
end
|
37
37
|
return desc unless @exif.exif?
|
@@ -41,13 +41,13 @@ class ExifrAdapter
|
|
41
41
|
return desc
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
44
|
+
def view_degrees
|
45
45
|
return 0 unless exif?
|
46
46
|
orientation = @exif.exif[:orientation]
|
47
47
|
return 0 if orientation.nil?
|
48
|
-
|
49
|
-
orientation.transform_rmagick(
|
50
|
-
return
|
48
|
+
image_mock = ExifrDegreeComuter.new
|
49
|
+
orientation.transform_rmagick(image_mock)
|
50
|
+
return image_mock.degree
|
51
51
|
end
|
52
52
|
|
53
53
|
def width
|
@@ -60,19 +60,19 @@ class ExifrAdapter
|
|
60
60
|
|
61
61
|
private
|
62
62
|
|
63
|
-
def
|
64
|
-
if(
|
63
|
+
def load_exif(file)
|
64
|
+
if(has_extension?(file, 'jpg'))
|
65
65
|
EXIFR::JPEG.new(file)
|
66
|
-
elsif(
|
66
|
+
elsif(has_extension?(file, 'tif'))
|
67
67
|
EXIFR::TIFF.new(file)
|
68
68
|
else
|
69
69
|
nil
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
def
|
73
|
+
def has_extension?(filename, ext)
|
74
74
|
File.basename(filename.upcase, ext.upcase) !=
|
75
|
-
|
75
|
+
File.basename(filename.upcase)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
data/lib/piggy-core/file_info.rb
CHANGED
@@ -9,10 +9,10 @@ module FilePath
|
|
9
9
|
|
10
10
|
# Ruby path notation for a given operation system/file system
|
11
11
|
# specific path
|
12
|
-
def FilePath.
|
13
|
-
return '' unless
|
14
|
-
|
15
|
-
return
|
12
|
+
def FilePath.intern_path(path_string)
|
13
|
+
return '' unless path_string
|
14
|
+
new_path = path_string.gsub(/\\/, File::SEPARATOR)
|
15
|
+
return new_path =~ /:$/ ? new_path + File::SEPARATOR : new_path
|
16
16
|
end
|
17
17
|
|
18
18
|
# Just as File.join but handles at least one possible error.
|
@@ -23,30 +23,30 @@ module FilePath
|
|
23
23
|
def FilePath.join(string1, string2)
|
24
24
|
return string2 unless string1 && !string1.empty?
|
25
25
|
return string1 unless string2 && !string2.empty?
|
26
|
-
|
27
|
-
return File.join(string1,
|
26
|
+
no_leading_seps2 = string2.sub(Regexp.compile("#{File::SEPARATOR}*"), '')
|
27
|
+
return File.join(string1, no_leading_seps2)
|
28
28
|
end
|
29
29
|
|
30
30
|
# Sections of a given pathString
|
31
|
-
def FilePath.split(
|
32
|
-
|
31
|
+
def FilePath.split(path_string)
|
32
|
+
path_string.split(File::SEPARATOR)
|
33
33
|
end
|
34
34
|
|
35
35
|
# Removes the last section of a given pathString.
|
36
36
|
# Won't remove a section of a file system root.
|
37
37
|
# Possible roots are '/', 'C:', 'X:/', ...
|
38
|
-
def FilePath.
|
39
|
-
return '' unless
|
40
|
-
sections = FilePath.split(
|
38
|
+
def FilePath.one_dir_up(path_string)
|
39
|
+
return '' unless path_string
|
40
|
+
sections = FilePath.split(path_string)
|
41
41
|
return '' unless sections || !sections.empty?
|
42
42
|
if sections.size == 1
|
43
|
-
return
|
44
|
-
return
|
43
|
+
return path_string if path_string =~ /:/
|
44
|
+
return path_string if path_string == '/'
|
45
45
|
return ''
|
46
46
|
end
|
47
47
|
return '' unless sections[-1]
|
48
|
-
|
49
|
-
return FilePath.
|
48
|
+
num_of_chars_to_strip = sections[-1].size + 2
|
49
|
+
return FilePath.intern_path(path_string[0..-num_of_chars_to_strip])
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -57,24 +57,24 @@ class FileName
|
|
57
57
|
attr_accessor(:name)
|
58
58
|
attr_reader(:path)
|
59
59
|
|
60
|
-
def initialize(
|
61
|
-
@name =
|
62
|
-
|
60
|
+
def initialize(the_name, the_path = '')
|
61
|
+
@name = the_name
|
62
|
+
set_path(the_path)
|
63
63
|
end
|
64
64
|
|
65
|
-
def path=(
|
66
|
-
|
65
|
+
def path=(new_path)
|
66
|
+
set_path(new_path)
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
70
|
-
@path = FilePath.
|
69
|
+
def set_path(new_path)
|
70
|
+
@path = FilePath.intern_path(new_path)
|
71
71
|
end
|
72
72
|
|
73
|
-
def
|
73
|
+
def name_with_path
|
74
74
|
return FilePath.join(path, name)
|
75
75
|
end
|
76
76
|
|
77
|
-
def
|
77
|
+
def name_without_extension
|
78
78
|
return File.basename(name, '.' + extension)
|
79
79
|
end
|
80
80
|
|
@@ -82,7 +82,7 @@ class FileName
|
|
82
82
|
return name.split('.')[-1]
|
83
83
|
end
|
84
84
|
|
85
|
-
def
|
85
|
+
def path_sections
|
86
86
|
return FilePath.split(path)
|
87
87
|
end
|
88
88
|
end
|
@@ -95,31 +95,31 @@ end
|
|
95
95
|
class FileInfo < FileName
|
96
96
|
attr_accessor(:size, :mtime, :ctime)
|
97
97
|
|
98
|
-
def initialize(
|
99
|
-
super(
|
98
|
+
def initialize(the_name, the_path = '')
|
99
|
+
super(the_name, the_path)
|
100
100
|
@size = 0
|
101
|
-
@
|
101
|
+
@is_directory = false
|
102
102
|
end
|
103
103
|
|
104
104
|
def directory?
|
105
|
-
return @
|
105
|
+
return @is_directory
|
106
106
|
end
|
107
107
|
|
108
108
|
def directory!
|
109
|
-
@
|
109
|
+
@is_directory = true
|
110
110
|
end
|
111
111
|
|
112
|
-
def
|
113
|
-
|
112
|
+
def mtime_string
|
113
|
+
time_string_for(mtime)
|
114
114
|
end
|
115
115
|
|
116
|
-
def
|
117
|
-
|
116
|
+
def ctime_string
|
117
|
+
time_string_for(ctime)
|
118
118
|
end
|
119
119
|
|
120
120
|
protected
|
121
121
|
|
122
|
-
def
|
122
|
+
def time_string_for(time)
|
123
123
|
return 'unknown' unless time
|
124
124
|
time.strftime("%m/%d/%Y at %I:%M%p")
|
125
125
|
end
|
@@ -128,9 +128,9 @@ end
|
|
128
128
|
class CommentedFile < FileInfo
|
129
129
|
attr_accessor(:comment, :rotation, :width, :height)
|
130
130
|
|
131
|
-
def initialize(
|
132
|
-
super(
|
133
|
-
@comment =
|
131
|
+
def initialize(the_name, the_path = '', the_comment = '')
|
132
|
+
super(the_name, the_path)
|
133
|
+
@comment = the_comment
|
134
134
|
@rotation = 0
|
135
135
|
@width = 0
|
136
136
|
@height = 0
|
@@ -146,29 +146,29 @@ end
|
|
146
146
|
class DirectoryContents
|
147
147
|
attr_accessor(:path)
|
148
148
|
|
149
|
-
def initialize(
|
150
|
-
@path =
|
149
|
+
def initialize(the_path = '')
|
150
|
+
@path = the_path
|
151
151
|
@contents = Hash.new
|
152
152
|
end
|
153
153
|
|
154
|
-
def add(
|
155
|
-
@contents[
|
154
|
+
def add(file_name)
|
155
|
+
@contents[file_name.name] = file_name
|
156
156
|
end
|
157
157
|
|
158
|
-
def []=(
|
159
|
-
@contents[
|
158
|
+
def []=(name, info)
|
159
|
+
@contents[name] = info
|
160
160
|
end
|
161
161
|
|
162
|
-
def get(
|
163
|
-
return @contents[
|
162
|
+
def get(file_name)
|
163
|
+
return @contents[file_name.name]
|
164
164
|
end
|
165
165
|
|
166
|
-
def at(
|
167
|
-
return @contents[
|
166
|
+
def at(name)
|
167
|
+
return @contents[name]
|
168
168
|
end
|
169
169
|
|
170
|
-
def [](
|
171
|
-
return @contents[
|
170
|
+
def [](name)
|
171
|
+
return @contents[name]
|
172
172
|
end
|
173
173
|
|
174
174
|
alias has_key? []
|
@@ -195,22 +195,22 @@ class FileRepository
|
|
195
195
|
@repository = Hash.new
|
196
196
|
end
|
197
197
|
|
198
|
-
def add(
|
199
|
-
self[
|
198
|
+
def add(file_name)
|
199
|
+
self[file_name] = file_name
|
200
200
|
end
|
201
201
|
|
202
|
-
def []=(
|
203
|
-
|
204
|
-
if
|
205
|
-
|
206
|
-
@repository[
|
202
|
+
def []=(file_name, info)
|
203
|
+
hash_or_nil = @repository[file_name.path]
|
204
|
+
if hash_or_nil == nil
|
205
|
+
hash_or_nil = Hash.new
|
206
|
+
@repository[file_name.path] = hash_or_nil
|
207
207
|
end
|
208
|
-
|
208
|
+
hash_or_nil[file_name.name] = info
|
209
209
|
end
|
210
210
|
|
211
|
-
def get(
|
212
|
-
|
213
|
-
return
|
211
|
+
def get(file_name)
|
212
|
+
sub_hash = @repository[file_name.path]
|
213
|
+
return sub_hash == nil ? nil : sub_hash[file_name.name]
|
214
214
|
end
|
215
215
|
alias [] get
|
216
216
|
alias has_key? get
|