Class: CompactIndex::VersionsFile
- Inherits:
-
Object
- Object
- CompactIndex::VersionsFile
- Defined in:
- lib/compact_index/versions_file.rb
Constant Summary collapse
- PATH =
"versions.list"
Instance Method Summary collapse
- #create ⇒ Object
- #create_or_update ⇒ Object
-
#initialize(connection) ⇒ VersionsFile
constructor
A new instance of VersionsFile.
- #update ⇒ Object
- #with_new_gems ⇒ Object
Constructor Details
#initialize(connection) ⇒ VersionsFile
5 6 7 |
# File 'lib/compact_index/versions_file.rb', line 5 def initialize(connection) @conn = connection end |
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/compact_index/versions_file.rb', line 17 def create content = "created_at: #{Time.now.iso8601}" content += "\n---\n" content += gems_for_new_file File.open(PATH, 'w') do |io| io.write content end end |
#create_or_update ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/compact_index/versions_file.rb', line 9 def create_or_update if File.exists? PATH update else create end end |
#update ⇒ Object
27 28 29 30 31 32 |
# File 'lib/compact_index/versions_file.rb', line 27 def update to_write = with_new_gems File.open(PATH, 'w') do |io| io.write to_write end end |
#with_new_gems ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/compact_index/versions_file.rb', line 34 def with_new_gems if new_gems.empty? content else content + "\n" + new_gems end end |