Class: Debci::Data::Export
- Inherits:
-
Object
- Object
- Debci::Data::Export
- Defined in:
- lib/debci/data.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#tarball ⇒ Object
readonly
Returns the value of attribute tarball.
Instance Method Summary collapse
- #add(pkgname) ⇒ Object
-
#initialize(tarball) ⇒ Export
constructor
A new instance of Export.
- #save ⇒ Object
Constructor Details
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries
20 21 22 |
# File 'lib/debci/data.rb', line 20 def entries @entries end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo
19 20 21 |
# File 'lib/debci/data.rb', line 19 def repo @repo end |
#root ⇒ Object (readonly)
Returns the value of attribute root
18 19 20 |
# File 'lib/debci/data.rb', line 18 def root @root end |
#tarball ⇒ Object (readonly)
Returns the value of attribute tarball
17 18 19 |
# File 'lib/debci/data.rb', line 17 def tarball @tarball end |
Instance Method Details
#add(pkgname) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/debci/data.rb', line 29 def add(pkgname) pkg = @repo.find_package(pkgname) # add data files suites = pkg.suites architectures = pkg.architectures glob = "{packages,autopkgtest}/{#{suites.join(',')}}/{#{architectures.join(',')}}/#{pkg.prefix}/#{pkg.name}" Dir.chdir(repo.path) do Dir[glob].each do |d| entries << d end end # add database data # FIXME make directory unique Dir.chdir(repo.path) do FileUtils.mkdir_p('export') File.open("export/#{pkg.name}.json", 'w') do |f| f.write(Debci::Job.where(package: pkg.name).to_json) end end entries << "export/#{pkg.name}.json" end |
#save ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/debci/data.rb', line 53 def save files_from = Tempfile.new files_from.puts(entries.sort) files_from.close target = File.(tarball) Dir.chdir(repo.path) do system('tar', 'caf', target, '--files-from=' + files_from.path) end end |