From 75e3bf86382edf99275a25895b362647158e25c1 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 10 Jan 2012 22:37:26 -0500 Subject: v3dv, add dev branch (use to make some changes to module & class names & test) * (intended as) short term branch, merge back into v3 once tested * sisu --dev (to invoke) --- lib/sisu/v3dv/git.rb | 281 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 lib/sisu/v3dv/git.rb (limited to 'lib/sisu/v3dv/git.rb') diff --git a/lib/sisu/v3dv/git.rb b/lib/sisu/v3dv/git.rb new file mode 100644 index 00000000..148b35fc --- /dev/null +++ b/lib/sisu/v3dv/git.rb @@ -0,0 +1,281 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997 - 2012, Ralph Amissah, All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_Git + require_relative 'param' # param.rb + require_relative 'sysenv' # sysenv.rb + require_relative 'dal' # dal.rb + class Source + def initialize(opt) + @opt=opt + @env=SiSU_Env::Info_env.new + @md=SiSU_Param::Parameters.new(@opt).get + @file=SiSU_Env::SiSU_file.new(@md) + l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + unless @opt.lng==l[:c] # @md.i18n[0]==l[:c] + p "using: #{@opt.lng} (@make: :language:); filename #{@md.fns} filename language: #{l[:c]}, mismatch" + end + if @env.output_dir_structure.multilingual? + m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst|ssm)$/ #watch added match for sss + fnn,fnb,fnt=@opt.fns[m,1],@opt.fns[m,2],@opt.fns[m,3] + else m=/(.+?)\.((?:-|ssm\.)?sst|ssm)$/ + fnb=@fnn=@opt.fns[m,1] + fnt=@opt.fns[m,2] + end + git_path_fnb=@env.processing_path.git + '/' + fnb + #unless @opt.cmd =~/q/ + # @opt.cmd=~/[MVvz]/ \ + # ? SiSU_Screen::Ansi.new(@opt.cmd,'Git path',@git_path[:fnb]).green_hi_blue \ + # : SiSU_Screen::Ansi.new(@opt.cmd,'Git path',@git_path[:fnb]).green_title_hi + # SiSU_Screen::Ansi.new(@opt.cmd,"Git path","#{@opt.fns} -> #{@git_path[:fnb]}").warn if @opt.cmd =~/[MVv]/ + #end + lng=(@md.opt.lng) ? (@md.opt.lng) : (@md.i18n[0]) + @git_path={ + fnb: git_path_fnb, + src: git_path_fnb + '/' + Gt[:src] + '/' + lng, + po: git_path_fnb + '/' + Gt[:po] + '/' + lng, + pot: git_path_fnb + '/' + Gt[:pot], + conf: git_path_fnb + '/' + Gt[:conf], + skin: git_path_fnb + '/' + Gt[:skin], + image: git_path_fnb + '/' + Gt[:image], + audio: git_path_fnb + '/' + Gt[:audio], + video: git_path_fnb + '/' + Gt[:video], + conf: git_path_fnb + '/' + Gt[:conf] + } + SiSU_DAL::Source.new(@opt).read # -m + end + def create_file_structure_git + make_dir_fnb + if program_found? + git_init + end + end + def read + create_file_structure_git + populate.sisusrc_files + if program_found? + git_commit + end + unless @opt.cmd =~/q/ + @opt.cmd=~/[MVvz]/ \ + ? SiSU_Screen::Ansi.new(@opt.cmd,'Git path',@git_path[:fnb]).green_hi_blue + : SiSU_Screen::Ansi.new(@opt.cmd,'Git path',@git_path[:fnb]).green_title_hi + SiSU_Screen::Ansi.new(@opt.cmd,"Git path","#{@opt.fns} -> #{@git_path[:fnb]}").warn if @opt.cmd =~/[MVv]/ + end + end + def program_found? + found=`whereis git` + (found =~/bin\/git\b/) ? true : false + end + def make_dir_fnb + FileUtils::mkdir_p(@git_path[:fnb]) unless FileTest.directory?(@git_path[:fnb]) + FileUtils::mkdir_p(@git_path[:src]) unless FileTest.directory?(@git_path[:src]) + FileUtils::mkdir_p(@git_path[:po]) unless FileTest.directory?(@git_path[:po]) + FileUtils::mkdir_p(@git_path[:pot]) unless FileTest.directory?(@git_path[:pot]) + FileUtils::mkdir_p(@git_path[:conf]) unless FileTest.directory?(@git_path[:conf]) + FileUtils::mkdir_p(@git_path[:skin]) unless FileTest.directory?(@git_path[:skin]) + FileUtils::mkdir_p(@git_path[:image]) unless FileTest.directory?(@git_path[:image]) + #FileUtils::mkdir_p(@git_path[:audio]) unless FileTest.directory?(@git_path[:audio]) + #FileUtils::mkdir_p(@git_path[:video]) unless FileTest.directory?(@git_path[:video]) + end + def git_init + unless FileTest.directory?("#{@git_path[:fnb]}/.git") + pwd=Dir.pwd + Dir.chdir(@git_path[:fnb]) + system("git init ") + Dir.chdir(pwd) + end + end + def git_commit + if FileTest.directory?("#{@git_path[:fnb]}") + pwd=Dir.pwd + Dir.chdir(@git_path[:fnb]) + system(" + git add . \ + && git commit -a + ") + Dir.chdir(pwd) + end + end + def populate + def identify_language_versions + print __FILE__ + ':' + p __LINE__ + end + def copy_src_head + if @opt.f_pth[:lng] + FileUtils::cp_r("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}",@git_path[:src]) + elsif @opt.fns =~/\.ssm\.sst/ + ssm=@opt.fns.gsub(/\.ssm\.sst/,'.ssm') + FileUtils::cp_r("#{@env.path.pwd}/#{ssm}",@git_path[:src]) + else + FileUtils::cp_r("#{@env.path.pwd}/#{@opt.fns}",@git_path[:src]) + end + end + def copy_related_sst_ssi + doc_import=[] + @rgx_doc_import=/^<<\s(\S+?\.ss[ti])/ + file_array=IO.readlines(@opt.fns,'') + file_array.each do |f| + if f =~@rgx_doc_import + doc_import = doc_import + f.scan(@rgx_doc_import).uniq.flatten + end + end + doc_import.each do |f| + if @opt.f_pth[:lng] + FileUtils::cp_r("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{f}",@git_path[:src]) + else + FileUtils::cp_r("#{@env.path.pwd}/#{f}",@git_path[:src]) + end + end + end + def locate_parse_file + composite_src=@opt.fns=~/\.ssm$/ ? true : false + parse_file=if composite_src \ + and @opt.cmd.inspect !~/m/ + ##SiSU_Assemble::Composite.new(@opt).read + #SiSU_DAL::Source.new(@opt).read # -m + "#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst" + elsif composite_src + "#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst" + else "#{@env.path.pwd}/#{@opt.fns}" + end + end + def locate_skin + SiSU_Env::Info_skin.new(@md).select + end + def read_composite + #print __FILE__ + ':' + #p __LINE__ + end + def extract_skin + #print __FILE__ + ':' + #p __LINE__ + end + def extract_skin_and_images #(parse_file) + parse_file_name=locate_parse_file + parse_file=IO.readlines(parse_file_name,'') + rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ + #rgx_rb_image=/["'](\S+?\.(?:png|jpg|gif))["']/ + #rgx_rb_image=/[^\/]?([a-z]\S+?\.(?:png|jpg|gif))/ + rgx_rb_image=/([a-z][^ \/]+?\.(?:png|jpg|gif))/ + rgx_skin=/^\s+:skin:\s+(\S+)/ + skin_get=nil + images=[] + skin_get + parse_file.each do |f| #% work area + if f !~/^%+\s/ + skin_get ||= f.scan(rgx_skin).uniq.flatten if f =~rgx_skin + if f =~rgx_image + images << f.scan(rgx_image).uniq + end + end + end + skin=skin_get[0] if skin_get + skin=locate_skin + parse_skin=IO.readlines(skin,"\n") + parse_skin.each do |f| #% work area + if f !~/^#/ \ + and f =~rgx_rb_image + images << f.scan(rgx_rb_image).uniq + end + end + image_path="#{@env.path.pwd}/_sisu/image" + images.flatten.each do |i| + if FileTest.file?("#{image_path}/#{i}") + FileUtils::cp_r("#{image_path}/#{i}",@git_path[:image]) + end + end + if FileTest.file?(skin) + FileUtils::cp_r(skin,"#{@git_path[:conf]}/skin") + end + { skin: skin, images: images } + end + def sisuyaml_rc + sisurc=@env.path.sisurc_path + if FileTest.file?(sisurc) + FileUtils::cp_r(sisurc,@git_path[:conf]) + end + end + def read_src + print __FILE__ + ':' + p __LINE__ + end + def composite_src? + @opt.fns=~/\.ssm$/ ? true : false + end + def sisusrc_files + populate.copy_src_head + if composite_src? + populate.copy_related_sst_ssi + end + populate.extract_skin + #parse_file_name=locate_parse_file + #parse_file=IO.readlines(parse_file_name,'') + populate.sisuyaml_rc #(parse_file) + populate.extract_skin_and_images #(parse_file) + #populate.extract_composite_source + #populate.read_composite # or read_each_composite + populate.identify_language_versions + end + self + end + end +end +__END__ +@file.output_path.sisugit -- cgit v1.2.3 From 732dca2b21d2261349e639c37e6ed1431e65250c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 10 Jan 2012 22:47:40 -0500 Subject: v3dv: class names, remove "SiSU_" (reserve for module names for consistency) --- lib/sisu/v3dv/git.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/sisu/v3dv/git.rb') diff --git a/lib/sisu/v3dv/git.rb b/lib/sisu/v3dv/git.rb index 148b35fc..63fb132f 100644 --- a/lib/sisu/v3dv/git.rb +++ b/lib/sisu/v3dv/git.rb @@ -65,7 +65,7 @@ module SiSU_Git @opt=opt @env=SiSU_Env::Info_env.new @md=SiSU_Param::Parameters.new(@opt).get - @file=SiSU_Env::SiSU_file.new(@md) + @file=SiSU_Env::FileOp.new(@md) l=SiSU_Env::Standardise_language.new(@md.opt.lng).language unless @opt.lng==l[:c] # @md.i18n[0]==l[:c] p "using: #{@opt.lng} (@make: :language:); filename #{@md.fns} filename language: #{l[:c]}, mismatch" -- cgit v1.2.3 From df67ee1079d074dc2af54aa87187c6538e73d5d7 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 10 Jan 2012 22:50:12 -0500 Subject: v3dv: class names, use more CamelCase --- lib/sisu/v3dv/git.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/sisu/v3dv/git.rb') diff --git a/lib/sisu/v3dv/git.rb b/lib/sisu/v3dv/git.rb index 63fb132f..82700d9c 100644 --- a/lib/sisu/v3dv/git.rb +++ b/lib/sisu/v3dv/git.rb @@ -63,10 +63,10 @@ module SiSU_Git class Source def initialize(opt) @opt=opt - @env=SiSU_Env::Info_env.new + @env=SiSU_Env::InfoEnv.new @md=SiSU_Param::Parameters.new(@opt).get @file=SiSU_Env::FileOp.new(@md) - l=SiSU_Env::Standardise_language.new(@md.opt.lng).language + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language unless @opt.lng==l[:c] # @md.i18n[0]==l[:c] p "using: #{@opt.lng} (@make: :language:); filename #{@md.fns} filename language: #{l[:c]}, mismatch" end @@ -197,7 +197,7 @@ module SiSU_Git end end def locate_skin - SiSU_Env::Info_skin.new(@md).select + SiSU_Env::InfoSkin.new(@md).select end def read_composite #print __FILE__ + ':' -- cgit v1.2.3