Class: Roebe::FotoSearcher
- Inherits:
-
Base
show all
- Defined in:
- lib/roebe/classes/foto_searcher.rb
Overview
Constant Summary
collapse
- BASE_DIRECTORY =
#
BASE_DIRECTORY
You may have to adjust this constant to where you keep your local images/pictures. This class currently assumes that all fotos / pictures reside in the same directory.
#
'/home/x/data/images/fotos/'
- ARRAY_ALL_CATS =
#
ARRAY_ALL_CATS
This array keeps the name of all (local) images from “cats”.
#
%w(
aisha
fennek
fleckerl
gemischt
jarosch_katze
kappa
mädi
minzi
muck
pizzi
puma
schatzi
silbernes
zwetschki
)
- ARRAY_ALL_DOGS =
%w(
krümel
sheeva
timba
gemischt
)
Constants inherited
from Base
Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE
Instance Method Summary
collapse
Methods inherited from Base
#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #copy_file, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #opnn, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow
#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments
Constructor Details
#initialize(i = ARGV, run_already = true) ⇒ FotoSearcher
70
71
72
73
74
75
76
77
|
# File 'lib/roebe/classes/foto_searcher.rb', line 70
def initialize(
i = ARGV,
run_already = true
)
reset
set_commandline_arguments(i)
run if run_already
end
|
Instance Method Details
#all_cats? ⇒ Boolean
118
119
120
|
# File 'lib/roebe/classes/foto_searcher.rb', line 118
def all_cats?
ARRAY_ALL_CATS
end
|
#all_dogs? ⇒ Boolean
125
126
127
|
# File 'lib/roebe/classes/foto_searcher.rb', line 125
def all_dogs?
ARRAY_ALL_DOGS
end
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/roebe/classes/foto_searcher.rb', line 132
def (
i = hyphened_arguments?
)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i
when /-?-?help/i
show_help
exit
end
end
end
|
#report(i) ⇒ Object
Also known as:
try_to_report
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# File 'lib/roebe/classes/foto_searcher.rb', line 170
def report(i)
if i.empty?
opne tomato('No match was found for `')+
lightblue(first_argument?.to_s)+
tomato('`.')
else
i.each {|entry|
e sfile(entry)
}
if try_to_create_a_local_HTML_page?
require 'html_tags'
opne 'Next creating a local HTML page for these '+
steelblue(i.size.to_s)+
rev+' images.'
cd('/tmp') if File.directory?('/tmp')
cd('/home/x/Temp') if File.directory?('/home/x/Temp')
images_to_html = Cyberweb::ImagesToHtml.new([], :do_not_run_yet) { :use_jquery }
images_to_html.work_on_these_files = i
images_to_html.(
'--use-HTML-table --table=2 --display_top_header'.split(' ')
)
images_to_html.show_names
stored_into_this_file = images_to_html.the_two_last_actions
if File.exist? stored_into_this_file
open_in_browser(stored_into_this_file) { :no_localhost }
end
end
end
end
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/roebe/classes/foto_searcher.rb', line 82
def reset
super()
infer_the_namespace
@try_to_create_a_local_HTML_page = true
@sort_how = :by_time_based_on_the_filename
end
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
# File 'lib/roebe/classes/foto_searcher.rb', line 206
def run
possible_matches = nil all_fotos = Dir["#{BASE_DIRECTORY}**/**"].select {|entry|
is_an_image?(entry) }
_ = first_argument?.to_s.downcase array_to_use_for_the_possible_matches = all_arguments?.map {|entry|
if entry.start_with? ':'
symbol = entry.delete(':').to_sym
case symbol
when :alle_katzen,
:all_cats
all_cats = all_cats?
possible_matches = all_cats.map {|entry|
entry = entry.dup if entry.frozen?
entry.prepend("#{BASE_DIRECTORY}cats_and_dogs/")
entry << '/' unless entry.end_with? '/'
Dir[entry+'*']
}.flatten.select {|this_file| is_an_image_file?(this_file) }
all_cats.reject! {|file_path| file_path.include?('gemischt') }
possible_matches.select! {|file_path|
downcased_file_path = file_path.downcase
all_cats.any? {|short_name_of_the_cat|
downcased_file_path.include?(short_name_of_the_cat)
}
}
when :alle_tiere,
:all_animals
_ = all_dogs?
_ << all_cats?
_.flatten!
possible_matches = _.map {|entry|
entry = entry.dup if entry.frozen?
entry.prepend(BASE_DIRECTORY+'cats_and_dogs/')
entry << '/' unless entry.end_with? '/'
Dir[entry+'*']
}.flatten.select {|this_file| is_an_image_file?(this_file) }
possible_matches.select! {|file_path|
downcased_file_path = file_path.downcase
_.any? {|short_name|
downcased_file_path.include?(short_name)
}
}
when :alle_hunde,
:all_dogs
all_dogs = all_dogs?
possible_matches = all_dogs.map {|entry|
entry = entry.dup if entry.frozen?
entry.prepend(BASE_DIRECTORY+'cats_and_dogs/')
entry << '/' unless entry.end_with? '/'
Dir[entry+'*']
}.flatten.select {|this_file| is_an_image_file?(this_file) }
all_dogs.reject! {|file_path| file_path.include?('gemischt') }
possible_matches.select! {|file_path|
downcased_file_path = file_path.downcase
all_dogs.any? {|short_name_of_the_dog|
downcased_file_path.include?(short_name_of_the_dog)
}
}
end
end
if possible_matches
possible_matches
else
entry.to_s.downcase
end
}
possible_matches = all_fotos.select {|entry|
downcased_entry = entry.downcase
true_or_false = false array_to_use_for_the_possible_matches.each {|inner_entry|
inner_entry = inner_entry.tr(' ','_') if downcased_entry.include?(inner_entry)
true_or_false = true
end
}
true_or_false
} unless possible_matches
possible_matches.uniq! if sort_by_time_based_on_the_filename?
possible_matches = Roebe.date_sort_based_on_filename(possible_matches).reverse
end
try_to_report(possible_matches)
end
|
#show_help ⇒ Object
159
160
161
162
163
164
165
|
# File 'lib/roebe/classes/foto_searcher.rb', line 159
def show_help
e
e ' foto_gatherer :alle_katzen # show all local cats'
e ' foto_gatherer :alle_hunde # show all local dogs'
e ' foto_gatherer :alle_tiere # show all local cats and dogs'
e
end
|
#sort_by_time_based_on_the_filename? ⇒ Boolean
#
sort_by_time_based_on_the_filename?
#
111
112
113
|
# File 'lib/roebe/classes/foto_searcher.rb', line 111
def sort_by_time_based_on_the_filename?
sort_how? == :by_time_based_on_the_filename
end
|
#sort_how? ⇒ Boolean
104
105
106
|
# File 'lib/roebe/classes/foto_searcher.rb', line 104
def sort_how?
@sort_how
end
|
#try_to_create_a_local_HTML_page? ⇒ Boolean
#
try_to_create_a_local_HTML_page?
#
152
153
154
|
# File 'lib/roebe/classes/foto_searcher.rb', line 152
def try_to_create_a_local_HTML_page?
@try_to_create_a_local_HTML_page
end
|