fakerbot 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -4
- data/README.md +1 -1
- data/fakerbot.gemspec +1 -0
- data/lib/fakerbot/bot.rb +37 -4
- data/lib/fakerbot/commands/search.rb +12 -1
- data/lib/fakerbot/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6f9c6012e690d78b9fe3312c3df35ab4e9f0fb0
|
4
|
+
data.tar.gz: ba34f6335dbfc51d8cec5f4d81e8886053da87e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22b90cab9064cb1e24f6f71bef7e6df71af6e70a81615a51a894dd70820e90897dd1c71f3f93175c0ccfeb1385415823ce0b5076007851aded1feadba9eaa24d
|
7
|
+
data.tar.gz: 97d80d7590d2758720536390d31cdd909f0c7e2f16bf8ecb2416799ece3e6db83c8c5fa3bb947c4dd4aec41d8f6a93a2dcfdb91b0ee56cc80527736f9296e63c
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fakerbot (0.1.
|
4
|
+
fakerbot (0.1.2)
|
5
5
|
faker
|
6
6
|
pastel (~> 0.7.2)
|
7
7
|
thor (~> 0.20.0)
|
8
|
+
tty-tree
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
@@ -22,11 +23,11 @@ GEM
|
|
22
23
|
domain_name (0.5.20180417)
|
23
24
|
unf (>= 0.0.5, < 1.0.0)
|
24
25
|
equatable (0.5.0)
|
25
|
-
faker (1.
|
26
|
+
faker (1.9.1)
|
26
27
|
i18n (>= 0.7)
|
27
28
|
http-cookie (1.0.3)
|
28
29
|
domain_name (~> 0.5)
|
29
|
-
i18n (1.0
|
30
|
+
i18n (1.1.0)
|
30
31
|
concurrent-ruby (~> 1.0)
|
31
32
|
json (2.1.0)
|
32
33
|
method_source (0.9.0)
|
@@ -68,7 +69,8 @@ GEM
|
|
68
69
|
tins (~> 1.0)
|
69
70
|
thor (0.20.0)
|
70
71
|
tins (1.16.3)
|
71
|
-
tty-color (0.4.
|
72
|
+
tty-color (0.4.3)
|
73
|
+
tty-tree (0.1.0)
|
72
74
|
unf (0.1.4)
|
73
75
|
unf_ext
|
74
76
|
unf_ext (0.0.7.5)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# FakerBot
|
2
2
|
|
3
|
-
[![codebeat badge](https://codebeat.co/badges/ef4839f2-3946-4435-8c0e-7025de5fac22)](https://codebeat.co/projects/github-com-akabiru-
|
3
|
+
[![codebeat badge](https://codebeat.co/badges/ef4839f2-3946-4435-8c0e-7025de5fac22)](https://codebeat.co/projects/github-com-akabiru-fakerbot-master) [![Inline docs](http://inch-ci.org/github/akabiru/fakerbot.svg?branch=master)](http://inch-ci.org/github/akabiru/fakerbot) [![Build Status](https://travis-ci.com/akabiru/fakerbot.svg?branch=master)](https://travis-ci.com/akabiru/fakerbot) [![Coverage Status](https://coveralls.io/repos/github/akabiru/fakerbot/badge.svg?branch=master)](https://coveralls.io/github/akabiru/fakerbot?branch=master) [![Gem Version](https://badge.fury.io/rb/fakerbot.svg)](https://badge.fury.io/rb/fakerbot)
|
4
4
|
|
5
5
|
> Quickly look up [Faker](https://github.com/stympy/faker) methods without leaving your terminal!
|
6
6
|
|
data/fakerbot.gemspec
CHANGED
@@ -22,6 +22,7 @@ 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-tree"
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.16"
|
27
28
|
spec.add_development_dependency "coveralls"
|
data/lib/fakerbot/bot.rb
CHANGED
@@ -10,18 +10,51 @@ module FakerBot
|
|
10
10
|
klass < self
|
11
11
|
end
|
12
12
|
end
|
13
|
+
|
14
|
+
def self.my_singleton_methods
|
15
|
+
if superclass
|
16
|
+
(singleton_methods - superclass.singleton_methods)
|
17
|
+
else
|
18
|
+
singleton_methods
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :matching_descendants, :query
|
24
|
+
|
25
|
+
def initialize(query)
|
26
|
+
@matching_descendants = Hash.new { |h, k| h[k] = [] }
|
27
|
+
@query = query
|
13
28
|
end
|
14
29
|
|
15
30
|
class << self
|
16
31
|
def find(query)
|
17
|
-
|
32
|
+
new(query).find
|
18
33
|
end
|
34
|
+
end
|
19
35
|
|
20
|
-
|
36
|
+
def find
|
37
|
+
search_descendants_matching_query
|
38
|
+
matching_descendants
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
21
42
|
|
22
|
-
|
23
|
-
|
43
|
+
def search_descendants_matching_query
|
44
|
+
faker_descendants.each do |faker|
|
45
|
+
methods = faker.my_singleton_methods
|
46
|
+
matching = methods.select { |m| m.match?(/#{query}/i) }
|
47
|
+
save_matching(faker, matching)
|
24
48
|
end
|
25
49
|
end
|
50
|
+
|
51
|
+
def save_matching(descendant, matching)
|
52
|
+
return if matching.empty?
|
53
|
+
matching_descendants[descendant].concat(matching)
|
54
|
+
end
|
55
|
+
|
56
|
+
def faker_descendants
|
57
|
+
@faker_descendants ||= Faker::Base.descendants
|
58
|
+
end
|
26
59
|
end
|
27
60
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'pastel'
|
4
|
+
require 'tty/tree'
|
4
5
|
require 'fakerbot/bot'
|
5
6
|
|
6
7
|
module FakerBot
|
@@ -12,7 +13,17 @@ module FakerBot
|
|
12
13
|
|
13
14
|
def execute(input)
|
14
15
|
result = FakerBot::Bot.find(input)
|
15
|
-
puts(result.
|
16
|
+
puts tree(result).render
|
17
|
+
end
|
18
|
+
|
19
|
+
def tree(input)
|
20
|
+
TTY::Tree.new do
|
21
|
+
input.each do |faker, methods|
|
22
|
+
node Pastel.new.green(faker.to_s) do
|
23
|
+
methods.each { |m| leaf Pastel.new.cyan(m.to_s) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
16
27
|
end
|
17
28
|
end
|
18
29
|
end
|
data/lib/fakerbot/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.0
|
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-
|
11
|
+
date: 2018-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faker
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.20.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: tty-tree
|
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'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|