basics 0.0.8 → 0.1.2
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 +4 -4
- data/bin/basics +15 -60
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbe3d5becbecde79a21e152a8b5767070679dcc9
|
4
|
+
data.tar.gz: 59237f4f7b80e9b9f506a11ab37040af3e8a44b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac78cc4844df5363fbf247ec8e26a6472d0864908238bfa453d54ef9bb43b55f6d47a909c7e3f11d5dcb29b4e3d05a18edf475ca1077f4408c306c7e090545e1
|
7
|
+
data.tar.gz: 0e65d2390f1841018fb739e29aa649e0fb8d6e0062a06df09101d78bee31477581308099a823acba5a6958b57f9353ae9a129a0a113c5a0bbaeeef135631bc35
|
data/bin/basics
CHANGED
@@ -7,7 +7,7 @@ require 'rainbow'
|
|
7
7
|
require 'console_renderer'
|
8
8
|
require 'redcarpet'
|
9
9
|
|
10
|
-
URL = "http://
|
10
|
+
URL = "http://b.adit.io/"
|
11
11
|
markdown = Redcarpet::Markdown.new(ConsoleRenderer)
|
12
12
|
|
13
13
|
def to_ascii str
|
@@ -24,75 +24,30 @@ def get(url)
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
if ARGV.empty? || ARGV[0] == "-h"
|
28
28
|
puts "usage: #{$0} [term to search] [category (optional)]\nSee a list of available categories with #{$0} -l"
|
29
29
|
exit
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
when 0
|
34
|
-
usage
|
35
|
-
when 1
|
36
|
-
if ARGV[0] == "-l"
|
37
|
-
p get(URL + "categories").map { |x| x['name'] }.sort
|
38
|
-
exit
|
39
|
-
elsif ARGV[0] == "-h" || ARGV[0] == "--help"
|
40
|
-
usage
|
30
|
+
elsif ARGV[0] == "-l"
|
31
|
+
get(URL + "categories").each do |category|
|
32
|
+
puts category
|
41
33
|
end
|
42
|
-
|
43
|
-
when 2
|
44
|
-
tips = get(URL + "search/#{URI.escape(ARGV[0])}/#{ARGV[1]}")
|
34
|
+
exit
|
45
35
|
end
|
46
36
|
|
37
|
+
tips = get(URL + "search?q=#{URI.escape(ARGV.join(" "))}")
|
38
|
+
|
47
39
|
if tips.size == 0
|
48
40
|
puts Rainbow("NO CONTENT").yellow
|
49
41
|
exit
|
50
42
|
end
|
51
43
|
|
52
|
-
puts Rainbow("
|
53
|
-
|
54
|
-
prev_category = nil
|
55
|
-
|
56
|
-
tips.each do |tip|
|
57
|
-
=begin DISABLING CATEGORIES FOR NOW
|
58
|
-
if tip["category"] != prev_category
|
59
|
-
prev_category = tip["category"]
|
60
|
-
puts tip["category"].upcase.background(:red).foreground("#000000")
|
61
|
-
end
|
62
|
-
=end
|
63
|
-
puts Rainbow(tip["title"]).background(:white).foreground("#000000")
|
64
|
-
end
|
65
|
-
|
66
|
-
prev_category = nil
|
67
|
-
puts Rainbow("\nDETAILS:").yellow
|
44
|
+
puts Rainbow("\nRESULTS:").yellow
|
68
45
|
tips.each do |tip|
|
69
|
-
|
70
|
-
if tip["
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
=end
|
75
|
-
puts Rainbow("##{tip["id"].to_s} ").background(:red) + Rainbow(tip["title"]).background(:white).foreground("#000000")
|
76
|
-
puts Rainbow(tip["title"]).background(:white).foreground("#000000")
|
77
|
-
puts markdown.render(tip["text"])
|
78
|
-
puts "\n\n\n"
|
79
|
-
end
|
80
|
-
|
81
|
-
def vote ids
|
82
|
-
ids.each do |id|
|
83
|
-
puts to_ascii(open(URL + "vote/#{id}").read)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
puts "were any of these especially useful? (comma-separated values ok, or 'y' to mark all as useful):\n"
|
88
|
-
input = STDIN.gets.chomp
|
89
|
-
|
90
|
-
if ["y", "yes"].include?(input)
|
91
|
-
vote(tips.map { |t| t["id"] })
|
92
|
-
else
|
93
|
-
ids = input.split(",").map(&:to_i)
|
94
|
-
ids = ids.compact.reject { |id| id == 0 }
|
95
|
-
unless ids.empty?
|
96
|
-
vote(ids)
|
46
|
+
puts Rainbow(tip["id"].to_s + ": " + tip["title"]).background(:white).foreground("#000000")
|
47
|
+
if tip["text"]
|
48
|
+
puts markdown.render(tip["text"])
|
49
|
+
else
|
50
|
+
puts "--no content--"
|
97
51
|
end
|
52
|
+
puts "\n\n"
|
98
53
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: basics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aditya Bhargava
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: json
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rainbow
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +53,7 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
55
|
description: Cheat sheets for basic programming knowledge.
|
70
|
-
email:
|
56
|
+
email: adit@adit.io
|
71
57
|
executables:
|
72
58
|
- basics
|
73
59
|
extensions: []
|