Class: RubyCat::Card
- Inherits:
-
Object
- Object
- RubyCat::Card
- Defined in:
- lib/rubycat/card.rb
Instance Attribute Summary collapse
-
#categories ⇒ Object
readonly
e.g.
-
#deps ⇒ Object
readonly
runtime dependencies as a string for now (activerecord, activesupport etc.).
-
#desc ⇒ Object
readonly
info/blurb/description/summary (use summary ??).
-
#downloads ⇒ Object
readonly
total downloads.
-
#gem_url ⇒ Object
readonly
e.g.
-
#github_url ⇒ Object
readonly
e.g.
-
#latest_version ⇒ Object
readonly
as string.
-
#latest_version_downloads ⇒ Object
readonly
Returns the value of attribute latest_version_downloads.
-
#name ⇒ Object
readonly
read only.
Instance Method Summary collapse
-
#initialize(card) ⇒ Card
constructor
A new instance of Card.
- #sync_gems_info(json) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(card) ⇒ Card
Returns a new instance of Card.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rubycat/card.rb', line 35 def initialize( card ) @categories = card.categories @name = nil github_link = card.links.find {|it| it[0].include?( ':octocat:') } if github_link @github_url = github_link[1] ## check if org (shortcut) uri = URI.parse( @github_url ) puts " uri.path: #{uri.path}" ## names = uri.path[1..-1].split('/') ## cut off leading / and split pp names ## if single name (duplicate - downcased! e.g. Ramaze => Ramaze/ramaze) if names.size == 1 @github_url += "/#{names[0].downcase}" @name = names[0].downcase else @name = names[1] end puts "github_url: #{@github_url}" else puts "*** no github_url found" pp card end gem_link = card.links.find {|it| it[0] == ':gem:' } if gem_link @gem_url = gem_link[1] puts "gem_url: #{@gem_url}" uri = URI.parse( @gem_url ) names = uri.path[1..-1].split('/') ## cut off leading / and split pp names ## assume last name entry is name of gem @name = names[-1] else puts "*** no gem_url found" pp card end end |
Instance Attribute Details
#categories ⇒ Object (readonly)
e.g.
12 13 14 |
# File 'lib/rubycat/card.rb', line 12 def categories @categories end |
#deps ⇒ Object (readonly)
runtime dependencies as a string for now (activerecord, activesupport etc.)
18 19 20 |
# File 'lib/rubycat/card.rb', line 18 def deps @deps end |
#desc ⇒ Object (readonly)
info/blurb/description/summary (use summary ??)
14 15 16 |
# File 'lib/rubycat/card.rb', line 14 def desc @desc end |
#downloads ⇒ Object (readonly)
total downloads
17 18 19 |
# File 'lib/rubycat/card.rb', line 17 def downloads @downloads end |
#gem_url ⇒ Object (readonly)
10 11 12 |
# File 'lib/rubycat/card.rb', line 10 def gem_url @gem_url end |
#github_url ⇒ Object (readonly)
11 12 13 |
# File 'lib/rubycat/card.rb', line 11 def github_url @github_url end |
#latest_version ⇒ Object (readonly)
as string
15 16 17 |
# File 'lib/rubycat/card.rb', line 15 def latest_version @latest_version end |
#latest_version_downloads ⇒ Object (readonly)
Returns the value of attribute latest_version_downloads.
16 17 18 |
# File 'lib/rubycat/card.rb', line 16 def latest_version_downloads @latest_version_downloads end |
#name ⇒ Object (readonly)
read only
9 10 11 |
# File 'lib/rubycat/card.rb', line 9 def name @name end |
Instance Method Details
#sync_gems_info(json) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/rubycat/card.rb', line 82 def sync_gems_info( json ) @desc = json['info'] @latest_version = json['version'] @latest_version_downloads = json['version_downloads'] @downloads = json['downloads'] deps_runtime = json['dependencies']['runtime'] if deps_runtime && deps_runtime.size > 0 deps = [] deps_runtime.each do |dep| deps << dep['name'] end @deps = deps.join(', ') else @deps = nil end end |
#to_hash ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rubycat/card.rb', line 21 def to_hash { name: @name, gem_url: @gem_url, github_url: @github_url, categories: @categories, desc: @desc, latest_version: @latest_version, latest_version_downloads: @latest_version_downloads, downloads: @downloads, deps: @deps } end |