grepg 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/grepg/errors.rb +4 -0
- data/lib/grepg/formatter.rb +12 -8
- data/lib/grepg/parser.rb +7 -5
- data/lib/grepg/version.rb +1 -1
- data/lib/grepg.rb +3 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3106a1e8e04894f0cb4b980682e95a64f7ad4894
|
4
|
+
data.tar.gz: 999e07dbb13b6a0ced4ad7e96b0e8e1cbe7983bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c935a00315b2342f1b0fb849215d65f9755defd29ea54e018897a5385caa3a0e5c1fbe7c4b8d992a7e2fe7d1bc3227a77161299255180dfbebbc00e0f37438af
|
7
|
+
data.tar.gz: 7d7db6a173f995fe8462b05efa2fc54f19889c7f14ac59bda243d228d9e1d6ed180ec8dde6631fcaf35515507cb9cfd1dd8fd8bb90dc016660a54e8175b3d34b
|
data/README.md
CHANGED
data/lib/grepg/errors.rb
ADDED
data/lib/grepg/formatter.rb
CHANGED
@@ -3,20 +3,24 @@ module GrepPage
|
|
3
3
|
class Formatter
|
4
4
|
# Displays an array of cheats
|
5
5
|
# TODO: Highlight search term
|
6
|
-
DESCRIPTION_COLOR= :green
|
7
|
-
COMMAND_COLOR= :blue
|
6
|
+
DESCRIPTION_COLOR = :green
|
7
|
+
COMMAND_COLOR = :blue
|
8
|
+
NONE_FOUND_COLOR = :green
|
9
|
+
|
8
10
|
def self.cheat_rows(cheats, search_term, colorize)
|
9
11
|
cheats.map do |cheat|
|
10
12
|
description = cheat[:description]
|
11
13
|
command = cheat[:command]
|
12
|
-
|
13
|
-
|
14
|
-
command = command.colorize(COMMAND_COLOR)
|
15
|
-
end
|
16
|
-
puts description
|
17
|
-
puts command
|
14
|
+
print description, DESCRIPTION_COLOR, colorize
|
15
|
+
print command, COMMAND_COLOR, colorize
|
18
16
|
puts
|
19
17
|
end
|
18
|
+
print "None found", NONE_FOUND_COLOR, colorize if cheats.size == 0
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.print(text, color, colorize)
|
22
|
+
text = text.colorize(color) if colorize
|
23
|
+
puts text
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
data/lib/grepg/parser.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'trollop'
|
2
2
|
require 'rest-client'
|
3
3
|
require 'yaml'
|
4
|
-
require_relative 'version'
|
5
4
|
|
6
5
|
# This class parses commandline arguments
|
7
6
|
module GrepPage
|
@@ -100,15 +99,14 @@ Defaults:
|
|
100
99
|
begin
|
101
100
|
topics = get_all_topics(user)
|
102
101
|
rescue RestClient::ResourceNotFound
|
103
|
-
|
104
|
-
raise "Unable to find user"
|
102
|
+
raise GrepPage::NotFoundError, "Unable to find user"
|
105
103
|
end
|
106
104
|
|
107
105
|
topic = filter_topics(topics, topic)
|
108
106
|
if topic.nil? || topic.empty?
|
109
107
|
puts "Can't find that topic. Choose one of the following"
|
110
108
|
puts topics.map{|t| t[:name]}
|
111
|
-
raise "Unable to find topic"
|
109
|
+
raise GrepPage::NotFoundError, "Unable to find topic"
|
112
110
|
end
|
113
111
|
|
114
112
|
cheats = get_cheats(user, topic[:id])
|
@@ -118,7 +116,11 @@ Defaults:
|
|
118
116
|
end
|
119
117
|
|
120
118
|
def run!
|
121
|
-
|
119
|
+
begin
|
120
|
+
process_args(@user, @topic, @search_term, @colorize)
|
121
|
+
rescue GrepPage::NotFoundError => ex
|
122
|
+
abort "Error: #{ex.message}"
|
123
|
+
end
|
122
124
|
end
|
123
125
|
end
|
124
126
|
end
|
data/lib/grepg/version.rb
CHANGED
data/lib/grepg.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grepg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yash Ranadive
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- img/screenshot.png
|
113
113
|
- lib/grepg.rb
|
114
114
|
- lib/grepg/api.rb
|
115
|
+
- lib/grepg/errors.rb
|
115
116
|
- lib/grepg/formatter.rb
|
116
117
|
- lib/grepg/parser.rb
|
117
118
|
- lib/grepg/version.rb
|