chid 0.1.6.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/CONTRIBUTING.md +75 -1
  4. data/Gemfile.lock +23 -36
  5. data/README.md +129 -79
  6. data/bin/chid +2 -25
  7. data/chid.gemspec +0 -6
  8. data/lib/chid.rb +0 -66
  9. data/lib/chid/chid_config.rb +4 -81
  10. data/lib/chid/commands/config.rb +48 -0
  11. data/lib/chid/commands/currency/convert.rb +50 -0
  12. data/lib/chid/commands/currency/list.rb +34 -0
  13. data/lib/chid/commands/currency/now.rb +47 -0
  14. data/lib/chid/commands/gitflow/commit.rb +0 -1
  15. data/lib/chid/commands/github.rb +40 -0
  16. data/lib/chid/commands/init.rb +1 -2
  17. data/lib/chid/commands/install.rb +1 -0
  18. data/lib/chid/commands/installs/dotfile.rb +1 -1
  19. data/lib/chid/commands/installs/node.rb +2 -2
  20. data/lib/chid/commands/installs/postgres.rb +2 -2
  21. data/lib/chid/commands/installs/rvm.rb +2 -2
  22. data/lib/chid/commands/installs/vim.rb +2 -2
  23. data/lib/chid/version.rb +1 -1
  24. data/spec/lib/chid/commands/init_spec.rb +4 -2
  25. data/tasks/install/yadr_dotfiles.rake +1 -0
  26. data/tasks/run/postgres.rake +1 -0
  27. data/tasks/update/os.rake +1 -0
  28. metadata +7 -52
  29. data/#README.md# +0 -222
  30. data/Rakefile +0 -18
  31. data/lib/chid/yandex_translate_api.rb +0 -39
  32. data/tasks/chid/config.rake +0 -5
  33. data/tasks/chid/init.rake +0 -19
  34. data/tasks/chid/install.rake +0 -14
  35. data/tasks/chid/start.rake +0 -26
  36. data/tasks/chid/update.rake +0 -14
  37. data/tasks/currency/convert.rake +0 -9
  38. data/tasks/currency/current.rake +0 -11
  39. data/tasks/currency/list.rake +0 -10
  40. data/tasks/github.rake +0 -12
  41. data/tasks/help.rake +0 -178
  42. data/tasks/install/node.rake +0 -18
  43. data/tasks/install/postgres.rake +0 -18
  44. data/tasks/install/rvm.rake +0 -21
  45. data/tasks/news.rake +0 -11
  46. data/tasks/stack_overflow.rake +0 -20
  47. data/tasks/tmux/config_windows.rake +0 -8
  48. data/tasks/tmux/new_session.rake +0 -9
  49. data/tasks/translate/yandex_list.rake +0 -7
  50. data/tasks/translate/yandex_translate.rake +0 -8
