chid 0.1.2
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 +7 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +67 -0
- data/README.md +221 -0
- data/Rakefile +17 -0
- data/chid.gemspec +32 -0
- data/etc/img/stack.png +0 -0
- data/lib/chid.rb +100 -0
- data/lib/chid/chid_config.rb +127 -0
- data/lib/chid/currency_api.rb +69 -0
- data/lib/chid/github_api.rb +41 -0
- data/lib/chid/main.rb +112 -0
- data/lib/chid/news_api.rb +60 -0
- data/lib/chid/paginator.rb +57 -0
- data/lib/chid/stack_overflow_api.rb +35 -0
- data/lib/chid/version.rb +3 -0
- data/lib/chid/yandex_translate_api.rb +39 -0
- data/tasks/chid/config.rake +5 -0
- data/tasks/chid/init.rake +19 -0
- data/tasks/chid/start.rake +26 -0
- data/tasks/chid/update.rake +14 -0
- data/tasks/currency/convert.rake +9 -0
- data/tasks/currency/current.rake +11 -0
- data/tasks/currency/list.rake +10 -0
- data/tasks/github.rake +12 -0
- data/tasks/help.rake +8 -0
- data/tasks/install/node.rake +18 -0
- data/tasks/install/postgres.rake +18 -0
- data/tasks/install/rvm.rake +21 -0
- data/tasks/install/yadr_dotfiles.rake +26 -0
- data/tasks/news.rake +11 -0
- data/tasks/run/postgres.rake +12 -0
- data/tasks/stack_overflow.rake +20 -0
- data/tasks/tmux/config_windows.rake +21 -0
- data/tasks/tmux/new_session.rake +10 -0
- data/tasks/translate/yandex_list.rake +7 -0
- data/tasks/translate/yandex_translate.rake +8 -0
- data/tasks/update/os.rake +14 -0
- data/tasks/workstation/create.rake +23 -0
- data/tasks/workstation/destroy.rake +14 -0
- data/tasks/workstation/list.rake +10 -0
- data/tasks/workstation/open.rake +29 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3aae1808f491122b975bde5b3e22278c3a0889fc
|
4
|
+
data.tar.gz: d5a02abb8cc2cfcb8a23eed38a82f0a4a18824ea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 198c1152cf1f5159e4e6eea999e17d73b11346d92a3acb9eb7c2f665a14067e9b2d75e94cfbe3ef0d490b6eb2c22d3ba6fca65e08ee70cfe2fdbf79ae11f275f
|
7
|
+
data.tar.gz: 5027cbaf7d3ee500354ac181abd383322130b2cffcaf879d061771711c379e1558b90bf10864392acba59313099124e9d7aceb3f7336b27e366831429d40e4ad
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
chid (0.1.1)
|
5
|
+
easy_translate
|
6
|
+
http
|
7
|
+
rake
|
8
|
+
tty-prompt
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.5.0)
|
14
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
15
|
+
coderay (1.1.1)
|
16
|
+
domain_name (0.5.20170223)
|
17
|
+
unf (>= 0.0.5, < 1.0.0)
|
18
|
+
easy_translate (0.5.0)
|
19
|
+
json
|
20
|
+
thread
|
21
|
+
thread_safe
|
22
|
+
equatable (0.5.0)
|
23
|
+
http (2.2.1)
|
24
|
+
addressable (~> 2.3)
|
25
|
+
http-cookie (~> 1.0)
|
26
|
+
http-form_data (~> 1.0.1)
|
27
|
+
http_parser.rb (~> 0.6.0)
|
28
|
+
http-cookie (1.0.3)
|
29
|
+
domain_name (~> 0.5)
|
30
|
+
http-form_data (1.0.1)
|
31
|
+
http_parser.rb (0.6.0)
|
32
|
+
json (2.0.3)
|
33
|
+
method_source (0.8.2)
|
34
|
+
necromancer (0.4.0)
|
35
|
+
pastel (0.7.1)
|
36
|
+
equatable (~> 0.5.0)
|
37
|
+
tty-color (~> 0.4.0)
|
38
|
+
pry (0.10.4)
|
39
|
+
coderay (~> 1.1.0)
|
40
|
+
method_source (~> 0.8.1)
|
41
|
+
slop (~> 3.4)
|
42
|
+
public_suffix (2.0.5)
|
43
|
+
rake (12.0.0)
|
44
|
+
slop (3.6.0)
|
45
|
+
thread (0.2.2)
|
46
|
+
thread_safe (0.3.6)
|
47
|
+
tty-color (0.4.2)
|
48
|
+
tty-cursor (0.4.0)
|
49
|
+
tty-prompt (0.11.0)
|
50
|
+
necromancer (~> 0.4.0)
|
51
|
+
pastel (~> 0.7.0)
|
52
|
+
tty-cursor (~> 0.4.0)
|
53
|
+
wisper (~> 1.6.1)
|
54
|
+
unf (0.1.4)
|
55
|
+
unf_ext
|
56
|
+
unf_ext (0.0.7.2)
|
57
|
+
wisper (1.6.1)
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
ruby
|
61
|
+
|
62
|
+
DEPENDENCIES
|
63
|
+
chid!
|
64
|
+
pry
|
65
|
+
|
66
|
+
BUNDLED WITH
|
67
|
+
1.14.6
|
data/README.md
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
# Chid
|
2
|
+
Chid is an assistant to help your day-to-day life. It can be used in some
|
3
|
+
installations, news, configurations, workstations and more.
|
4
|
+
|
5
|
+

