chid 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +24 -18
- data/README.md +7 -12
- data/lib/chid/chid_config.rb +2 -2
- data/lib/chid/command.rb +1 -1
- data/lib/chid/commands/alias/create.rb +53 -0
- data/lib/chid/commands/installs/dotfile.rb +26 -10
- data/lib/chid/commands/installs/node.rb +3 -1
- data/lib/chid/commands/installs/postgres.rb +4 -1
- data/lib/chid/commands/installs/rvm.rb +7 -2
- data/lib/chid/commands/installs/vim.rb +10 -2
- data/lib/chid/commands/pr.rb +63 -0
- data/lib/chid/commands/workstation/create.rb +43 -5
- data/lib/chid/github_api.rb +9 -0
- data/lib/chid/version.rb +1 -1
- data/spec/lib/chid/commands/alias/create_spec.rb +55 -0
- data/spec/lib/chid/commands/pr_spec.rb +68 -0
- data/spec/lib/chid/commands/workstation/create_spec.rb +153 -0
- data/spec/support/.bashrc +7 -0
- data/spec/support/.chid.config +7 -0
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4c0781e14ef22978392d80819ff7b1835bc5b7c8396e1d8f1a9ad36b296cb66
|
4
|
+
data.tar.gz: 836462ef8b68c6edda4c9c783f04caef9830dff476af59ea5072bbbf5f6a66a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeaedc1bb901c77c9d3650e4dc180511f1f277eb932e41f46cfeffee4917c053f0bd6c8270b7c7607941d7e6f4c1967ff5ac499d01b6f3079bba5c0a9078500a
|
7
|
+
data.tar.gz: '0307939c58378866fdb7fec4431af85023ff06281929cba8ab5f354db36fe11612a9be20d4bdba693b191e98131a573ec63ad1fb957b8b96fc7de784a12b915e'
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
chid
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.5
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
chid (0.1
|
4
|
+
chid (0.2.1)
|
5
5
|
http
|
6
6
|
tty-prompt
|
7
7
|
|
@@ -15,25 +15,31 @@ GEM
|
|
15
15
|
domain_name (0.5.20190701)
|
16
16
|
unf (>= 0.0.5, < 1.0.0)
|
17
17
|
equatable (0.6.1)
|
18
|
-
|
18
|
+
ffi (1.13.1)
|
19
|
+
ffi-compiler (1.0.1)
|
20
|
+
ffi (>= 1.0.0)
|
21
|
+
rake
|
22
|
+
http (4.4.1)
|
19
23
|
addressable (~> 2.3)
|
20
24
|
http-cookie (~> 1.0)
|
21
|
-
http-form_data (~> 2.
|
22
|
-
|
25
|
+
http-form_data (~> 2.2)
|
26
|
+
http-parser (~> 1.2.0)
|
23
27
|
http-cookie (1.0.3)
|
24
28
|
domain_name (~> 0.5)
|
25
|
-
http-form_data (2.
|
26
|
-
|
29
|
+
http-form_data (2.3.0)
|
30
|
+
http-parser (1.2.1)
|
31
|
+
ffi-compiler (>= 1.0, < 2.0)
|
27
32
|
method_source (0.8.2)
|
28
|
-
necromancer (0.5.
|
29
|
-
pastel (0.7.
|
33
|
+
necromancer (0.5.1)
|
34
|
+
pastel (0.7.4)
|
30
35
|
equatable (~> 0.6)
|
31
36
|
tty-color (~> 0.5)
|
32
37
|
pry (0.10.4)
|
33
38
|
coderay (~> 1.1.0)
|
34
39
|
method_source (~> 0.8.1)
|
35
40
|
slop (~> 3.4)
|
36
|
-
public_suffix (4.0.
|
41
|
+
public_suffix (4.0.5)
|
42
|
+
rake (13.0.1)
|
37
43
|
rspec (3.6.0)
|
38
44
|
rspec-core (~> 3.6.0)
|
39
45
|
rspec-expectations (~> 3.6.0)
|
@@ -48,21 +54,21 @@ GEM
|
|
48
54
|
rspec-support (~> 3.6.0)
|
49
55
|
rspec-support (3.6.0)
|
50
56
|
slop (3.6.0)
|
51
|
-
tty-color (0.5.
|
52
|
-
tty-cursor (0.7.
|
53
|
-
tty-prompt (0.
|
57
|
+
tty-color (0.5.1)
|
58
|
+
tty-cursor (0.7.1)
|
59
|
+
tty-prompt (0.21.0)
|
54
60
|
necromancer (~> 0.5.0)
|
55
61
|
pastel (~> 0.7.0)
|
56
|
-
tty-reader (~> 0.
|
57
|
-
tty-reader (0.
|
62
|
+
tty-reader (~> 0.7.0)
|
63
|
+
tty-reader (0.7.0)
|
58
64
|
tty-cursor (~> 0.7)
|
59
65
|
tty-screen (~> 0.7)
|
60
66
|
wisper (~> 2.0.0)
|
61
|
-
tty-screen (0.
|
67
|
+
tty-screen (0.8.0)
|
62
68
|
unf (0.1.4)
|
63
69
|
unf_ext
|
64
|
-
unf_ext (0.0.7.
|
65
|
-
wisper (2.0.
|
70
|
+
unf_ext (0.0.7.7)
|
71
|
+
wisper (2.0.1)
|
66
72
|
|
67
73
|
PLATFORMS
|
68
74
|
ruby
|
@@ -73,4 +79,4 @@ DEPENDENCIES
|
|
73
79
|
rspec
|
74
80
|
|
75
81
|
BUNDLED WITH
|
76
|
-
1.
|
82
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Chid
|
2
|
-
Chid is an assistant to help your day-to-day life. It can be used in some
|
2
|
+
Chid is an assistant to help your day-to-day life. It can be used in some
|
3
3
|
installations, news, configurations, workstations and more.
|
4
4
|
|
5
|
-
![](
|
5
|
+
![](https://user-images.githubusercontent.com/47482049/67632355-199ecb80-f89a-11e9-879e-32a0987108ca.gif)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -96,10 +96,10 @@ Signed-off-by: "YourName" "yourEmail@mail.com"
|
|
96
96
|
|
97
97
|
### <a name="install-apps"></a> Install apps
|
98
98
|
|
99
|
-
**Note:** All install tasks, chid will always ask if you really want to install it. Also
|
99
|
+
**Note:** All install tasks, chid will always ask if you really want to install it. Also
|
100
100
|
will install the dependencies if necessary.
|
101
101
|
|
102
|
-
* `$ chid install dotfiles` - Install
|
102
|
+
* `$ chid install dotfiles` - Install my own dotfiles for vim, zsh and tmux
|
103
103
|
* `$ chid install node` - Install Node
|
104
104
|
* `$ chid install postgres` - Install Postgres
|
105
105
|
* `$ chid install rvm` - Install stable RVM version
|
@@ -128,9 +128,7 @@ A simple search in StackOverflow
|
|
128
128
|
* `$ chid stack -search [TEXT_TO_SEACH]` - Will search on StackOverflow all results for that
|
129
129
|
text.
|
130
130
|
|
131
|
-
|
132
|
-
<img src="etc/img/stack.png" alt="stack sample" />
|
133
|
-
</p>
|
131
|
+
![stackchid](https://user-images.githubusercontent.com/47482049/67722187-5c62bf80-f9d0-11e9-9921-86d2b548cc97.gif)
|
134
132
|
|
135
133
|
### <a name="search-gitHub-repositories"></a> Search GitHub repositories
|
136
134
|
|
@@ -159,7 +157,7 @@ choose one of them to open all applications
|
|
159
157
|
from a list. Eg.: `$ chid workstation open -name base` - It will open all applications inside the
|
160
158
|
**base** workstation
|
161
159
|
|
162
|
-
![](
|
160
|
+
![workstationchid](https://user-images.githubusercontent.com/47482049/67722314-b794b200-f9d0-11e9-81cd-1e7b0b27bedf.gif)
|
163
161
|
|
164
162
|
**Note:** For linux users the `$chid workstation create` is not working. You need create
|
165
163
|
manually (editing the .chid.config file). Will be explained how on
|
@@ -240,14 +238,13 @@ To add a new *workstation* you can edit like:
|
|
240
238
|
- Slack
|
241
239
|
:tmux_templates: {}
|
242
240
|
```
|
241
|
+
![configchid](https://user-images.githubusercontent.com/47482049/67722353-d2672680-f9d0-11e9-8c52-8dad5d2ad22f.gif)
|
243
242
|
|
244
243
|
After edit you can open the **base** workstation running:
|
245
244
|
|
246
245
|
* `$ chid workstation open -name base`
|
247
246
|
* `$ chid workstation open -n base`
|
248
247
|
|
249
|
-
![](http://g.recordit.co/VqTjUsQ9fy.gif)
|
250
|
-
|
251
248
|
#### Advance configuration
|
252
249
|
|
253
250
|
Is possible you can customize some options with each Application when will open it
|
@@ -268,5 +265,3 @@ Is possible you can customize some options with each Application when will open
|
|
268
265
|
:tmux_templates: {}
|
269
266
|
```
|
270
267
|
|
271
|
-
![](http://g.recordit.co/40rFYBBR1t.gif)
|
272
|
-
|
data/lib/chid/chid_config.rb
CHANGED
@@ -2,9 +2,9 @@ class ChidConfig
|
|
2
2
|
|
3
3
|
attr_reader :chid_path, :home_path, :chid_config_path
|
4
4
|
|
5
|
-
def initialize
|
5
|
+
def initialize(home_base_path: "~/")
|
6
6
|
@chid_path = Dir.pwd
|
7
|
-
@home_path = File.expand_path(
|
7
|
+
@home_path = File.expand_path(home_base_path)
|
8
8
|
@chid_config_path = File.join(home_path, '.chid.config')
|
9
9
|
end
|
10
10
|
|
data/lib/chid/command.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
module Chid
|
2
|
+
module Commands
|
3
|
+
module Alias
|
4
|
+
class Create < Command
|
5
|
+
|
6
|
+
command :'alias create'
|
7
|
+
|
8
|
+
self.summary = 'Create a new alias'
|
9
|
+
self.description = <<-DESC
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
|
13
|
+
$ chid alias create -command {COMMAND} -alias {ALIAS}
|
14
|
+
|
15
|
+
Example:
|
16
|
+
|
17
|
+
$ chid alias create -command "chid workstation create" -alias cwo
|
18
|
+
|
19
|
+
DESC
|
20
|
+
self.arguments = ['-command', '-alias']
|
21
|
+
|
22
|
+
def run
|
23
|
+
add_command_on_bashrc
|
24
|
+
|
25
|
+
print "Please run: source ~/.bashrc".blue
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def add_command_on_bashrc
|
31
|
+
File.open(bashrc_path, 'a') { |file| file.puts shell_command }
|
32
|
+
end
|
33
|
+
|
34
|
+
def bashrc_path
|
35
|
+
@bashrc_path ||= File.join(Dir.home, '.bashrc')
|
36
|
+
end
|
37
|
+
|
38
|
+
def shell_command
|
39
|
+
"alias #{alias_value}='#{command}'"
|
40
|
+
end
|
41
|
+
|
42
|
+
def alias_value
|
43
|
+
options['-alias'].first
|
44
|
+
end
|
45
|
+
|
46
|
+
def command
|
47
|
+
options['-command'].first
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -12,7 +12,7 @@ Usage:
|
|
12
12
|
|
13
13
|
$ chid install dotfile
|
14
14
|
|
15
|
-
For Linux users will install through curl
|
15
|
+
For Linux users will install through curl
|
16
16
|
|
17
17
|
For OSx users will install through curl
|
18
18
|
|
@@ -21,23 +21,39 @@ Usage:
|
|
21
21
|
|
22
22
|
def run
|
23
23
|
puts "\nInstalling the YADR Dotfiles..."
|
24
|
+
|
25
|
+
puts "\nCreating undodir folder"
|
26
|
+
system('mkdir ~/.vim/undodir')
|
27
|
+
|
24
28
|
::ChidConfig.on_linux do
|
29
|
+
puts "\nInstalling all dependencies"
|
25
30
|
system('sudo apt-get update')
|
26
31
|
system('sudo apt-get install curl')
|
32
|
+
system('sudo apt-get install tmux')
|
33
|
+
system('sudo apt-get install xclip')
|
34
|
+
system('sudo apt install npm')
|
35
|
+
system('sudo apt-get install ripgrep')
|
36
|
+
system('sudo apt-get install fzf')
|
27
37
|
system('sudo apt-get install zsh')
|
28
|
-
system('sudo apt
|
38
|
+
system('sudo apt install git-all')
|
29
39
|
end
|
30
40
|
|
31
|
-
|
41
|
+
puts "\nDownloading tmux config"
|
42
|
+
system('curl -o ~/.tmux.conf https://gist.githubusercontent.com/rachidcalazans/b9ede3f6e49450b41a5bbaff9ccc8cad/raw/f0c1fe18b22772ad04bf322aeb49df993e73877c/.tmux.conf')
|
43
|
+
|
44
|
+
puts "\nDownloading .vimrc"
|
45
|
+
system('curl -o ~/.vimrc https://gist.githubusercontent.com/rachidcalazans/e7b7ee668b9a8b247b3a9c20e5669366/raw/84af22bb3c5fb24b01aa8a01e8b783f85a6928b5/.vimrc')
|
46
|
+
|
47
|
+
puts "\nDownloading coc-settings.json"
|
48
|
+
system('curl -o ~/.vim/coc-settings.json https://gist.githubusercontent.com/rachidcalazans/a29bdedde40b328a14279bda419ccd4f/raw/59492c4096d77aef4690b1516d9c9f597fafd205/coc-settings.json')
|
49
|
+
|
50
|
+
puts "\nInstalling Oh My ZSH"
|
51
|
+
system('sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"')
|
32
52
|
|
33
|
-
puts
|
34
|
-
|
35
|
-
path = "#{home_path}/.yadr"
|
36
|
-
Dir.chdir path
|
37
|
-
system('git pull --rebase')
|
38
|
-
system('rake update')
|
53
|
+
puts "\nInstalling all Vim Plugins"
|
54
|
+
system("vim +'PlugInstall --sync' +qa")
|
39
55
|
|
40
|
-
puts "\
|
56
|
+
puts "\nDotfiles installed successfully"
|
41
57
|
end
|
42
58
|
|
43
59
|
end
|
@@ -23,10 +23,12 @@ Usage:
|
|
23
23
|
puts "\nInstalling the Node..."
|
24
24
|
|
25
25
|
::ChidConfig.on_linux do
|
26
|
-
system('sudo apt
|
26
|
+
system('sudo apt update')
|
27
|
+
system('sudo apt install nodejs')
|
27
28
|
end
|
28
29
|
|
29
30
|
::ChidConfig.on_osx do
|
31
|
+
system('brew update')
|
30
32
|
system('brew install node')
|
31
33
|
end
|
32
34
|
|
@@ -25,10 +25,13 @@ Usage:
|
|
25
25
|
puts "\nInstalling the Postgres..."
|
26
26
|
|
27
27
|
::ChidConfig.on_linux do
|
28
|
-
system('sudo apt
|
28
|
+
system('sudo apt update')
|
29
|
+
system('sudo apt install postgresql postgresql-contrib')
|
30
|
+
system('sudo apt-get install libpq-dev')
|
29
31
|
end
|
30
32
|
|
31
33
|
::ChidConfig.on_osx do
|
34
|
+
system('brew update')
|
32
35
|
system('brew install postgres')
|
33
36
|
end
|
34
37
|
|
@@ -22,19 +22,24 @@ Usage:
|
|
22
22
|
|
23
23
|
def run
|
24
24
|
puts "\nInstalling the RVM..."
|
25
|
+
system('gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB')
|
25
26
|
|
26
27
|
::ChidConfig.on_linux do
|
28
|
+
system('sudo apt-get install software-properties-common')
|
29
|
+
system('sudo apt-get install curl')
|
27
30
|
system('sudo apt-add-repository -y ppa:rael-gc/rvm')
|
28
31
|
system('sudo apt-get update')
|
29
|
-
system('sudo apt-get install curl')
|
30
32
|
system('sudo apt-get install rvm')
|
33
|
+
|
34
|
+
system("echo 'source \"/etc/profile.d/rvm.sh\"' >> ~/.bashrc")
|
31
35
|
end
|
32
36
|
|
33
37
|
::ChidConfig.on_osx do
|
34
|
-
system('\curl -sSL https://get.rvm.io | bash')
|
38
|
+
system('\curl -sSL https://get.rvm.io | bash -s stable --ruby')
|
35
39
|
end
|
36
40
|
|
37
41
|
puts "\nRVM installed successfully"
|
42
|
+
puts "\nPlease rebot your terminal"
|
38
43
|
end
|
39
44
|
|
40
45
|
end
|
@@ -25,12 +25,20 @@ Usage:
|
|
25
25
|
is_gvim = do_gvim?
|
26
26
|
|
27
27
|
::ChidConfig.on_linux do
|
28
|
-
system('sudo apt
|
28
|
+
system('sudo apt update')
|
29
|
+
|
30
|
+
if is_vim
|
31
|
+
system('sudo add-apt-repository ppa:jonathonf/vim')
|
32
|
+
system('sudo apt update')
|
33
|
+
system('sudo apt install vim')
|
34
|
+
end
|
35
|
+
|
29
36
|
system('sudo apt-get install vim-gnome') if is_gvim
|
30
37
|
end
|
31
38
|
|
32
39
|
::ChidConfig.on_osx do
|
33
|
-
system('brew
|
40
|
+
system('brew update')
|
41
|
+
system('brew install vim')
|
34
42
|
end
|
35
43
|
|
36
44
|
puts "\nVim installed successfully" if is_vim
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Chid
|
2
|
+
module Commands
|
3
|
+
class Pr < Command
|
4
|
+
|
5
|
+
command :'pr'
|
6
|
+
|
7
|
+
self.summary = "Will return a list of Open PR's filters by given user"
|
8
|
+
self.description = <<-DESC
|
9
|
+
|
10
|
+
Usage:
|
11
|
+
|
12
|
+
$ chid pr
|
13
|
+
|
14
|
+
or
|
15
|
+
|
16
|
+
$ chid pr -user rachidcalazans
|
17
|
+
|
18
|
+
|
19
|
+
Options:
|
20
|
+
|
21
|
+
-user
|
22
|
+
|
23
|
+
DESC
|
24
|
+
self.arguments = ['-user']
|
25
|
+
|
26
|
+
def run
|
27
|
+
json_prs = GitHubApi.prs(by: user)
|
28
|
+
msg = build_msg(json_prs)
|
29
|
+
|
30
|
+
send_msg(msg)
|
31
|
+
|
32
|
+
msg
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def user
|
38
|
+
options['-user']&.first
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_msg(json_prs)
|
42
|
+
json_prs
|
43
|
+
.filter { |pr| pr['user']['login'] == user }
|
44
|
+
.each_with_object([]) do |pr, memo|
|
45
|
+
pr.transform_keys!(&:to_sym)
|
46
|
+
pr[:user].transform_keys!(&:to_sym)
|
47
|
+
|
48
|
+
memo << <<~STR
|
49
|
+
##{pr[:number]} - #{pr[:title]}
|
50
|
+
By #{pr[:user][:login]}
|
51
|
+
Status: #{pr[:state]}
|
52
|
+
Labels: #{pr[:labels].map { |label| label['name'] }.join(', ') }
|
53
|
+
STR
|
54
|
+
end.join("\n---\n\n")
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def send_msg(msg)
|
59
|
+
puts msg
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -14,15 +14,17 @@ Usage:
|
|
14
14
|
|
15
15
|
Create a new workstation with the selected apps.
|
16
16
|
|
17
|
+
# @todo - Add description to use with new arguments
|
18
|
+
|
17
19
|
To see all workstations you can run
|
18
20
|
|
19
21
|
$ chid workstation list
|
20
22
|
|
21
23
|
DESC
|
22
|
-
self.arguments = []
|
24
|
+
self.arguments = ['-name', '-app_names']
|
23
25
|
|
24
26
|
def run
|
25
|
-
workstation_name = get_workstation_name
|
27
|
+
workstation_name = get_workstation_name
|
26
28
|
result = ::ChidConfig.on_osx { select_apps_on_osx }
|
27
29
|
|
28
30
|
if result.empty?
|
@@ -38,11 +40,21 @@ Usage:
|
|
38
40
|
private
|
39
41
|
|
40
42
|
def get_workstation_name
|
43
|
+
return option_name if option_name
|
44
|
+
|
41
45
|
puts 'tell me the name of the new workstation'
|
42
46
|
print "> "
|
43
47
|
STDIN.gets.strip
|
44
48
|
end
|
45
49
|
|
50
|
+
def option_name
|
51
|
+
options['-name']&.first&.strip
|
52
|
+
end
|
53
|
+
|
54
|
+
def option_app_names
|
55
|
+
options['-app_names']
|
56
|
+
end
|
57
|
+
|
46
58
|
def chid_config
|
47
59
|
::ChidConfig.new
|
48
60
|
end
|
@@ -50,12 +62,38 @@ Usage:
|
|
50
62
|
def select_apps_on_osx
|
51
63
|
prompt = TTY::Prompt.new
|
52
64
|
|
53
|
-
choices =
|
54
|
-
|
65
|
+
choices = osx_application_names
|
66
|
+
|
67
|
+
default_choices = default_choices(choices)
|
68
|
+
|
69
|
+
prompt.multi_select('select all apps for that workstation?', choices, default: default_choices)
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def osx_application_names
|
74
|
+
osx_application_names = %x{ls /applications}.strip
|
75
|
+
|
76
|
+
osx_application_names
|
55
77
|
.gsub(/\n/, ' - ')
|
56
78
|
.gsub('.app', '')
|
57
79
|
.split(' - ')
|
58
|
-
|
80
|
+
end
|
81
|
+
|
82
|
+
def default_choices(choices)
|
83
|
+
return unless option_app_names
|
84
|
+
|
85
|
+
choices
|
86
|
+
.flatten
|
87
|
+
.each_with_object([])
|
88
|
+
.each_with_index do |(choice, memo), index|
|
89
|
+
memo << index + 1 if choice_in_option_app_names?(choice)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def choice_in_option_app_names?(choice)
|
94
|
+
DidYouMean::SpellChecker
|
95
|
+
.new(dictionary: option_app_names)
|
96
|
+
.correct(choice).any?
|
59
97
|
end
|
60
98
|
end
|
61
99
|
end
|
data/lib/chid/github_api.rb
CHANGED
@@ -26,6 +26,15 @@ class GitHubApi
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def self.prs(by:)
|
30
|
+
owner = 'rachidcalazans'
|
31
|
+
repo_name = 'chid'
|
32
|
+
uri = URI("https://api.github.com/repos/#{owner}/#{repo_name}/pulls")
|
33
|
+
request = ::HTTP.get(uri)
|
34
|
+
|
35
|
+
JSON.parse request
|
36
|
+
end
|
37
|
+
|
29
38
|
def self.repositories(search_expression)
|
30
39
|
uri = URI("https://api.github.com/search/repositories?q=#{search_expression}&sort=stars&order=desc")
|
31
40
|
request = ::HTTP.get(uri)
|
data/lib/chid/version.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ::Chid::Commands::Alias::Create, '#run' do
|
4
|
+
let(:alias_command) { ['alias', 'create'] }
|
5
|
+
|
6
|
+
before do
|
7
|
+
reset_bashrc(bashrc_path)
|
8
|
+
override_bashrc_path
|
9
|
+
invoke_run
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:bashrc_path) { File.join(Dir.pwd, 'spec/support/.bashrc') }
|
13
|
+
let(:override_bashrc_path) do
|
14
|
+
allow_any_instance_of(described_class).to receive(:bashrc_path)
|
15
|
+
.and_return(bashrc_path)
|
16
|
+
end
|
17
|
+
let(:invoke_run) do
|
18
|
+
argv = alias_command
|
19
|
+
.concat(arguments)
|
20
|
+
.compact
|
21
|
+
|
22
|
+
Chid::Command.run(argv)
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when given required arguments' do
|
26
|
+
let(:arguments) { ['-command', 'chid workstation open', '-alias', 'cwo'] }
|
27
|
+
|
28
|
+
it 'add alias on .bashrc' do
|
29
|
+
last_line = last_line_at_bashrc(bashrc_path)
|
30
|
+
|
31
|
+
expect(last_line).to eql "alias cwo='chid workstation open'"
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def reset_bashrc(bashrc_path)
|
37
|
+
bash_file = File.open(bashrc_path, 'w') do |file|
|
38
|
+
str = <<~STR
|
39
|
+
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
|
40
|
+
export PATH="$PATH:$HOME/.rvm/bin"
|
41
|
+
export TIDY_KEYS_PATH=/Users/rachidcalazans/Workspaces/tidy-workspace/pem_files
|
42
|
+
export TIDYTOOLS_DIR=~/Workspaces/tidy-workspace/rails-workspace/ops_scripts/tidytools
|
43
|
+
export AWS_USERNAME=rachid
|
44
|
+
# HEY
|
45
|
+
STR
|
46
|
+
file.puts str
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def last_line_at_bashrc(bashrc_path)
|
51
|
+
File
|
52
|
+
.read(bashrc_path)
|
53
|
+
.split("\n").last
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ::Chid::Commands::Pr, '#run', :github, mock: true do
|
4
|
+
let(:invoke_run) do
|
5
|
+
argv = ['pr']
|
6
|
+
argv.concat(arguments)
|
7
|
+
argv.compact!
|
8
|
+
Chid::Command.run(argv)
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'when given an user as arguments' do
|
12
|
+
let(:user) { 'ricmarinovic' }
|
13
|
+
let(:arguments) { ['-user', user] }
|
14
|
+
|
15
|
+
before do |example|
|
16
|
+
allow_github_prs if example.metadata[:mock]
|
17
|
+
|
18
|
+
invoke_run
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:allow_github_prs) do
|
22
|
+
response_prs = [
|
23
|
+
{
|
24
|
+
'number' => 41,
|
25
|
+
'title' => 'Update README',
|
26
|
+
'state' => 'open',
|
27
|
+
'labels' => [],
|
28
|
+
'user' => { 'login' => 'rachidcalazans'}
|
29
|
+
},
|
30
|
+
{
|
31
|
+
'number' => 42,
|
32
|
+
'title' => 'A new PR arrived',
|
33
|
+
'state' => 'open',
|
34
|
+
'labels' => [{'name' => 'in progress'}, {'name' => 'question'}],
|
35
|
+
'user' => { 'login' => user}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
'number' => 43,
|
39
|
+
'title' => 'One more PR',
|
40
|
+
'state' => 'open',
|
41
|
+
'labels' => [{'name' => 'in progress'}],
|
42
|
+
'user' => { 'login' => user}
|
43
|
+
}
|
44
|
+
]
|
45
|
+
allow(GitHubApi).to receive(:prs)
|
46
|
+
.with(by: user)
|
47
|
+
.and_return(response_prs)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'lists all open pull requests' do
|
51
|
+
expected_msg = <<~STR
|
52
|
+
#42 - A new PR arrived
|
53
|
+
By #{user}
|
54
|
+
Status: open
|
55
|
+
Labels: in progress, question
|
56
|
+
|
57
|
+
---
|
58
|
+
|
59
|
+
#43 - One more PR
|
60
|
+
By #{user}
|
61
|
+
Status: open
|
62
|
+
Labels: in progress
|
63
|
+
STR
|
64
|
+
|
65
|
+
expect(invoke_run).to eql(expected_msg)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
# @todo
|
3
|
+
# - [OK] Fix the ChidConfig.on_x for tests
|
4
|
+
# - [OK] Reset support/.chid.config with base template from Init Command or something like that
|
5
|
+
# - [OK] Refactor test code
|
6
|
+
# - [ ] Add feature to given options and arguments with workstation_name and app_names
|
7
|
+
# - chid workstation create -name tt -app_names Safari,iTerm
|
8
|
+
# - [OK] Update test code to reuse setups and contexts
|
9
|
+
# - [OK] Add the app_names option
|
10
|
+
# - [OK] Fix Bug when the workstation_name has `-`. Eg.: -name tt-maris
|
11
|
+
# - [ ] Add description to use with new arguments
|
12
|
+
#
|
13
|
+
|
14
|
+
describe ::Chid::Commands::Workstation::Create do
|
15
|
+
describe '#run' do
|
16
|
+
before do
|
17
|
+
reset_chid_config_file
|
18
|
+
|
19
|
+
set_chid_config_instance
|
20
|
+
|
21
|
+
set_plataform
|
22
|
+
|
23
|
+
set_get_option
|
24
|
+
|
25
|
+
set_multi_select_option
|
26
|
+
|
27
|
+
invoke_run
|
28
|
+
end
|
29
|
+
let(:reset_chid_config_file) do
|
30
|
+
template_data = {
|
31
|
+
chid: {
|
32
|
+
workstations: {},
|
33
|
+
tmux_templates: {}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
File.open(chid_config.chid_config_path, 'w') do |file|
|
38
|
+
YAML.dump(template_data, file)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
let(:set_get_option) { allow(STDIN).to receive(:gets).and_return(workstation_name) }
|
42
|
+
let(:set_multi_select_option) { allow_any_instance_of(TTY::Prompt).to receive(:multi_select).and_return(app_names) }
|
43
|
+
let(:set_chid_config_instance) { allow(::ChidConfig).to receive(:new).and_return chid_config }
|
44
|
+
let(:set_plataform) { allow(::ChidConfig).to receive(:platform).and_return platform_name }
|
45
|
+
|
46
|
+
let(:invoke_run) do
|
47
|
+
argv = ['workstation', 'create']
|
48
|
+
argv.concat(options)
|
49
|
+
argv.compact!
|
50
|
+
|
51
|
+
Chid::Command.run(argv)
|
52
|
+
end
|
53
|
+
|
54
|
+
let(:chid_config) { ::ChidConfig.new(home_base_path: "./spec/support") }
|
55
|
+
let(:load_chid_config_as_yaml) { YAML.load_file chid_config.chid_config_path }
|
56
|
+
|
57
|
+
context 'when given a workstation name' do
|
58
|
+
let(:workstation_name) { 'tt5' }
|
59
|
+
|
60
|
+
context 'when choose an app' do
|
61
|
+
let(:app_names) { %w[Safari] }
|
62
|
+
|
63
|
+
context 'when NOT given any options' do
|
64
|
+
let(:options) { [] }
|
65
|
+
|
66
|
+
context 'when the platform is osx' do
|
67
|
+
let(:platform_name) { 'Darwin' }
|
68
|
+
|
69
|
+
it 'add the new workstation name with choosen app on .chid.config file' do
|
70
|
+
yaml_file = load_chid_config_as_yaml
|
71
|
+
result = yaml_file.dig(:chid, :workstations, :tt5)
|
72
|
+
|
73
|
+
expect(result).to eq %w[Safari]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when given workstation name option' do
|
79
|
+
let(:options) { ['-name', workstation_name] }
|
80
|
+
|
81
|
+
context 'when the platform is osx' do
|
82
|
+
let(:platform_name) { 'Darwin' }
|
83
|
+
|
84
|
+
it 'add the new workstation name with choosen app on .chid.config file' do
|
85
|
+
yaml_file = load_chid_config_as_yaml
|
86
|
+
result = yaml_file.dig(:chid, :workstations, :tt5)
|
87
|
+
|
88
|
+
expect(result).to eq %w[Safari]
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'when workstation name has `-` in the name' do
|
92
|
+
let(:workstation_name) { 'tt5-5' }
|
93
|
+
let(:set_get_option) {}
|
94
|
+
|
95
|
+
it 'add the new workstation name with choosen app on .chid.config file' do
|
96
|
+
yaml_file = load_chid_config_as_yaml
|
97
|
+
result = yaml_file.dig(:chid, :workstations, :'tt5-5')
|
98
|
+
|
99
|
+
expect(result).to eq %w[Safari]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'when given app_names option' do
|
104
|
+
let(:app_names) { %w[Safari iTerm] }
|
105
|
+
let(:options) { ['-name', workstation_name, '-app_names'].concat(app_names) }
|
106
|
+
let(:set_multi_select_option) do
|
107
|
+
ask_msg = 'select all apps for that workstation?'
|
108
|
+
os_app_names = ['1Password 7', 'Accelerate', 'Safari', 'iTerm']
|
109
|
+
|
110
|
+
allow_any_instance_of(::Chid::Commands::Workstation::Create).to receive(:osx_application_names).and_return [os_app_names]
|
111
|
+
|
112
|
+
allow_any_instance_of(TTY::Prompt).to receive(:multi_select)
|
113
|
+
.with(ask_msg, [os_app_names], default: [3,4])
|
114
|
+
.and_return(app_names)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'add all new options on .chid.config file' do
|
118
|
+
yaml_file = load_chid_config_as_yaml
|
119
|
+
result = yaml_file.dig(:chid, :workstations, :tt5)
|
120
|
+
|
121
|
+
expect(result).to eq %w[Safari iTerm]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'when given some wrong app_names option' do
|
126
|
+
let(:app_wrong_name) { 'iTerminal' }
|
127
|
+
let(:app_names) { %W[Safari #{app_wrong_name}] }
|
128
|
+
let(:options) { ['-name', workstation_name, '-app_names'].concat(app_names) }
|
129
|
+
let(:set_multi_select_option) do
|
130
|
+
ask_msg = 'select all apps for that workstation?'
|
131
|
+
os_app_names = ['1Password 7', 'Accelerate', 'Safari', 'iTerm']
|
132
|
+
|
133
|
+
allow_any_instance_of(::Chid::Commands::Workstation::Create).to receive(:osx_application_names).and_return [os_app_names]
|
134
|
+
|
135
|
+
app_correct_names = %w[Safari iTerm]
|
136
|
+
allow_any_instance_of(TTY::Prompt).to receive(:multi_select)
|
137
|
+
.with(ask_msg, [os_app_names], default: [3,4])
|
138
|
+
.and_return(app_correct_names)
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'add all new options on .chid.config file with matched app_names for the wrong app_names' do
|
142
|
+
yaml_file = load_chid_config_as_yaml
|
143
|
+
result = yaml_file.dig(:chid, :workstations, :tt5)
|
144
|
+
|
145
|
+
expect(result).to eq %w[Safari iTerm]
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
|
2
|
+
export PATH="$PATH:$HOME/.rvm/bin"
|
3
|
+
export TIDY_KEYS_PATH=/Users/rachidcalazans/Workspaces/tidy-workspace/pem_files
|
4
|
+
export TIDYTOOLS_DIR=~/Workspaces/tidy-workspace/rails-workspace/ops_scripts/tidytools
|
5
|
+
export AWS_USERNAME=rachid
|
6
|
+
# HEY
|
7
|
+
alias cwo='chid workstation open'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rachid Calazans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -75,6 +75,8 @@ executables:
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
+
- ".ruby-gemset"
|
79
|
+
- ".ruby-version"
|
78
80
|
- CHANGELOG.md
|
79
81
|
- CONTRIBUTING.md
|
80
82
|
- Gemfile
|
@@ -86,6 +88,7 @@ files:
|
|
86
88
|
- lib/chid.rb
|
87
89
|
- lib/chid/chid_config.rb
|
88
90
|
- lib/chid/command.rb
|
91
|
+
- lib/chid/commands/alias/create.rb
|
89
92
|
- lib/chid/commands/config.rb
|
90
93
|
- lib/chid/commands/currency/convert.rb
|
91
94
|
- lib/chid/commands/currency/list.rb
|
@@ -100,6 +103,7 @@ files:
|
|
100
103
|
- lib/chid/commands/installs/rvm.rb
|
101
104
|
- lib/chid/commands/installs/vim.rb
|
102
105
|
- lib/chid/commands/news.rb
|
106
|
+
- lib/chid/commands/pr.rb
|
103
107
|
- lib/chid/commands/stack_overflow.rb
|
104
108
|
- lib/chid/commands/tmux/list.rb
|
105
109
|
- lib/chid/commands/tmux/open.rb
|
@@ -115,9 +119,14 @@ files:
|
|
115
119
|
- lib/chid/stack_overflow_api.rb
|
116
120
|
- lib/chid/version.rb
|
117
121
|
- spec/lib/chid/command_spec.rb
|
122
|
+
- spec/lib/chid/commands/alias/create_spec.rb
|
118
123
|
- spec/lib/chid/commands/init_spec.rb
|
124
|
+
- spec/lib/chid/commands/pr_spec.rb
|
125
|
+
- spec/lib/chid/commands/workstation/create_spec.rb
|
119
126
|
- spec/lib/chid/commands/workstation/open_spec.rb
|
120
127
|
- spec/spec_helper.rb
|
128
|
+
- spec/support/.bashrc
|
129
|
+
- spec/support/.chid.config
|
121
130
|
- tasks/install/yadr_dotfiles.rake
|
122
131
|
- tasks/run/postgres.rake
|
123
132
|
- tasks/update/os.rake
|
@@ -141,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
150
|
- !ruby/object:Gem::Version
|
142
151
|
version: '0'
|
143
152
|
requirements: []
|
144
|
-
rubygems_version: 3.0.
|
153
|
+
rubygems_version: 3.0.8
|
145
154
|
signing_key:
|
146
155
|
specification_version: 4
|
147
156
|
summary: Simple assistant for day-to-day life. Developers and common users
|