Class: SiSU_Images::Source::Place
- Inherits:
-
Object
- Object
- SiSU_Images::Source::Place
- Defined in:
- lib/sisu/shared_images.rb
Instance Method Summary collapse
- #copy(src_path, dest_path, images = nil) ⇒ Object
- #dest_path(image_type) ⇒ Object
- #images_set ⇒ Object
-
#initialize(particulars) ⇒ Place
constructor
A new instance of Place.
- #select_sisu_base ⇒ Object
- #select_with_document ⇒ Object
- #songsheet ⇒ Object
Constructor Details
#initialize(particulars) ⇒ Place
Returns a new instance of Place.
67 68 69 70 71 72 |
# File 'lib/sisu/shared_images.rb', line 67 def initialize(particulars) @particulars=particulars @md=@particulars.md @env=@particulars.env @o_str ||=SiSU_Env::ProcessingSettings.new(@md).output_dir_structure end |
Instance Method Details
#copy(src_path, dest_path, images = nil) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/sisu/shared_images.rb', line 79 def copy(src_path,dest_path,images=nil) if FileTest.directory?(src_path) FileUtils::cd(src_path) unless images images=Dir.glob("*.{png,jpg,gif,ico}") end unless FileTest.directory?(dest_path) \ or FileTest.symlink?(dest_path) FileUtils::mkdir_p(dest_path) FileUtils::chmod(0755,dest_path) end if images.length > 0 images.each do |i| if FileTest.file?(i) FileUtils::cp_r(i,"#{dest_path}/#{i}") FileUtils::chmod(0644,"#{dest_path}/#{i}") else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]} end end end FileUtils::cd(@pwd) else STDERR.puts %{\t*WARN* did not find - "#{src_path}" [#{__FILE__}:#{__LINE__}]} end end |
#dest_path(image_type) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/sisu/shared_images.rb', line 103 def dest_path(image_type) pth=if image_type==:image_sys pth=(@o_str.dump_or_redirect?) \ ? "#{@md.file.output_path.html.dir}/image" : "#{@md.file.output_path.base.dir}/_sisu/image_sys" elsif image_type==:image pth=(@o_str.dump_or_redirect?) \ ? "#{@md.file.output_path.html.dir}/image" : "#{@md.file.output_path.base.dir}/_sisu/image" end pth end |
#images_set ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/sisu/shared_images.rb', line 77 def images_set @pwd=(/(\S+?)(?:\/(?:#{Px[:lng_lst_rgx]}))?$/).match(Dir.pwd)[1] def copy(src_path,dest_path,images=nil) if FileTest.directory?(src_path) FileUtils::cd(src_path) unless images images=Dir.glob("*.{png,jpg,gif,ico}") end unless FileTest.directory?(dest_path) \ or FileTest.symlink?(dest_path) FileUtils::mkdir_p(dest_path) FileUtils::chmod(0755,dest_path) end if images.length > 0 images.each do |i| if FileTest.file?(i) FileUtils::cp_r(i,"#{dest_path}/#{i}") FileUtils::chmod(0644,"#{dest_path}/#{i}") else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]} end end end FileUtils::cd(@pwd) else STDERR.puts %{\t*WARN* did not find - "#{src_path}" [#{__FILE__}:#{__LINE__}]} end end def dest_path(image_type) pth=if image_type==:image_sys pth=(@o_str.dump_or_redirect?) \ ? "#{@md.file.output_path.html.dir}/image" : "#{@md.file.output_path.base.dir}/_sisu/image_sys" elsif image_type==:image pth=(@o_str.dump_or_redirect?) \ ? "#{@md.file.output_path.html.dir}/image" : "#{@md.file.output_path.base.dir}/_sisu/image" end pth end def select_with_document images=@md.ec[:image] src_path=unless @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/ "#{@pwd}/_sisu/image" else #sisupod pt=/(\/\S+?\/sisupod\/\S+?\/sisupod)\/doc/.match(@md.opt.f_pth[:pth])[1] pt + '/image' end dest=dest_path(:image) copy(src_path,dest,images) end def select_sisu_base images=%w[arrow_next_red.png arrow_prev_red.png arrow_up_red.png dot_clear.png dot_white.png b_doc.png b_epub.png b_odf.png b_pdf.png b_toc.png] src_path="#{SiSU_is.path_base_system_data?}/image" dest=dest_path(:image_sys) copy(src_path,dest,images) end self end |
#select_sisu_base ⇒ Object
126 127 128 129 130 131 |
# File 'lib/sisu/shared_images.rb', line 126 def select_sisu_base images=%w[arrow_next_red.png arrow_prev_red.png arrow_up_red.png dot_clear.png dot_white.png b_doc.png b_epub.png b_odf.png b_pdf.png b_toc.png] src_path="#{SiSU_is.path_base_system_data?}/image" dest=dest_path(:image_sys) copy(src_path,dest,images) end |
#select_with_document ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/sisu/shared_images.rb', line 115 def select_with_document images=@md.ec[:image] src_path=unless @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/ "#{@pwd}/_sisu/image" else #sisupod pt=/(\/\S+?\/sisupod\/\S+?\/sisupod)\/doc/.match(@md.opt.f_pth[:pth])[1] pt + '/image' end dest=dest_path(:image) copy(src_path,dest,images) end |
#songsheet ⇒ Object
73 74 75 76 |
# File 'lib/sisu/shared_images.rb', line 73 def songsheet images_set.select_sisu_base images_set.select_with_document end |