data/Rakefile DELETED
@@ -1,18 +0,0 @@
1
- #require 'chid'
2
- # Require all files inside the lib folder only
3
- #%w(lib).each do |inc|
4
- # dir = File.join(File.dirname(__FILE__), inc)
5
- # glob = Dir.glob(dir + "/*.rb")
6
- # glob.each { |r| require r }
7
- #end
8
- #
9
- # Load all rake tasks inside the tasks folder
10
- #dir = File.join(File.dirname(__FILE__), 'tasks')
11
- #glob = Dir.glob(dir + "/**/*.rake")
12
- #glob.each { |r| load r }
13
-
14
-
15
- # Initialize the default variable to use on all rake tasks
16
- #@chid_config = ChidConfig.new
17
-
18
- task :default => :chid
@@ -1,39 +0,0 @@
1
- class YandexTranslateApi
2
- API_TOKEN = 'trnsl.1.1.20170318T165136Z.005f29f713d3e410.1d52e55d7e9a3f125e38645215a101e743b16b98'
3
-
4
- def self.translate(options = {})
5
- text = options.fetch(:text, "")
6
- from = options.fetch(:from, :en).to_sym
7
- to = options.fetch(:to, :pt).to_sym
8
-
9
- uri = URI("https://translate.yandex.net/api/v1.5/tr.json/translate?lang=#{from}-#{to}&key=#{API_TOKEN}&text=#{text}")
10
-
11
- response = HTTP.get(uri)
12
- json = JSON.parse response
13
- json['text'].first
14
- end
15
-
16
- def self.list
17
- puts "Language Code Language Code".green
18
- puts "Azerbaijan az Maltese mt"
19
- puts "Albanian sq Macedonian mk"
20
- puts "Amharic am Maori mi"
21
- puts "English en Marathi mr"
22
- puts "Armenian hy Mongolian mn"
23
- puts "Afrikaans af German de"
24
- puts "Bashkir ba Norwegian no"
25
- puts "Bulgarian bg Persian fa"
26
- puts "Bosnian bs Polish pl"
27
- puts "Welsh cy Portuguese pt"
28
- puts "Vietnamese vi Russian ru"
29
- puts "Italian it Telugu te"
30
- puts "Spanish es Udmurt udm"
31
- puts "Chinese zh French fr"
32
- puts "Xhosa xh Croatian hr"
33
- puts "Latin la Czech cs"
34
- puts "Latvian lv Swedish sv"
35
- puts "Lithuanian lt Scottish gd"
36
- puts "Luxembourgish lb Estonian et"
37
- end
38
-
39
- end
@@ -1,5 +0,0 @@
1
- desc 'Open the .chid.config file'
2
- task :chid_config do
3
- puts "\nOpening the .chid.config..."
4
- system("vim #{@chid_config.chid_config_path}")
5
- end
@@ -1,19 +0,0 @@
1
- desc 'Initial configuration for Chid app'
2
- task :init do
3
- print "Chid is an assistant to help your day-to-day life.\n\n"
4
- print "You can use it as "
5
- print "a terminal App ".green
6
- print "or through "
7
- print "Rake Tasks".green
8
- print", having a greater interaction with it.\n\n"
9
-
10
- print "To initialize the app you can run the command: "
11
- print "$ rake\n".blue
12
- print "Or the command: "
13
- print "$ chid\n".blue
14
- print "But the command "
15
- print "$ chid ".blue
16
- print "will work after you reload your profile\n"
17
-
18
- @chid_config.configure
19
- end
@@ -1,14 +0,0 @@
1
- desc 'Initial configuration for Chid app'
2
- task :install do
3
- print "Chid is an assistant to help your day-to-day life.\n\n"
4
- print "You can use it as "
5
- print "a terminal App ".green
6
- print "or through "
7
- print "Rake Tasks".green
8
- print", having a greater interaction with it.\n\n"
9
-
10
- print "To initialize the app you can run the command: "
11
- print "$ chid\n".blue
12
-
13
- @chid_config.configure_chid_file_only
14
- end
@@ -1,26 +0,0 @@
1
- desc 'Start the Chid app'
2
- task :chid do
3
- prompt = TTY::Prompt.new(help_color: :green)
4
- confirm_install = -> (action, &block) {
5
- matched = /^install:(.*)/.match(action)
6
- return block.() unless matched
7
-
8
- action_name = matched.captures.first
9
- if prompt.yes?("Can I install the #{action_name}?")
10
- block.()
11
- else
12
- puts "\nNo problem. What do you need?"
13
- end
14
- }
15
-
16
- Main.new(@chid_config).init do |action, args|
17
- rake_task = Rake::Task[action]
18
- task_args = Rake::TaskArguments.new(rake_task.arg_names, args)
19
-
20
- confirm_install.(action) do
21
- rake_task.execute(task_args)
22
- end
23
-
24
- puts "\nDone! What else?"
25
- end
26
- end
@@ -1,14 +0,0 @@
1
- desc 'Update Chid'
2
- task :update do
3
- puts 'Updating Chid...'
4
- path = "#{@chid_config.chid_rake_path}"
5
- Dir.chdir path do |p|
6
- system('git pull --rebase')
7
- end
8
-
9
- @chid_config.configure
10
-
11
- puts "\nChid updated successfully"
12
- end
13
-
14
-
@@ -1,9 +0,0 @@
1
- namespace :currency do
2
-
3
- desc 'You can convert an amount between types. Eg.: convert 10 USD to BRL'
4
- task :convert, [:amount, :from, :to] do |t, args|
5
- amount = CurrencyApi.convert(args)
6
- puts "The converted #{args[:from]} to #{args[:to]} is: #{amount}"
7
- end
8
-
9
- end
@@ -1,11 +0,0 @@
1
- namespace :currency do
2
-
3
- desc 'Get the current conversion for USD to BRL'
4
- task :current do
5
- currency = CurrencyApi.convert()
6
- puts "USD is #{currency} BRL"
7
- end
8
-
9
- end
10
-
11
-
@@ -1,10 +0,0 @@
1
- namespace :currency do
2
-
3
- desc 'Show all types of currencies'
4
- task :list do
5
- types = CurrencyApi::SOURCES
6
- puts "Types available:\n\n"
7
- types.each { |k, v| puts "#{k} => #{v}"}
8
- end
9
-
10
- end
@@ -1,12 +0,0 @@
1
- desc 'List all repositories'
2
- task :github, [:search] do |t, args|
3
- search_expression = args[:search]
4
-
5
- repositories = GitHubApi.repositories(search_expression)
6
-
7
- Paginator.new(repositories).paginate do |repository|
8
- repository.summary
9
- end
10
- end
11
-
12
-
@@ -1,178 +0,0 @@
1
- desc 'Show all tasks availabe'
2
- task :help do
3
- #Dir.chdir @chid_config.chid_rake_path
4
- #system("rake -T")
5
- puts "\nTell me what you need"
6
-
7
- a = <<MY
8
- # Chid
9
-
10
- **Note:** All tasks are available for **osx** and **linux**. The *chid* will automatically
11
- knows how run the specific **comand** for each plataform.
12
-
13
- #### Install chid configuration
14
-
15
- * `$ chid init` - Will install all necessary confiuration.
16
-
17
- #### Start the app
18
-
19
- * `$ chid` - To start the **chid** terminal app
20
-
21
- **Note:** To run the commands listed bellow you must started the chid app.
22
-
23
- #### Help
24
-
25
- * `help` or `:h` - Show all tasks available
26
-
27
- #### Quit
28
-
29
- * `:q` or `quit` or `bye` or `exit` - Will finish the **chid** app
30
-
31
- #### Currency
32
-
33
- * `current` - Get the current conversion for USD to BRL amount
34
- * `currency list` - Show all types of currencies available to convert
35
- * `convert [amount] [type_from] to [type_to]` - You can convert an amount between
36
- types. Eg.: **convert 10 USD to BRL**
37
-
38
- #### Install apps
39
-
40
- **Note:** All install tasks, chid will always ask if you really want to install it. Also
41
- will install the dependencies if necessary.
42
-
43
- * `install dotfiles` - Install [YADR Dotfiles](https://github.com/skwp/dotfiles)
44
- * `install node` - Install Node
45
- * `install postgres` - Install Postgres
46
- * `install rvm` - Install stable RVM version
47
-
48
- #### Run
49
-
50
- * `run postgres` - Run the postgresql if you already have installed.
51
-
52
- #### Update
53
-
54
- * `update os` or `update` - Will update the linux os. For osx is not available
55
-
56
- #### News
57
-
58
- * `news` - Will show all news from some sites. BBC news, CNN, Espn,
59
- Mashable, Google, Techcrunch, Reddit
60
-
61
- #### Translate
62
-
63
- * `t [TEXT]` or `t [TEXT] [FROM] to [TO]` - Will translate the given text. By
64
- default the **from** is **en** and **to** is **pt**
65
-
66
- Example:
67
- `t hello world` or `t hello world en to pt`
68
-
69
- #### Search on StackOverflow
70
-
71
- A simple search in StackOverflow
72
-
73
- * `stack [TEXT_TO_SEACH]` - Will search on StackOverflow all results for that
74
- text.
75
-
76
- * `stack` - Will ask what you want to search on StackOverflow all results for that
77
-
78
- #### Search GitHub repositories
79
-
80
- A simple search for repository name
81
-
82
- * `github [SEARCH_EXPRESSION]` - Show results for expression paginated every 10
83
-
84
- #### Workstations
85
-
86
- Workstations are a way to make it easy for you to open a set of applications by
87
- simple commands.
88
-
89
- The set of configurations are saved on **.chid.config** file.
90
-
91
- **Note:** All commands bellow is possible run with prefix: `workstation [command]`
92
- or `work [command]`.
93
-
94
- * `work list` - List all workstations
95
- * `work create` - Create a new workstation. Chid will ask for a name to set the
96
- new workstation and after that will list all **applications** available on your
97
- system to chosse witch one you wanna add
98
- * `work destroy` - Chid will ask which workstation you want to destroy and chid
99
- will destroy it after choose
100
- * `work open` - Open a specific workstation. Chid will list all workstations to
101
- choose one of them to open all applications
102
- * `work open [workstation_name]` - Open a specific workstation without choose
103
- from a list. Eg.: `work open base` - It will open all applications inside the
104
- **base** workstation
105
-
106
- **Note:** For linux users the **work create** is not working. You need create
107
- manually (editing the .chid.config file). Will be explained how on
108
- **How configure and customize your workstations** topic
109
-
110
- #### Chid configuration
111
-
112
- * `chid config` or `config` - Open the **.chid.config** file
113
-
114
- ## How configure and customize your workstations
115
-
116
- The chid configuration file is installed on **~/.chid.config**. You can open: `$ chid
117
- chid_config`
118
-
119
- Chid config is a **YAML** file.
120
-
121
- You can create the workstations just adding on :workstations: key.
122
-
123
- The initial chid config file will be like:
124
-
125
- ```YAML
126
- ---
127
- :chid:
128
- :chid_path: "[CHID_FOLDER_PROJECT_PATH]"
129
- :workstations: {}
130
- ```
131
-
132
- #### Base configuration
133
-
134
- To add a new *workstation* you can edit like:
135
-
136
- ```YAML
137
- ---
138
- :chid:
139
- :chid_path: "[CHID_FOLDER_PROJECT_PATH]"
140
- :workstations:
141
- :base: # Workstation Name
142
- - iTerm #Application Name
143
- - Safari
144
- - Slack
145
- ```
146
-
147
- After edit you can open the **base** workstation running:
148
-
149
- * `$ chid workstation:open['base']` - As rake task
150
- * `work open base` - With the **chid** app running
151
-
152
- #### Advance configuration
153
-
154
- Is possible you can customize some options with each Application when will open it
155
-
156
- - Open the Terminal in a specific folder
157
- - Open a Safari with a specific URL
158
- - Any options which your application can use
159
-
160
- ```YAML
161
- ---
162
- :chid:
163
- :chid_path: "[CHID_FOLDER_PROJECT_PATH]"
164
- :workstations:
165
- :base: # Workstation Name
166
- - iTerm ~/Workspaces/rake-workspace/chid/ & rake tmux_config # Will open
167
- # in a specific folder and will run some Rake Task
168
- - Safari https://github.com/rachidcalazans/chid # Will open the Safari
169
- # in a specific URL
170
- ```
171
-
172
- MY
173
-
174
- puts a
175
-
176
- end
177
-
178
-
@@ -1,18 +0,0 @@
1
- namespace :install do
2
-
3
- desc 'Install Node'
4
- task :node do
5
- puts "\nInstalling the Node..."
6
-
7
- @chid_config.on_linux do
8
- system('sudo apt-get install nodejs')
9
- end
10
-
11
- @chid_config.on_osx do
12
- system('brew install node')
13
- end
14
-
15
- puts "\nNode installed successfully"
16
- end
17
-
18
- end
@@ -1,18 +0,0 @@
1
- namespace :install do
2
-
3
- desc 'Install Postgres'
4
- task :postgres do
5
- puts "\nInstalling the Postgres..."
6
-
7
- @chid_config.on_linux do
8
- system('sudo apt-get install postgresql postgresql-contrib')
9
- end
10
-
11
- @chid_config.on_osx do
12
- system('brew install postgres')
13
- end
14
-
15
- puts "\nPostgres installed successfully"
16
- end
17
-
18
- end
@@ -1,21 +0,0 @@
1
- namespace :install do
2
-
3
- desc 'Install RVM'
4
- task :rvm do
5
- puts "\nInstalling the RVM..."
6
-
7
- @chid_config.on_linux do
8
- system('sudo apt-add-repository -y ppa:rael-gc/rvm')
9
- system('sudo apt-get update')
10
- system('sudo apt-get install curl')
11
- system('sudo apt-get install rvm')
12
- end
13
-
14
- @chid_config.on_osx do
15
- system('\curl -sSL https://get.rvm.io | bash')
16
- end
17
-
18
- puts "\nRVM installed successfully"
19
- end
20
-
21
- end
@@ -1,11 +0,0 @@
1
- desc 'List all news'
2
- task :news do
3
- articles = NewsApi.articles
4
-
5
- Paginator.new(articles).paginate do |article|
6
- article.summary
7
- end
8
-
9
- end
10
-
11
-