chid 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/bin/chid +1 -1
- data/lib/chid/chid_config.rb +5 -0
- data/lib/chid/commands/gitflow/commit.rb +0 -1
- data/lib/chid/commands/init.rb +4 -2
- data/lib/chid/commands/news.rb +32 -0
- data/lib/chid/commands/stack_overflow.rb +63 -0
- data/lib/chid/commands/tmux/list.rb +28 -0
- data/lib/chid/commands/tmux/open.rb +89 -0
- data/lib/chid/version.rb +1 -1
- data/spec/lib/chid/commands/workstation/open_spec.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 51d240fb1dd06def3848504ae94b5b34c9966da3e808f5edb3977d84024c82b3
|
4
|
+
data.tar.gz: 0c7216dbadcdd864ce6925af4c98f5f1dae0be145444a7e953c52c03b418bba2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ffb3e40667b8f5de2e2b2a2bb1bd57c24e82000154c1f7f6e21ed82992c8ae42f8f8eb91031e6fcd5489c71434b8e29db919fe5c6410031728ee82e6969fff9
|
7
|
+
data.tar.gz: 8bbe3027b673200f8a697040ee0978b183970e27052d659e71b4be213a977ca58146777a63e9fe6bafed101a24073ade3e4bce9415d82fe7d2aad608cd4bf181
|
data/CHANGELOG.md
CHANGED
data/bin/chid
CHANGED
data/lib/chid/chid_config.rb
CHANGED
@@ -56,6 +56,11 @@ class ChidConfig
|
|
56
56
|
data[:chid][:workstations]
|
57
57
|
end
|
58
58
|
|
59
|
+
def all_tmux_templates
|
60
|
+
data = YAML.load_file chid_config_path
|
61
|
+
data[:chid][:tmux_templates]
|
62
|
+
end
|
63
|
+
|
59
64
|
def destroy_workstations(workstations = [])
|
60
65
|
data = YAML.load_file chid_config_path
|
61
66
|
|
data/lib/chid/commands/init.rb
CHANGED
@@ -50,14 +50,16 @@ Usage:
|
|
50
50
|
return base_configurations unless chid_config_file_exist?
|
51
51
|
|
52
52
|
data = YAML.load_file chid_config_path
|
53
|
-
data[:chid][:workstations]
|
53
|
+
data[:chid][:workstations] = data[:chid].fetch(:workstations, {})
|
54
|
+
data[:chid][:tmux_templates] = data[:chid].fetch(:tmux_templates, {})
|
54
55
|
data
|
55
56
|
end
|
56
57
|
|
57
58
|
def base_configurations
|
58
59
|
{
|
59
60
|
chid: {
|
60
|
-
workstations: {}
|
61
|
+
workstations: {},
|
62
|
+
tmux_templates: {}
|
61
63
|
}
|
62
64
|
}
|
63
65
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Chid
|
2
|
+
module Commands
|
3
|
+
class News < Command
|
4
|
+
|
5
|
+
command :'news'
|
6
|
+
|
7
|
+
self.summary = 'Will show all news from some sites'
|
8
|
+
self.description = <<-DESC
|
9
|
+
|
10
|
+
Usage:
|
11
|
+
|
12
|
+
$ chid news
|
13
|
+
|
14
|
+
Will show all news from some sites
|
15
|
+
|
16
|
+
Sites:
|
17
|
+
BBC, CNN, Espn, Mashable, Google, Techcrunch, Reddit
|
18
|
+
|
19
|
+
|
20
|
+
Options:
|
21
|
+
|
22
|
+
DESC
|
23
|
+
self.arguments = []
|
24
|
+
|
25
|
+
def run
|
26
|
+
articles = ::NewsApi.articles
|
27
|
+
::Paginator.new(articles).paginate { |article| article.summary }
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Chid
|
2
|
+
module Commands
|
3
|
+
class StackOverflow < Command
|
4
|
+
|
5
|
+
command :'stack'
|
6
|
+
|
7
|
+
self.summary = 'Will search on StackOverflow all results'
|
8
|
+
self.description = <<-DESC
|
9
|
+
|
10
|
+
Usage:
|
11
|
+
|
12
|
+
$ chid stack
|
13
|
+
or
|
14
|
+
$ chid stack -s some_text_to_be_searched
|
15
|
+
|
16
|
+
Will search on StackOverflow all results
|
17
|
+
|
18
|
+
If no pass option Will ask what you want to search on StackOverflow all results for the passed text
|
19
|
+
|
20
|
+
Options:
|
21
|
+
|
22
|
+
-search TEXT_TO_SEARCH
|
23
|
+
-s TEXT_TO_SEARCH
|
24
|
+
|
25
|
+
DESC
|
26
|
+
self.arguments = ['-search', '-s']
|
27
|
+
|
28
|
+
def run
|
29
|
+
text_to_search = text_to_search_from_options
|
30
|
+
text_to_search = get_text_to_search if text_to_search.empty?
|
31
|
+
|
32
|
+
questions = ::StackOverflowApi.questions(text_to_search)
|
33
|
+
::Paginator.new(questions).paginate { |question| question.summary }
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def get_text_to_search
|
39
|
+
print "Tell me, what do you want to search?\n".blue
|
40
|
+
print "> "
|
41
|
+
STDIN.gets.strip
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
# Returns the TEXT_TO_SEARCH mapped from the values of the options attribute.
|
47
|
+
# Will remove all nil values and join the array of values into String
|
48
|
+
#
|
49
|
+
# @return [String] Mapped values from options attribute
|
50
|
+
# If the options does not exist, will return empty String #=> ""
|
51
|
+
#
|
52
|
+
# @example Text to Search
|
53
|
+
# options = {'-search' => ['base', 'two']}
|
54
|
+
#
|
55
|
+
# text_to_search #=> 'base two'
|
56
|
+
#
|
57
|
+
def text_to_search_from_options
|
58
|
+
@text_to_search ||= self.class.arguments.map { |a| options[a] }.compact.join(' ')
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Chid
|
2
|
+
module Commands
|
3
|
+
module Tmux
|
4
|
+
class List < Command
|
5
|
+
|
6
|
+
command :'tmux list'
|
7
|
+
|
8
|
+
self.summary = 'List all existent tmux template'
|
9
|
+
self.description = <<-DESC
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
|
13
|
+
$ chid tmux list
|
14
|
+
|
15
|
+
DESC
|
16
|
+
self.arguments = []
|
17
|
+
|
18
|
+
def run
|
19
|
+
chid_config = ChidConfig.new
|
20
|
+
puts "Tmux templates availabbe:".blue
|
21
|
+
puts chid_config.all_tmux_templates.keys
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Chid
|
2
|
+
module Commands
|
3
|
+
module Tmux
|
4
|
+
class Open < Command
|
5
|
+
|
6
|
+
command :'tmux open'
|
7
|
+
|
8
|
+
self.summary = 'Open a specific tmux template'
|
9
|
+
self.description = <<-DESC
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
|
13
|
+
$ chid tmux open
|
14
|
+
or
|
15
|
+
$ chid tmux open -name some_template_name
|
16
|
+
|
17
|
+
Open the template.
|
18
|
+
|
19
|
+
To see all templates you can run
|
20
|
+
|
21
|
+
$ chid tmux list
|
22
|
+
|
23
|
+
If no options are specified, chid will show a list of Templates created
|
24
|
+
to be selected.
|
25
|
+
|
26
|
+
Options:
|
27
|
+
|
28
|
+
-name template_name Open the specifc template called 'template_name'
|
29
|
+
-n "base two" Open the specific template called 'base two'
|
30
|
+
|
31
|
+
DESC
|
32
|
+
self.arguments = ['-name', '-n']
|
33
|
+
|
34
|
+
def run
|
35
|
+
template_name = template_name_from_options
|
36
|
+
template_name = select_template if template_name.empty?
|
37
|
+
|
38
|
+
open_template(template_name)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
# Returns the template name mapped from the values of the options attribute.
|
44
|
+
# Will remove all nil values and join the array of values into String
|
45
|
+
#
|
46
|
+
# @return [String] Mapped values from options attribute
|
47
|
+
# If the options does not exist, will return empty String #=> ""
|
48
|
+
#
|
49
|
+
# @example Template Name
|
50
|
+
# options = {'-name' => ['base', 'two']}
|
51
|
+
#
|
52
|
+
# template_name #=> 'base two'
|
53
|
+
#
|
54
|
+
def template_name_from_options
|
55
|
+
@template_name ||= self.class.arguments.map { |a| options[a] }.compact.join(' ')
|
56
|
+
end
|
57
|
+
|
58
|
+
def chid_config
|
59
|
+
::Chid.chid_config
|
60
|
+
end
|
61
|
+
|
62
|
+
def templates
|
63
|
+
@templates ||= chid_config.all_tmux_templates
|
64
|
+
end
|
65
|
+
|
66
|
+
def select_template
|
67
|
+
prompt = TTY::Prompt.new
|
68
|
+
choices = templates.keys
|
69
|
+
selected_template = prompt.select('Choose a template to open', choices)
|
70
|
+
selected_template
|
71
|
+
end
|
72
|
+
|
73
|
+
def open_template(template_name)
|
74
|
+
puts "\nOpening Template #{template_name}"
|
75
|
+
commands = templates[template_name.to_sym]
|
76
|
+
|
77
|
+
exist_tmux_session = system("tmux ls | grep -c #{template_name}")
|
78
|
+
|
79
|
+
if exist_tmux_session
|
80
|
+
system("tmux attach -t #{template_name}")
|
81
|
+
else
|
82
|
+
system(commands.join('').gsub('$$template_name$$', template_name.to_s))
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
data/lib/chid/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.6
|
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: 2018-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -122,6 +122,10 @@ files:
|
|
122
122
|
- lib/chid/commands/installs/node.rb
|
123
123
|
- lib/chid/commands/installs/postgres.rb
|
124
124
|
- lib/chid/commands/installs/rvm.rb
|
125
|
+
- lib/chid/commands/news.rb
|
126
|
+
- lib/chid/commands/stack_overflow.rb
|
127
|
+
- lib/chid/commands/tmux/list.rb
|
128
|
+
- lib/chid/commands/tmux/open.rb
|
125
129
|
- lib/chid/commands/workstation/list.rb
|
126
130
|
- lib/chid/commands/workstation/open.rb
|
127
131
|
- lib/chid/currency_api.rb
|
@@ -183,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
187
|
version: '0'
|
184
188
|
requirements: []
|
185
189
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.
|
190
|
+
rubygems_version: 2.7.3
|
187
191
|
signing_key:
|
188
192
|
specification_version: 4
|
189
193
|
summary: Simple assistant for day-to-day life. Developers and common users
|