Module: RubyGemFeed

Defined in:
lib/rubygemfeed.rb,
lib/rubygemfeed/version.rb

Constant Summary collapse

MAX_INFO_LENGTH =
76
VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.new50Object



34
35
36
# File 'lib/rubygemfeed.rb', line 34

def self.new50
  self.parse_url
end

.parse(rgems) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rubygemfeed.rb', line 16

def self.parse(rgems)
  rgnames = []
  rgems.each do |x|
    rgnames << [x['name'], x['version'], x['authors'], x['info'], x['project_uri']]
  end
  puts (
    rgnames.map { |x|
      x[0] = (
        x[0].gsub(/([-_])/, ' ').split.map { |y|
          y.capitalize
        }
      ).join(' ')
      x[3] = x[3][0..MAX_INFO_LENGTH]
      "\n#{x[0]} #{x[1]} ( by #{x[2]} )\n  #{x[3]}\n  #{x[4]}\n"
    }
  )
end

.parse_url(in_url = 'https://rubygems.org/api/v1/activity/latest.json') ⇒ Object



10
11
12
13
14
# File 'lib/rubygemfeed.rb', line 10

def self.parse_url(in_url = 'https://rubygems.org/api/v1/activity/latest.json')
  content = open(in_url).read
  rgems = JSON.parse(content)
  self.parse(rgems)
end

.querygem(name) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/rubygemfeed.rb', line 42

def self.querygem(name)
  begin
    rgem = JSON.parse(open("https://rubygems.org/api/v1/gems/#{name.strip_byac((('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + ['-','_']).flatten.join(''))}.json").read)
    self.parse([rgem])
  rescue
    puts "\n!!! GEM #{name} NOT FOUND !!!\n" 
  end
end

.updated50Object



38
39
40
# File 'lib/rubygemfeed.rb', line 38

def self.updated50
  self.parse_url('https://rubygems.org/api/v1/activity/just_updated.json')
end