rubyist 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -9
- data/exe/rubyist +39 -0
- data/lib/rubyist.rb +30 -4
- data/lib/rubyist/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 231a1d3ff0ec9cef4aec72fd2d5316d60a665584
|
4
|
+
data.tar.gz: 96c87378b49d87e9813b4a7ee5d3f189d7a25831
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77fa697d8dec3730f5002da40a19cb680eb2b654fb7ef48c21afd9bdc6394d2aee390ecb1633950fabb0e9a1485b74ba2a314abba43db0960b387bdf973a6969
|
7
|
+
data.tar.gz: 481ef750edba3220295c53569f73d37a527608ade7bdf91d89e305dac6461fbcacdf7381282902ee3dbb864772c2671477054d282ba38c6639c931cd60460086
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Rubyist
|
2
2
|
|
3
|
-
|
3
|
+
Just made this to know gems owned by someone, and forget the [gems](https://github.com/rubygems/gems) and [rubygems.org API](http://guides.rubygems.org/rubygems-org-api/)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,18 +20,26 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
```
|
24
|
-
|
23
|
+
```
|
24
|
+
irb(main):001:0> Rubyist.own('kaminari').include? Rubyist.named('a_matsuda')
|
25
|
+
=> true
|
25
26
|
```
|
26
27
|
|
27
28
|
Interfaces as below
|
28
29
|
|
29
|
-
```
|
30
|
-
irb(main):
|
31
|
-
=> [:
|
32
|
-
irb(main):
|
33
|
-
=> [:name, :
|
34
|
-
irb(main):
|
30
|
+
```
|
31
|
+
irb(main):002:0> Rubyist.methods false
|
32
|
+
=> [:named, :own]
|
33
|
+
irb(main):003:0> Rubyist.instance_methods false
|
34
|
+
=> [:<=>, :name, :gems, :total_downloads]
|
35
|
+
irb(main):004:0> Rubyist::Gem.instance_methods false
|
36
|
+
=> [:<=>, :name, :info, :versions, :total_downloads, :homepage_uri, :project_uri]
|
37
|
+
irb(main):005:0> Rubyist::Gem::Version.instance_methods false
|
35
38
|
=> [:summary, :number, :downloads, :created_at]
|
36
39
|
```
|
37
40
|
|
41
|
+
CLI
|
42
|
+
|
43
|
+
```
|
44
|
+
$ rubyist tenderlove
|
45
|
+
```
|
data/exe/rubyist
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rubyist'
|
2
|
+
|
3
|
+
def help
|
4
|
+
puts <<~EOH
|
5
|
+
Usage: rubyist [OPTION]... NAME
|
6
|
+
List gems owned by NAME, ordered by download count
|
7
|
+
|
8
|
+
-v also show versions
|
9
|
+
-h help
|
10
|
+
EOH
|
11
|
+
end
|
12
|
+
|
13
|
+
def help?
|
14
|
+
ARGV.include? '-h'
|
15
|
+
end
|
16
|
+
|
17
|
+
def versions?
|
18
|
+
ARGV.include? '-v'
|
19
|
+
end
|
20
|
+
|
21
|
+
name = (ARGV - ['-v', '-h']).first
|
22
|
+
|
23
|
+
if help? or name.nil?
|
24
|
+
help
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
Rubyist.
|
29
|
+
named(name).
|
30
|
+
gems.
|
31
|
+
sort { |g1, g2| g1.total_downloads <=> g2.total_downloads }.
|
32
|
+
each do |g|
|
33
|
+
puts "#{g.name} #{g.total_downloads} > #{g.homepage_uri or g.project_uri}"
|
34
|
+
puts "#{g.info}"
|
35
|
+
g.versions.each do |v|
|
36
|
+
puts " #{v.number} #{v.downloads}"
|
37
|
+
end if versions?
|
38
|
+
puts
|
39
|
+
end
|
data/lib/rubyist.rb
CHANGED
@@ -3,25 +3,51 @@ require 'gems'
|
|
3
3
|
require 'time'
|
4
4
|
|
5
5
|
class Rubyist
|
6
|
-
attr_reader :name
|
6
|
+
attr_reader :name
|
7
|
+
include Comparable
|
7
8
|
|
8
9
|
def initialize name
|
9
10
|
@name = name
|
10
|
-
|
11
|
+
end
|
12
|
+
|
13
|
+
def <=>(other)
|
14
|
+
name <=> other.name
|
15
|
+
end
|
16
|
+
|
17
|
+
def gems
|
18
|
+
return @gems if defined? @gems
|
19
|
+
result = Gems.gems(name)
|
20
|
+
@gems = (Hash === result ? [] : result.map { |g| Gem.new g })
|
11
21
|
end
|
12
22
|
|
13
23
|
def total_downloads
|
14
24
|
gems.inject(0) { |sum, g| sum + g.total_downloads }
|
15
25
|
end
|
16
26
|
|
27
|
+
class << self
|
28
|
+
alias_method :named, :new
|
29
|
+
|
30
|
+
def own gem_name
|
31
|
+
Gems.owners(gem_name).
|
32
|
+
map { |o| new o['handle'] }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
17
36
|
class Gem
|
18
|
-
attr_reader :name, :info, :homepage_uri, :project_uri
|
37
|
+
attr_reader :name, :info, :homepage_uri, :project_uri
|
38
|
+
include Comparable
|
19
39
|
|
20
40
|
def initialize hash
|
21
41
|
@name, @info, @homepage_uri, @project_uri =
|
22
42
|
%w[name info homepage_uri project_uri].map { |k| hash[k] }
|
43
|
+
end
|
44
|
+
|
45
|
+
def <=>(other)
|
46
|
+
name <=> other.name
|
47
|
+
end
|
23
48
|
|
24
|
-
|
49
|
+
def versions
|
50
|
+
@versions ||= Gems.versions(name).map { |v| Version.new v }
|
25
51
|
end
|
26
52
|
|
27
53
|
def total_downloads
|
data/lib/rubyist/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,7 +69,8 @@ dependencies:
|
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- block24block@gmail.com
|
72
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- rubyist
|
73
74
|
extensions: []
|
74
75
|
extra_rdoc_files: []
|
75
76
|
files:
|
@@ -81,6 +82,7 @@ files:
|
|
81
82
|
- Rakefile
|
82
83
|
- bin/console
|
83
84
|
- bin/setup
|
85
|
+
- exe/rubyist
|
84
86
|
- lib/rubyist.rb
|
85
87
|
- lib/rubyist/version.rb
|
86
88
|
- rubyist.gemspec
|