joya 0.1.0 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/Gemfile.lock +3 -3
- data/README.md +9 -38
- data/exe/joya +3 -1
- data/lib/joya.rb +104 -71
- data/lib/joya/gem.rb +14 -0
- data/lib/joya/version.rb +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28ff93e326df0d6398e7167a1f31c19db5f8b963e9959fad330aa99e833ed0d4
|
4
|
+
data.tar.gz: 5fa0f4233df5efb76aa6802af6ad7f5a0dc790b261f60da233eef46c69a22b9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ca5aa73a627d5f2af4023c856dd04369158b5eeb68d961ceafed838a74469b113ca9f75f61eca93e7b483ad98cfdc9adb4fd526f0b03fa1bc72817f85ea77a9
|
7
|
+
data.tar.gz: 7d36f3d3e964440f36dfc55c16a49827247fff37c828f6a68849e06463a1e7dcf1f4025db8c9b1e2a1887af12024021417000ba354c7f70fc3093b4d9d7dfebf
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
joya (0.1.
|
4
|
+
joya (0.1.11)
|
5
5
|
nokogiri (~> 1.10.4)
|
6
6
|
|
7
7
|
GEM
|
@@ -17,7 +17,7 @@ GEM
|
|
17
17
|
builder
|
18
18
|
minitest (>= 5.0)
|
19
19
|
ruby-progressbar
|
20
|
-
nokogiri (1.10.
|
20
|
+
nokogiri (1.10.8)
|
21
21
|
mini_portile2 (~> 2.4.0)
|
22
22
|
rake (10.5.0)
|
23
23
|
ruby-progressbar (1.10.1)
|
@@ -34,4 +34,4 @@ DEPENDENCIES
|
|
34
34
|
rake (~> 10.0)
|
35
35
|
|
36
36
|
BUNDLED WITH
|
37
|
-
2.
|
37
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,41 +1,12 @@
|
|
1
1
|
Joya
|
2
2
|
====
|
3
3
|
|
4
|
-
[
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
## Usage
|
14
|
-
|
15
|
-
Pass the name of a <https://rubygems.org> account:
|
16
|
-
|
17
|
-
```bash
|
18
|
-
$ joya sergioro
|
19
|
-
4 gems found
|
20
|
-
[0/4] Unpacking hola-sergio
|
21
|
-
[1/4] Unpacking trick_or_treat
|
22
|
-
[2/4] Unpacking repo-sergio
|
23
|
-
[3/4] Unpacking clup
|
24
|
-
Done: gems available at gems-sergioro
|
25
|
-
```
|
26
|
-
|
27
|
-
Recommended steps to maximize profit:
|
28
|
-
|
29
|
-
1. Find an awesome Ruby programmer to learn from
|
30
|
-
2. Use `joya programmer_name`
|
31
|
-
3. Read the source code of the programmer and learn new techniques
|
32
|
-
4. Become an awesome Ruby programmer
|
33
|
-
|
34
|
-
## Contributing
|
35
|
-
|
36
|
-
Bug reports and pull requests are welcome on [GitHub.](https://github.com/sergioro9/joya)
|
37
|
-
|
38
|
-
## License
|
39
|
-
|
40
|
-
The gem is available as open source under the terms of the [MIT
|
41
|
-
License](https://opensource.org/licenses/MIT).
|
4
|
+
[Joya](https://en.wiktionary.org/wiki/joya#Spanish) clones gems from a [rubygems](https://rubygems.org) users.
|
5
|
+
|
6
|
+
[ ] remove nokogiri dependency. use only stdlib
|
7
|
+
[ ] optimize Joya#unpack_all by multiple processes to download gems in parallel
|
8
|
+
[ ] add an option that prints available gems and let you choose which to download
|
9
|
+
- you can print all the gems of an author and then let the user use the mouse to choose which gems not to download.
|
10
|
+
- you could use whiptail(1) to display the menu of gems
|
11
|
+
- you could see the source code of fzf and nerdtree ruby gems, which let you use the mouse to click on files. do something similar for joya
|
12
|
+
- conclusion: learn how to detect mouse clicks and mouse location inside a terminal
|
data/exe/joya
CHANGED
data/lib/joya.rb
CHANGED
@@ -1,97 +1,130 @@
|
|
1
|
+
$LOAD_PATH.unshift(__dir__)
|
2
|
+
|
1
3
|
require "joya/version"
|
4
|
+
require "joya/gem"
|
2
5
|
require 'open-uri'
|
3
6
|
require 'nokogiri'
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
|
9
|
+
%w[INT TERM].each do |signal|
|
10
|
+
trap(signal) do
|
11
|
+
puts "\b"*3+"Download interrupted"
|
12
|
+
break
|
8
13
|
end
|
9
14
|
end
|
10
15
|
|
11
|
-
class String
|
16
|
+
class String # :nodoc:
|
17
|
+
# check if a gem is installed
|
12
18
|
def gem_installed?
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
!Dir.glob([path, 'gems', gem_name << version].join('/')).empty?
|
19
|
+
gem_path=ENV['GEM_PATH'].split(":").first
|
20
|
+
!Dir.glob([gem_path, 'gems', self + Joya::GEM_VERSION_PATTERN].join('/')).empty?
|
21
|
+
rescue NoMethodError
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
25
|
+
# the Joya module
|
26
|
+
module Joya
|
27
|
+
class Error < StandardError; end # :nodoc:
|
28
|
+
|
29
|
+
# xpath pattern to scrap gem names of a rubygems user
|
30
|
+
GEM_NAME_XPATH="//a[@class='gems__gem__name']//text()[not(parent::span)]"
|
31
|
+
GEM_VERSION_PATTERN='-[0-9]*\.[0-9]*\.[0-9]*'
|
32
|
+
|
33
|
+
@gems=[]
|
34
|
+
@author=''
|
35
|
+
|
36
|
+
class << self
|
37
|
+
# gems author
|
38
|
+
attr_accessor :author
|
39
|
+
|
40
|
+
# author's gems
|
41
|
+
attr_accessor :gems
|
42
|
+
|
43
|
+
def main(args) # :nodoc:
|
44
|
+
help if(args.include?("-h") or args.include?("--help") or args.empty?)
|
45
|
+
version if (args.include?("-v") or args.include?("--version"))
|
46
|
+
|
47
|
+
# take the first argument starting with '\w' as the author
|
48
|
+
@author = args.find{|arg| arg.match(/^\w/)}
|
49
|
+
help if author.nil?
|
50
|
+
|
51
|
+
fetch_gem_names
|
52
|
+
print_and_quit if (args.include?("-p") or args.include?("--print"))
|
53
|
+
make_dir
|
54
|
+
unpack_all
|
36
55
|
end
|
37
|
-
Dir.chdir '..'
|
38
|
-
puts "Done: gems available at #{directory}"
|
39
|
-
rescue
|
40
|
-
puts "There was a problem, maybe try with a different argument?"
|
41
|
-
end
|
42
56
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
puts
|
57
|
+
# print user gems and exit
|
58
|
+
def print_and_quit
|
59
|
+
puts "Gems of #{author}:"
|
60
|
+
puts gems
|
47
61
|
exit
|
48
62
|
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.url
|
52
|
-
"https://rubygems.org/profiles/#{Joya.author}"
|
53
|
-
end
|
54
63
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
# install missing gems and unpack them in +base_dir+
|
65
|
+
def unpack_all
|
66
|
+
Dir.chdir base_dir
|
67
|
+
total=gems.size
|
68
|
+
digits=total.to_s.size
|
69
|
+
puts "#{total} gems found"
|
70
|
+
puts "Downloading into #{base_dir}/"
|
71
|
+
interrupted = false
|
72
|
+
gems.each_with_index do |jem,i|
|
73
|
+
printf("[%#{digits}d/%#{digits}d] Unpacking %s\n", i+1, total, jem)
|
74
|
+
Joya::Gem.install(jem) unless jem.gem_installed?
|
75
|
+
Joya::Gem.unpack(jem)
|
76
|
+
end
|
77
|
+
rescue LocalJumpError
|
78
|
+
ensure
|
79
|
+
Dir.chdir '..'
|
80
|
+
end
|
67
81
|
|
68
|
-
|
69
|
-
|
70
|
-
|
82
|
+
def version # :nodoc:
|
83
|
+
puts "joya #{Joya::VERSION}"
|
84
|
+
exit
|
85
|
+
end
|
71
86
|
|
72
|
-
|
73
|
-
|
74
|
-
|
87
|
+
def help # :nodoc:
|
88
|
+
puts <<~str
|
89
|
+
Usage:
|
90
|
+
joya <author> [options]
|
75
91
|
|
76
|
-
|
77
|
-
|
78
|
-
|
92
|
+
Options:
|
93
|
+
-h, --help print this help message
|
94
|
+
-p, --print print user gems without downloading
|
95
|
+
-v, --version print joya version
|
96
|
+
str
|
97
|
+
exit
|
98
|
+
end
|
79
99
|
|
80
|
-
|
100
|
+
def url # :nodoc:
|
101
|
+
"https://rubygems.org/profiles/#{author}"
|
102
|
+
end
|
81
103
|
|
82
|
-
|
83
|
-
|
84
|
-
|
104
|
+
# fetch gem names from a given rubygems author
|
105
|
+
def fetch_gem_names
|
106
|
+
site=Nokogiri::HTML(open_rubygems)
|
107
|
+
@gems=site.xpath(GEM_NAME_XPATH).text.gsub(/\s+/," ").split
|
108
|
+
end
|
85
109
|
|
86
|
-
|
87
|
-
|
88
|
-
|
110
|
+
# open the rubygems url
|
111
|
+
def open_rubygems
|
112
|
+
URI.open(url)
|
113
|
+
rescue OpenURI::HTTPError
|
114
|
+
puts "HTTPError: Could not find rubygems of #{author}"
|
115
|
+
exit
|
116
|
+
end
|
89
117
|
|
90
|
-
|
91
|
-
|
92
|
-
|
118
|
+
# directory where gems will be unpacked
|
119
|
+
def base_dir
|
120
|
+
"gems-#{author}"
|
121
|
+
end
|
122
|
+
alias_method :directory, :base_dir
|
93
123
|
|
94
|
-
|
95
|
-
|
124
|
+
# makes +base_dir+
|
125
|
+
def make_dir
|
126
|
+
FileUtils.mkdir base_dir
|
127
|
+
rescue Errno::EEXIST
|
128
|
+
end
|
96
129
|
end
|
97
130
|
end
|
data/lib/joya/gem.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Joya
|
2
|
+
# container of +gem+ commands
|
3
|
+
class Gem
|
4
|
+
# install a gem
|
5
|
+
def self.install(jem)
|
6
|
+
system("gem install #{jem}", [:err, :out] => File::NULL)
|
7
|
+
end
|
8
|
+
|
9
|
+
# unpack a gem
|
10
|
+
def self.unpack(jem)
|
11
|
+
system("gem unpack #{jem}", [:err, :out] => File::NULL)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/joya/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.1.
|
1
|
+
module Joya # :nodoc:
|
2
|
+
VERSION = "0.1.12"
|
3
3
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Romero
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,12 +114,13 @@ files:
|
|
114
114
|
- exe/joya
|
115
115
|
- joya.gemspec
|
116
116
|
- lib/joya.rb
|
117
|
+
- lib/joya/gem.rb
|
117
118
|
- lib/joya/version.rb
|
118
119
|
homepage: https://github.com/sergioro9/joya
|
119
120
|
licenses:
|
120
121
|
- MIT
|
121
122
|
metadata: {}
|
122
|
-
post_install_message:
|
123
|
+
post_install_message:
|
123
124
|
rdoc_options: []
|
124
125
|
require_paths:
|
125
126
|
- lib
|
@@ -134,8 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
135
|
- !ruby/object:Gem::Version
|
135
136
|
version: '0'
|
136
137
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
138
|
-
signing_key:
|
138
|
+
rubygems_version: 3.2.11
|
139
|
+
signing_key:
|
139
140
|
specification_version: 4
|
140
141
|
summary: Clone gems from a specified author
|
141
142
|
test_files: []
|