grepg 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cee82c12d92813e766763700c3fea73eb1d20f3a
4
- data.tar.gz: bc0ed894ffecec938bebf35369bdfc97438e2195
3
+ metadata.gz: 3106a1e8e04894f0cb4b980682e95a64f7ad4894
4
+ data.tar.gz: 999e07dbb13b6a0ced4ad7e96b0e8e1cbe7983bb
5
5
  SHA512:
6
- metadata.gz: 82fe6a2c37ebcf1e40ec3d3543d0e36aa7534e070900042eb19aef525af5ddeedeb90f61d45f0ef89ff25e4a87d1a5ef32d8e3d4f884d9bcbf9391a8b43cf3f4
7
- data.tar.gz: 227627ba0b54bb55b037df46a2e9e86328b70e2d01a3aa45cbff76f3809cbf7fa09c9761c34472522c8369c02690eb0009c3c161416d6609fb732ab7d856b151
6
+ metadata.gz: c935a00315b2342f1b0fb849215d65f9755defd29ea54e018897a5385caa3a0e5c1fbe7c4b8d992a7e2fe7d1bc3227a77161299255180dfbebbc00e0f37438af
7
+ data.tar.gz: 7d7db6a173f995fe8462b05efa2fc54f19889c7f14ac59bda243d228d9e1d6ed180ec8dde6631fcaf35515507cb9cfd1dd8fd8bb90dc016660a54e8175b3d34b
data/README.md CHANGED
@@ -39,7 +39,7 @@ Examples:
39
39
 
40
40
  Defaults:
41
41
  To set default user, create a file in ~/.grepg.yml with
42
- default_user: test
42
+ user: test
43
43
  ```
44
44
 
45
45
 
@@ -0,0 +1,4 @@
1
+ module GrepPage
2
+ # when a resource is not found
3
+ class NotFoundError < StandardError; end
4
+ end
@@ -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
- if colorize
13
- description = description.colorize(DESCRIPTION_COLOR)
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
- puts "That username does not exist"
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
- process_args(@user, @topic, @search_term, @colorize)
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
@@ -1,3 +1,3 @@
1
1
  module GrepPage
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/grepg.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'grepg/errors'
2
+ require 'grepg/formatter'
3
+ require 'grepg/version'
1
4
  require 'grepg/api'
2
5
  require 'grepg/parser'
3
- require 'grepg/formatter'
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.5
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-05-23 00:00:00.000000000 Z
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