module Dev #PROJECT = Dev::Project.new( { # name: 'Musco.Cs.Framework', # type: 'C#', # dep: { nunit:{uri: 'svn://denver-svn/ThirdParty/export/NUnit/2.5.10.11092', # dir: 'ThirdParty/NUnit/2.5.10.11092'}, # specflow:{uri: 'svn://denver-svn/ThirdParty/export/SpecFlow/1.8.1', # dir: 'ThirdParty/SpecFlow/1.8.1'}, # interface:{uri: 'svn://denver-svn/Musco.Cs/Interface/trunk@#{INTERFACE_REV}', # rake: 'default', cache: 'true' } # } , # replace: { interface: { glob: '*.csproj', # search: /Musco.Cs\\Interface\\trunk@[\d]+/, # replace: "Musco.Cs\\Interface\\trunk@#{INTERFACE_REV}" } } #} ) # uri: # dir: # rake: # cache: class Dep < Hash # constructor that accepts a hash def initialize(hash,init_defaults=true) hash.each { |name,value| self[name]=value } end def get_rel_dir return Dev::Environment.expand_string_variables(self[:dir]) unless self[:dir].nil? uri=Dev::Environment.expand_string_variables(self[:uri]) uri_words=uri.split('/') while(uri_words.length > 3) do uri_words.shift end return uri_words.join('/') end def get_dep_dir return Dev::Environment.dev_root + "/dep/" + get_rel_dir end def get_wrk_dir return Dev::Environment.dev_root + "/wrk/" + get_rel_dir unless get_rel_dir.include?("@") return Dev::Environment.dev_root + "/wrk/" + get_rel_dir.split("@")[0] end def get_export_command(local_dir) unless self[:uri].nil? uri=Dev::Environment.expand_string_variables(self.get_value("uri")) if(uri.include?('github.com')) return "<%Dev::Scm::export('#{uri}','#{local_dir}','git') unless File.exists?('#{local_dir}')%>" end return "<%Dev::Scm::export('#{uri}','#{local_dir}','svn') unless File.exists?('#{local_dir}')%>" end # unless end def get_rake_command end def setup_commands array = Array.new array << get_export_command(get_dep_dir) array << "<%puts ' #{get_dep_dir} exists.' if File.exist?('#{get_dep_dir}')%>" unless self[:rake].nil? #array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_dep_dir}', cache:'true'}" unless self.get_value("cache").nil? #array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_dep_dir}'}" if self.get_value("cache").nil? array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_dep_dir}', cache:'true', capture_output: false}" unless self.get_value("cache").nil? array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_dep_dir}', capture_output: false}" if self.get_value("cache").nil? end return array end def pull_commands array = Array.new if(File.exists?(get_wrk_dir)) unless self[:rake].nil? array << "{cmd: 'rake pull', dir: '#{get_wrk_dir}'}" #array << "{cmd: 'rake pull', dir: '#{get_wrk_dir}', capture_output: false}" #array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_wrk_dir}'}" rakefile="#{get_wrk_dir}/rakefile.rb" array << "<%Dev::Svn::update_revision_variables('#{rakefile}')%>" array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_wrk_dir}'}" #array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_wrk_dir}', capture_output: false}" end end return array end end # class Dep end # module Dev