fakerbot 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e69f2f82ca880b7296703001d6f5f787cce885a7
4
- data.tar.gz: c818353d057e1bb14ffb3ef343e73de63c8fcfdd
3
+ metadata.gz: b5088f42e2b2ebe474794900ef68c9c82082577f
4
+ data.tar.gz: e2c0b519a845ad6060aded36dccae8550fd4675f
5
5
  SHA512:
6
- metadata.gz: 3d8201991eb7fb523e23a91736b1a5752ed32e7746416776d53351357f466ba45dc11b5ddd2c77f8b00b0781d76b799e216fb0bf58fdf94f184298610c73f353
7
- data.tar.gz: c86c5b42cde4c3b747f742d2707664c6bc883e0e69bfed210f6add5c906f557c68afdf191c241e4799631ff393cf99a75ff8fc2153cf11e1c594212b6aea6ed5
6
+ metadata.gz: ddcbc76eb1255fbcc9eab56f68da1e16df9f988c6a03061e524aba571dc41da5ea235adcad6de839eb60c59fe987843eb49307ccd3ac02713b6ae1363febf9d5
7
+ data.tar.gz: a1595e16fba24d51b280fc5a14d044c7288a26633d38143f6f97afe86184bc62ec05791c5c27c6e39c660477d74ff7c514390a60294b2673c58147f3bda8b2ff
data/Gemfile.lock CHANGED
@@ -1,10 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fakerbot (0.2.3)
4
+ fakerbot (0.2.4)
5
5
  faker
6
6
  pastel (~> 0.7.2)
7
7
  thor (~> 0.20.0)
8
+ tty-pager
9
+ tty-screen
8
10
  tty-tree
9
11
 
10
12
  GEM
@@ -65,15 +67,26 @@ GEM
65
67
  json (>= 1.8, < 3)
66
68
  simplecov-html (~> 0.10.0)
67
69
  simplecov-html (0.10.2)
70
+ strings (0.1.1)
71
+ unicode-display_width (~> 1.3.0)
72
+ unicode_utils (~> 1.4.0)
68
73
  term-ansicolor (1.6.0)
69
74
  tins (~> 1.0)
70
75
  thor (0.20.0)
71
76
  tins (1.16.3)
72
77
  tty-color (0.4.3)
78
+ tty-pager (0.11.0)
79
+ strings (~> 0.1.0)
80
+ tty-screen (~> 0.6.4)
81
+ tty-which (~> 0.3.0)
82
+ tty-screen (0.6.5)
73
83
  tty-tree (0.1.0)
84
+ tty-which (0.3.0)
74
85
  unf (0.1.4)
75
86
  unf_ext
76
87
  unf_ext (0.0.7.5)
88
+ unicode-display_width (1.3.3)
89
+ unicode_utils (1.4.0)
77
90
 
78
91
  PLATFORMS
79
92
  ruby
data/README.md CHANGED
@@ -22,14 +22,27 @@ Run a quick lookup
22
22
 
23
23
  ```bash
24
24
  $ fakerbot search name
25
- # Faker::FunnyName
26
- # Faker::Name
25
+ # Faker::SwordArtOnline
26
+ # └── real_name
27
+ # └── game_name
28
+ # Faker::Superhero
29
+ # └── name
30
+ # Faker::ProgrammingLanguage
31
+ # └── name
32
+ # Faker::Cat
33
+ # └── name
34
+ # Faker::Pokemon
35
+ # └── name
36
+ # e.t.c
27
37
  ```
28
38
 
29
- ## TODO
39
+ ## New Features! :sunglasses: :dancers:
30
40
 
31
- - [ ] List classes with methods E.g. Faker::FunnyName should list `.name`,`.first_name` e.t.c.
32
- - [ ] Expand search to Faker::Base sub classes i.e."fakerbot search email" should include `Faker::Internet.email`
41
+ - [x] List classes with methods E.g. Faker::FunnyName should list `.name`,`.first_name` e.t.c.
42
+ - [x] Expand search to Faker::Base sub classes
43
+ - [x] Paginate results :book:
44
+
45
+ ![screen shot 2018-08-09 at 20 21 06](https://user-images.githubusercontent.com/17295175/43914887-c9a99d84-9c11-11e8-9686-85f584412b27.jpg)
33
46
 
34
47
  ## Development
35
48
 
@@ -41,6 +54,10 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
41
54
 
42
55
  Bug reports and pull requests are welcome on GitHub at https://github.com/akabiru/fakerbot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
43
56
 
57
+ ## Credits
58
+
59
+ Terminal awesomeness made easy by the [TTY Toolkit](http://piotrmurach.github.io/tty/). :beer:
60
+
44
61
  ## License
45
62
 
46
63
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/fakerbot.gemspec CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "faker"
23
23
  spec.add_dependency "pastel", "~> 0.7.2"
24
24
  spec.add_dependency "thor", "~> 0.20.0"
25
+ spec.add_dependency "tty-pager"
26
+ spec.add_dependency "tty-screen"
25
27
  spec.add_dependency "tty-tree"
26
28
 
27
29
  spec.add_development_dependency "bundler", "~> 1.16"
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'pastel'
4
+ require 'tty/pager'
4
5
  require 'tty/tree'
5
6
  require 'fakerbot/bot'
6
7
 
@@ -9,11 +10,26 @@ module FakerBot
9
10
  class Search
10
11
  def initialize(options)
11
12
  @options = options
13
+ @pager = TTY::Pager.new(command: 'less -R')
14
+ @screen = TTY::Screen
12
15
  end
13
16
 
14
17
  def execute(input)
15
- result = FakerBot::Bot.find(input)
16
- puts result.empty? ? not_found : tree(result).render
18
+ render FakerBot::Bot.find(input)
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :screen, :pager
24
+
25
+ def render(result)
26
+ return not_found if result.empty?
27
+ output = tree(result)
28
+ if screen.height < output.nodes.size
29
+ pager.page output.render
30
+ else
31
+ puts output.render
32
+ end
17
33
  end
18
34
 
19
35
  def tree(input)
@@ -27,7 +43,7 @@ module FakerBot
27
43
  end
28
44
 
29
45
  def not_found
30
- "\n ☹️ Sorry, we couldn't find a match\n"
46
+ puts "\nSorry, we couldn't find a match 😢", "\n"
31
47
  end
32
48
  end
33
49
  end
@@ -1,3 +1,3 @@
1
1
  module FakerBot
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakerbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Kabiru
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-09 00:00:00.000000000 Z
11
+ date: 2018-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faker
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.20.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-pager
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: tty-screen
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: tty-tree
57
85
  requirement: !ruby/object:Gem::Requirement