Class: Gems::GemDataset

Inherits:
Object
  • Object
show all
Defined in:
lib/gemverse/gems.rb

Overview

rename to Gems or Gemset or such - why? why not?

Instance Method Summary collapse

Constructor Details

#initialize(gems) ⇒ GemDataset

Returns a new instance of GemDataset.



9
10
11
# File 'lib/gemverse/gems.rb', line 9

def initialize( gems )
   @gems = gems
end

Instance Method Details

#each(&block) ⇒ Object



15
# File 'lib/gemverse/gems.rb', line 15

def each( &block )            @gems.each( &block );            end

#each_with_index(&block) ⇒ Object



14
# File 'lib/gemverse/gems.rb', line 14

def each_with_index( &block ) @gems.each_with_index( &block ); end

#export(path) ⇒ Object

todo/check: add an write_csv( path ) alias / alternate method name - why? why not?



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/gemverse/gems.rb', line 19

def export( path )
  recs = []

  @gems.each do |gem|

    if gem.yanked?
      puts "!! ERROR - includes yanked gem"
      pp gem
      exit 1
    end

    rec = [gem.name,
           gem.version,
           gem.version_created.strftime( '%Y-%m-%d' ),
           gem.version_downloads.to_s,
           gem.homepage,
           gem.runtime_dependencies.join( ' | ' ),
          ]
    recs << rec
  end
  headers = ['name',
             'version',
             'version_created',
             'version_downloads',
             'homepage',
             'dependencies',
            ]
  write_csv( path, [headers]+recs )
end

#sizeObject



13
# File 'lib/gemverse/gems.rb', line 13

def size() @gems.size; end