|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
To get started follow those steps:
|
10
|
+
|
11
|
+
1- Clone the project:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
git clone https://github.com/rachidcalazans/chid.git
|
15
|
+
```
|
16
|
+
|
17
|
+
2- Install the dependcy if you do not have already installed:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ gem install bundler
|
21
|
+
$ bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
3- Inside the folder project run:
|
25
|
+
|
26
|
+
```bash
|
27
|
+
$ rake init
|
28
|
+
```
|
29
|
+
|
30
|
+
**Note:** Chid will automatically install a *.chid.config* file and create an
|
31
|
+
alias on your **.bashrc** or **.zshrc** (if you have zsh installed). After the
|
32
|
+
installation **Chid** will give you the *bash command* to reload your **sources**
|
33
|
+
file.
|
34
|
+
|
35
|
+
## Upgrading
|
36
|
+
|
37
|
+
To update the chid is easy.
|
38
|
+
|
39
|
+
```bash
|
40
|
+
$ chid update
|
41
|
+
```
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
**Chid** is an app based on **Rake Tasks**. You are available to use all features
|
46
|
+
as rake tasks or run as a **terminal app**:
|
47
|
+
|
48
|
+
**Note:** All tasks are available for **osx** and **linux**. The *chid* will automatically
|
49
|
+
knows how run the specific **comand** for each plataform.
|
50
|
+
|
51
|
+
All features are listed bellow:
|
52
|
+
|
53
|
+
#### Install chid configuration
|
54
|
+
|
55
|
+
* `$ chid init` - Will install all necessary confiuration.
|
56
|
+
|
57
|
+
#### Start the app
|
58
|
+
|
59
|
+
* `$ chid` - To start the **chid** terminal app
|
60
|
+
|
61
|
+
**Note:** To run the commands listed bellow you must started the chid app.
|
62
|
+
|
63
|
+
#### Help
|
64
|
+
|
65
|
+
* `help` or `:h` - Show all tasks available
|
66
|
+
|
67
|
+
#### Quit
|
68
|
+
|
69
|
+
* `:q` or `quit` or `bye` or `exit` - Will finish the **chid** app
|
70
|
+
|
71
|
+
#### Currency
|
72
|
+
|
73
|
+
* `current` - Get the current conversion for USD to BRL amount
|
74
|
+
* `currency list` - Show all types of currencies available to convert
|
75
|
+
* `convert [amount] [type_from] to [type_to]` - You can convert an amount between
|
76
|
+
types. Eg.: **convert 10 USD to BRL**
|
77
|
+
|
78
|
+
#### Install apps
|
79
|
+
|
80
|
+
**Note:** All install tasks, chid will always ask if you really want to install it. Also
|
81
|
+
will install the dependencies if necessary.
|
82
|
+
|
83
|
+
* `install dotfiles` - Install [YADR Dotfiles](https://github.com/skwp/dotfiles)
|
84
|
+
* `install node` - Install Node
|
85
|
+
* `install postgres` - Install Postgres
|
86
|
+
* `install rvm` - Install stable RVM version
|
87
|
+
|
88
|
+
#### Run
|
89
|
+
|
90
|
+
* `run postgres` - Run the postgresql if you already have installed.
|
91
|
+
|
92
|
+
#### Update
|
93
|
+
|
94
|
+
* `update os` or `update` - Will update the linux os. For osx is not available
|
95
|
+
|
96
|
+
#### News
|
97
|
+
|
98
|
+
* `news` - Will show all news from some sites. BBC news, CNN, Espn,
|
99
|
+
Mashable, Google, Techcrunch, Reddit
|
100
|
+
|
101
|
+
#### Translate
|
102
|
+
|
103
|
+
* `t [TEXT]` or `t [TEXT] [FROM] to [TO]` - Will translate the given text. By
|
104
|
+
default the **from** is **en** and **to** is **pt**
|
105
|
+
|
106
|
+
Example:
|
107
|
+
`t hello world` or `t hello world en to pt`
|
108
|
+
|
109
|
+
#### Search on StackOverflow
|
110
|
+
|
111
|
+
A simple search in StackOverflow
|
112
|
+
|
113
|
+
* `stack [TEXT_TO_SEACH]` - Will search on StackOverflow all results for that
|
114
|
+
text.
|
115
|
+
|
116
|
+
* `stack` - Will ask what you want to search on StackOverflow all results for that
|
117
|
+
|
118
|
+
<p align="left">
|
119
|
+
<img src="etc/img/stack.png" alt="stack sample" />
|
120
|
+
</p>
|
121
|
+
|
122
|
+
#### Search GitHub repositories
|
123
|
+
|
124
|
+
A simple search for repository name
|
125
|
+
|
126
|
+
* `github [SEARCH_EXPRESSION]` - Show results for expression paginated every 10
|
127
|
+
|
128
|
+
#### Workstations
|
129
|
+
|
130
|
+
Workstations are a way to make it easy for you to open a set of applications by
|
131
|
+
simple commands.
|
132
|
+
|
133
|
+
The set of configurations are saved on **.chid.config** file.
|
134
|
+
|
135
|
+
**Note:** All commands bellow is possible run with prefix: `workstation [command]`
|
136
|
+
or `work [command]`.
|
137
|
+
|
138
|
+
* `work list` - List all workstations
|
139
|
+
* `work create` - Create a new workstation. Chid will ask for a name to set the
|
140
|
+
new workstation and after that will list all **applications** available on your
|
141
|
+
system to chosse witch one you wanna add
|
142
|
+
* `work destroy` - Chid will ask which workstation you want to destroy and chid
|
143
|
+
will destroy it after choose
|
144
|
+
* `work open` - Open a specific workstation. Chid will list all workstations to
|
145
|
+
choose one of them to open all applications
|
146
|
+
* `work open [workstation_name]` - Open a specific workstation without choose
|
147
|
+
from a list. Eg.: `work open base` - It will open all applications inside the
|
148
|
+
**base** workstation
|
149
|
+
|
150
|
+

|
151
|
+
|
152
|
+
**Note:** For linux users the **work create** is not working. You need create
|
153
|
+
manually (editing the .chid.config file). Will be explained how on
|
154
|
+
**How configure and customize your workstations** topic
|
155
|
+
|
156
|
+
#### Chid configuration
|
157
|
+
|
158
|
+
* `chid config` or `config` - Open the **.chid.config** file
|
159
|
+
|
160
|
+
## How configure and customize your workstations
|
161
|
+
|
162
|
+
The chid configuration file is installed on **~/.chid.config**. You can open: `$ chid
|
163
|
+
chid_config`
|
164
|
+
|
165
|
+
Chid config is a **YAML** file.
|
166
|
+
|
167
|
+
You can create the workstations just adding on :workstations: key.
|
168
|
+
|
169
|
+
The initial chid config file will be like:
|
170
|
+
|
171
|
+
```YAML
|
172
|
+
---
|
173
|
+
:chid:
|
174
|
+
:chid_path: "[CHID_FOLDER_PROJECT_PATH]"
|
175
|
+
:workstations: {}
|
176
|
+
```
|
177
|
+
|
178
|
+
#### Base configuration
|
179
|
+
|
180
|
+
To add a new *workstation* you can edit like:
|
181
|
+
|
182
|
+
```YAML
|
183
|
+
---
|
184
|
+
:chid:
|
185
|
+
:chid_path: "[CHID_FOLDER_PROJECT_PATH]"
|
186
|
+
:workstations:
|
187
|
+
:base: # Workstation Name
|
188
|
+
- iTerm #Application Name
|
189
|
+
- Safari
|
190
|
+
- Slack
|
191
|
+
```
|
192
|
+
|
193
|
+
After edit you can open the **base** workstation running:
|
194
|
+
|
195
|
+
* `$ chid workstation:open['base']` - As rake task
|
196
|
+
* `work open base` - With the **chid** app running
|
197
|
+
|
198
|
+

|
199
|
+
|
200
|
+
#### Advance configuration
|
201
|
+
|
202
|
+
Is possible you can customize some options with each Application when will open it
|
203
|
+
|
204
|
+
- Open the Terminal in a specific folder
|
205
|
+
- Open a Safari with a specific URL
|
206
|
+
- Any options which your application can use
|
207
|
+
|
208
|
+
```YAML
|
209
|
+
---
|
210
|
+
:chid:
|
211
|
+
:chid_path: "[CHID_FOLDER_PROJECT_PATH]"
|
212
|
+
:workstations:
|
213
|
+
:base: # Workstation Name
|
214
|
+
- iTerm ~/Workspaces/rake-workspace/chid/ & rake tmux_config # Will open
|
215
|
+
# in a specific folder and will run some Rake Task
|
216
|
+
- Safari https://github.com/rachidcalazans/chid # Will open the Safari
|
217
|
+
# in a specific URL
|
218
|
+
```
|
219
|
+
|
220
|
+

|
221
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Require all files inside the lib folder only
|
2
|
+
%w(lib).each do |inc|
|
3
|
+
dir = File.join(File.dirname(__FILE__), inc)
|
4
|
+
glob = Dir.glob(dir + "/*.rb")
|
5
|
+
glob.each { |r| require r }
|
6
|
+
end
|
7
|
+
|
8
|
+
# Load all rake tasks inside the tasks folder
|
9
|
+
dir = File.join(File.dirname(__FILE__), 'tasks')
|
10
|
+
glob = Dir.glob(dir + "/**/*.rake")
|
11
|
+
glob.each { |r| load r }
|
12
|
+
|
13
|
+
|
14
|
+
# Initialize the default variable to use on all rake tasks
|
15
|
+
@chid_config = ChidConfig.new
|
16
|
+
|
17
|
+
task :default => :chid
|
data/chid.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chid/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "chid"
|
8
|
+
spec.version = Chid::VERSION
|
9
|
+
spec.authors = ["Rachid Calazans"]
|
10
|
+
spec.summary = "Simple assistant for day-to-day life. Developers and common users"
|
11
|
+
spec.email = ["rachidcalazans@gmail.com"]
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.homepage = "https://github.com/rachidcalazans/chid"
|
14
|
+
spec.description = "Chid is an assistant to help your day-to-day life. It can be used in some installations, news, configurations, workstations and more."
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
#spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib", "tasks"]
|
20
|
+
|
21
|
+
spec.add_development_dependency 'pry'
|
22
|
+
|
23
|
+
# Tasks runner
|
24
|
+
spec.add_dependency 'rake'
|
25
|
+
# Simple HTTP request
|
26
|
+
spec.add_runtime_dependency 'http'
|
27
|
+
# Prompt utils
|
28
|
+
spec.add_dependency 'tty-prompt'
|
29
|
+
# Google translate
|
30
|
+
spec.add_dependency 'easy_translate'
|
31
|
+
|
32
|
+
end
|
data/etc/img/stack.png
ADDED
Binary file
|
data/lib/chid.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'tty-prompt'
|
3
|
+
require 'http'
|
4
|
+
require 'easy_translate'
|
5
|
+
|
6
|
+
# Require all files inside the chid folder
|
7
|
+
dir = File.join(File.dirname(__FILE__))
|
8
|
+
glob = Dir.glob(dir + "/chid/*.rb")
|
9
|
+
glob.each { |r| require r }
|
10
|
+
|
11
|
+
module Chid
|
12
|
+
|
13
|
+
# The Regex Actions are used to execute automatically some Rake::Task
|
14
|
+
#
|
15
|
+
# The Keys are the name of the task
|
16
|
+
#
|
17
|
+
# The Values are a list of possile matchs (even Rake::TaskArguments) from a
|
18
|
+
# typed text
|
19
|
+
#
|
20
|
+
# Example 1:
|
21
|
+
#
|
22
|
+
# :hello => [/hail/]
|
23
|
+
#
|
24
|
+
# That means must exist a Rake::Task called :hello and when
|
25
|
+
# typed 'hail' the app will match with the value of the array and will execute
|
26
|
+
# the Rake::Task[:hello]
|
27
|
+
#
|
28
|
+
# Example 2:
|
29
|
+
#
|
30
|
+
# :'install:dotfiles' => [/install dotfiles/]
|
31
|
+
#
|
32
|
+
# In that case the key has a namespace (install) and a task name (dotfiles)
|
33
|
+
#
|
34
|
+
#
|
35
|
+
# If you want to pass some argument you can use the Capture Enclosed option on
|
36
|
+
# regex.
|
37
|
+
#
|
38
|
+
# Example 3:
|
39
|
+
#
|
40
|
+
# :hello => [/hail\s(.*)/]
|
41
|
+
#
|
42
|
+
# That means the captured arguments to use on Rake::Task is inside the '()'. In
|
43
|
+
# that case any characteres typed after 'hail ' will be used as Rake::TaskArguments
|
44
|
+
|
45
|
+
REGEX_ACTIONS = {
|
46
|
+
:help => [/help/, /:h/],
|
47
|
+
:chid_config => [/config.*/, /chid config.*/],
|
48
|
+
:news => [/news/],
|
49
|
+
:'currency:list' => [/^list$/, /^list currency$/, /^currency$/, /^currency list$/],
|
50
|
+
:'currency:convert' => [/^conv.*\s(\d*.?\d+?)\s(\w{3})\sto\s(\w{3})/, /^currency/],
|
51
|
+
:'currency:current' => [/current/, /^currency/, /current currency/],
|
52
|
+
:'install:rvm' => [/install rvm/],
|
53
|
+
:'install:postgres' => [/install postgres/],
|
54
|
+
:'install:dotfiles' => [/install dotfile/, /install dotfiles/, /install yard/],
|
55
|
+
:'install:node' => [/install node/],
|
56
|
+
:'run:postgres' => [/run postgres/],
|
57
|
+
:'workstation:list' => [/^workstation/, /^work$/, /^list$/, /^list workstation$/, /^list work$/, /^work list$/],
|
58
|
+
:'workstation:open' => [/^workstation/, /^work$/, /^work open$/, /^open workstation/, /^open work$/,
|
59
|
+
/^open work\s(.+)/, /^open\s(.+)/, /^work open\s(.+)/],
|
60
|
+
:'workstation:create' => [/^workstation/, /^work$/, /create/, /create workstation/, /create work/],
|
61
|
+
:'workstation:destroy' => [/^workstation/, /^work$/, /destroy/, /destroy workstation/,
|
62
|
+
/destroy work/, /remove/, /remove workstation/, /remove work/],
|
63
|
+
:'update:os' => [/update os/, /update/],
|
64
|
+
:'stack' => [/^stack\s(.*)/, /^stack/],
|
65
|
+
:'translate:yandex_translate' => [/^t\s(.*)\s(\w{2})\sto\s(\w{2})/, /^t\s(.*)/ ],
|
66
|
+
:'translate:yandex_list' => [/^translate list/ ],
|
67
|
+
:github => [/^github\s(.+)/]
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
# Add styles for String class
|
74
|
+
class String
|
75
|
+
def black; "\e[30m#{self}\e[0m" end
|
76
|
+
def red; "\e[31m#{self}\e[0m" end
|
77
|
+
def green; "\e[32m#{self}\e[0m" end
|
78
|
+
def brown; "\e[33m#{self}\e[0m" end
|
79
|
+
def blue; "\e[34m#{self}\e[0m" end
|
80
|
+
def magenta; "\e[35m#{self}\e[0m" end
|
81
|
+
def cyan; "\e[36m#{self}\e[0m" end
|
82
|
+
def gray; "\e[37m#{self}\e[0m" end
|
83
|
+
|
84
|
+
def bg_black; "\e[40m#{self}\e[0m" end
|
85
|
+
def bg_red; "\e[41m#{self}\e[0m" end
|
86
|
+
def bg_green; "\e[42m#{self}\e[0m" end
|
87
|
+
def bg_brown; "\e[43m#{self}\e[0m" end
|
88
|
+
def bg_blue; "\e[44m#{self}\e[0m" end
|
89
|
+
def bg_magenta; "\e[45m#{self}\e[0m" end
|
90
|
+
def bg_cyan; "\e[46m#{self}\e[0m" end
|
91
|
+
def bg_gray; "\e[47m#{self}\e[0m" end
|
92
|
+
|
93
|
+
def bold; "\e[1m#{self}\e[22m" end
|
94
|
+
def italic; "\e[3m#{self}\e[23m" end
|
95
|
+
def underline; "\e[4m#{self}\e[24m" end
|
96
|
+
def blink; "\e[5m#{self}\e[25m" end
|
97
|
+
def reverse_color; "\e[7m#{self}\e[27m" end
|
98
|
+
end
|
99
|
+
|
100
|
+
|