Class: Raykit::SourceImport
- Inherits:
-
Hash
- Object
- Hash
- Raykit::SourceImport
- Defined in:
- lib/raykit/sourceImport.rb
Instance Method Summary collapse
- #copy ⇒ Object
-
#initialize(url) ⇒ SourceImport
constructor
attr_accessor :remote attr_accessor :glob attr_accessor :target attr_accessor :commit.
- #remote ⇒ Object
- #target ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(url) ⇒ SourceImport
attr_accessor :remote attr_accessor :glob attr_accessor :target attr_accessor :commit
9 10 11 12 13 14 |
# File 'lib/raykit/sourceImport.rb', line 9 def initialize(url) self['remote'] = url self['glob'] = '**/*.cs' self['target'] = '' self['commit']='' end |
Instance Method Details
#copy ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/raykit/sourceImport.rb', line 43 def copy if(target.length == 0) puts 'target has not been specified' else count=0 source_names = [] work=self['remote'].work_dir Dir.chdir(work) do source_names=Dir.glob(self['glob']) end source_names.each{|source_name| source=work + "/" + source_name target_name = target + "/" + source_name target_parent = File.dirname(target_name) FileUtils.mkdir_p(target_parent) if(!Dir.exist?(target_parent)) FileUtils.copy(source,target_name) count += 1 } puts ' copied ' + count.to_s + ' files to ' + target end end |
#remote ⇒ Object
16 17 18 |
# File 'lib/raykit/sourceImport.rb', line 16 def remote self['remote'] end |
#target ⇒ Object
20 21 22 |
# File 'lib/raykit/sourceImport.rb', line 20 def target self['target'] end |
#update ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/raykit/sourceImport.rb', line 24 def update work=self['remote'].work_dir work_parent=File.dirname(work) FileUtils.mkdir_p(work_parent) if(!Dir.exist?(work_parent)) if(Dir.exist?(work)) Dir.chdir(work) do PROJECT.run("git pull") end else PROJECT.run("git clone #{remote} #{work}") end Dir.chdir(work) do text=`git log -n 1` scan=text.scan(/commit ([\w]+)\s/) self['commit'] = scan[0][0].to_s end end |