chid 0.1.6 → 0.2.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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +27 -0
  5. data/CONTRIBUTING.md +78 -0
  6. data/Gemfile.lock +34 -34
  7. data/README.md +135 -89
  8. data/bin/chid +2 -25
  9. data/chid.gemspec +0 -6
  10. data/lib/chid.rb +0 -66
  11. data/lib/chid/chid_config.rb +6 -83
  12. data/lib/chid/command.rb +1 -1
  13. data/lib/chid/commands/alias/create.rb +53 -0
  14. data/lib/chid/commands/config.rb +48 -0
  15. data/lib/chid/commands/currency/convert.rb +50 -0
  16. data/lib/chid/commands/currency/list.rb +34 -0
  17. data/lib/chid/commands/currency/now.rb +47 -0
  18. data/lib/chid/commands/gitflow/commit.rb +0 -1
  19. data/lib/chid/commands/github.rb +40 -0
  20. data/lib/chid/commands/init.rb +1 -2
  21. data/lib/chid/commands/install.rb +1 -0
  22. data/lib/chid/commands/installs/dotfile.rb +27 -11
  23. data/lib/chid/commands/installs/node.rb +5 -3
  24. data/lib/chid/commands/installs/postgres.rb +6 -3
  25. data/lib/chid/commands/installs/rvm.rb +9 -4
  26. data/lib/chid/commands/installs/vim.rb +69 -0
  27. data/lib/chid/commands/pr.rb +63 -0
  28. data/lib/chid/commands/tmux/open.rb +3 -2
  29. data/lib/chid/commands/workstation/create.rb +101 -0
  30. data/lib/chid/commands/workstation/destroy.rb +61 -0
  31. data/lib/chid/commands/workstation/open.rb +4 -4
  32. data/lib/chid/github_api.rb +9 -0
  33. data/lib/chid/version.rb +1 -1
  34. data/spec/lib/chid/commands/alias/create_spec.rb +55 -0
  35. data/spec/lib/chid/commands/init_spec.rb +4 -2
  36. data/spec/lib/chid/commands/pr_spec.rb +68 -0
  37. data/spec/lib/chid/commands/workstation/create_spec.rb +153 -0
  38. data/spec/support/.bashrc +7 -0
  39. data/spec/support/.chid.config +7 -0
  40. data/tasks/install/yadr_dotfiles.rake +1 -0
  41. data/tasks/run/postgres.rake +1 -0
  42. data/tasks/update/os.rake +1 -0
  43. metadata +21 -58
  44. data/#README.md# +0 -221
  45. data/Rakefile +0 -18
  46. data/lib/chid/yandex_translate_api.rb +0 -39
  47. data/tasks/chid/config.rake +0 -5
  48. data/tasks/chid/init.rake +0 -19
  49. data/tasks/chid/install.rake +0 -14
  50. data/tasks/chid/start.rake +0 -26
  51. data/tasks/chid/update.rake +0 -14
  52. data/tasks/currency/convert.rake +0 -9
  53. data/tasks/currency/current.rake +0 -11
  54. data/tasks/currency/list.rake +0 -10
  55. data/tasks/github.rake +0 -12
  56. data/tasks/help.rake +0 -178
  57. data/tasks/install/node.rake +0 -18
  58. data/tasks/install/postgres.rake +0 -18
  59. data/tasks/install/rvm.rake +0 -21
  60. data/tasks/news.rake +0 -11
  61. data/tasks/stack_overflow.rake +0 -20
  62. data/tasks/tmux/config_windows.rake +0 -8
  63. data/tasks/tmux/new_session.rake +0 -9
  64. data/tasks/translate/yandex_list.rake +0 -7
  65. data/tasks/translate/yandex_translate.rake +0 -8
  66. data/tasks/workstation/create.rake +0 -23
  67. data/tasks/workstation/destroy.rake +0 -14
  68. data/tasks/workstation/list.rake +0 -10
  69. data/tasks/workstation/open.rake +0 -29
@@ -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
-
@@ -1,20 +0,0 @@
1
- desc 'Search questions in StackOverflow'
2
- task :stack, [:search] do |t, args|
3
-
4
- search_param = args[:search]
5
-
6
- unless search_param
7
- print "Tell me, what do you want to search?\n".blue
8
- print "> "
9
- search_param = STDIN.gets.strip
10
- end
11
-
12
- questions = StackOverflowApi.questions(search_param)
13
-
14
- Paginator.new(questions).paginate do |question|
15
- question.summary
16
- end
17
-
18
- end
19
-
20
-
@@ -1,8 +0,0 @@
1
- desc 'Configure default windows for development'
2
- task :tmux_config do
3
- system("tmux rename-window bash")
4
- system("tmux new-window -n app")
5
- system("tmux new-window -n server")
6
- end
7
-
8
-
@@ -1,9 +0,0 @@
1
- desc 'Open or Create the new session for development key'
2
- task :tmux do
3
- session = system('tmux attach -t development')
4
- unless session
5
- system('tmux new -s development')
6
- end
7
- end
8
-
9
-
@@ -1,7 +0,0 @@
1
- namespace :translate do
2
- desc 'Yandex translate list'
3
- task :yandex_list do
4
- puts "All options availale are:".blue
5
- YandexTranslateApi.list
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- namespace :translate do
2
- desc 'Yandex translate'
3
- task :yandex_translate, [:text, :from, :to] do |t, args|
4
- puts "Translating..."
5
- text = YandexTranslateApi.translate(args)
6
- puts "#{text}".green
7
- end
8
- end
@@ -1,23 +0,0 @@
1
- namespace :workstation do
2
-
3
- desc 'Create a new workstation'
4
- task :create do
5
- prompt = TTY::Prompt.new
6
-
7
- puts 'Tell me the name of the new Workstation'
8
- print "> "
9
- workstation_name = STDIN.gets.strip
10
-
11
- @chid_config.on_osx do
12
- choices = %x{ls /Applications}.strip
13
- choices = choices
14
- .gsub(/\n/, ' - ')
15
- .gsub('.app', '')
16
- .split(' - ')
17
- result = prompt.multi_select('Select all apps for that workstation?', choices)
18
- @chid_config.create_workstation(workstation_name, result)
19
- puts "\n#{workstation_name} Workstation was created!"
20
- end
21
- end
22
-
23
- end