okbot 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/okbot +5 -0
- data/bin/setup +8 -0
- data/lib/okbot.rb +6 -0
- data/lib/okbot/cli.rb +81 -0
- data/lib/okbot/cli/stack.rb +48 -0
- data/lib/okbot/version.rb +3 -0
- data/okbot.gemspec +41 -0
- data/pkg/okbot-0.1.0.gem +0 -0
- metadata +200 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 45a0926766e65d89d1c7e5473f23029aea174b6e
|
4
|
+
data.tar.gz: 7f8bf93cd70edcc194623a374365749319f0051a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 652741adbabe7f5f19e8b89377f8e6421cd9c3b9403bf0b461fc76465aa2f3ae3fa099ef3067c444d8e54b8904f6a0cc6f87ba85eadb3aae15c19bc324f50a9b
|
7
|
+
data.tar.gz: 4dee768c7bd905e986530749f6d9f4bbaeb8c21ecbee5c3d51108b2d6952969d229b91f056e9730d6e50a276e47c07174637e3460f000d962c437d1c3a909d33
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Okbot
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/okbot`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'okbot'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install okbot
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/okbot.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "okbot"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/okbot
ADDED
data/bin/setup
ADDED
data/lib/okbot.rb
ADDED
data/lib/okbot/cli.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'thor'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'rainbow/ext/string'
|
5
|
+
require 'okbot/cli/stack'
|
6
|
+
require 'net/http'
|
7
|
+
require 'json'
|
8
|
+
require "highline/import"
|
9
|
+
require 'terminal-table/import'
|
10
|
+
require 'pry'
|
11
|
+
require 'open-uri'
|
12
|
+
|
13
|
+
module Okbot
|
14
|
+
class MyCli < Thor
|
15
|
+
desc "blitz", "Get schedule theater on blitz bandung"
|
16
|
+
|
17
|
+
def blitz
|
18
|
+
puts "Please choice your theater!"
|
19
|
+
puts "1. pvj"
|
20
|
+
puts "----------"
|
21
|
+
puts "2. miko"
|
22
|
+
puts "----------"
|
23
|
+
puts "3. bec"
|
24
|
+
puts "----------"
|
25
|
+
answer = STDIN.gets.chomp
|
26
|
+
print "Doing your schedule..."
|
27
|
+
spin_it{
|
28
|
+
sleep rand(4)+2
|
29
|
+
}
|
30
|
+
print "done!"
|
31
|
+
case answer
|
32
|
+
when "1", "pvj"
|
33
|
+
doc = Nokogiri::XML(open("https://www.cgvblitz.com/en/schedule/cinema/0100"))
|
34
|
+
puts Rainbow("Result schedule PVJ MALL").yellow
|
35
|
+
puts "--------------------"
|
36
|
+
doc.css('.schedule-title').children.each do |l|
|
37
|
+
puts l.content.color(:cyan)
|
38
|
+
end
|
39
|
+
puts "--------------------"
|
40
|
+
when "2", "miko"
|
41
|
+
doc = Nokogiri::HTML(open("https://www.cgvblitz.com/en/schedule/cinema/1200"))
|
42
|
+
puts Rainbow("Result schedule MIKO MALL").yellow
|
43
|
+
puts "--------------------"
|
44
|
+
doc.css('.schedule-title').children.each do |l|
|
45
|
+
puts l.content.color(:cyan)
|
46
|
+
end
|
47
|
+
puts "--------------------"
|
48
|
+
when "3", "bec"
|
49
|
+
doc = Nokogiri::HTML(open("https://www.cgvblitz.com/en/schedule/cinema/1400"))
|
50
|
+
puts Rainbow("Result schedule BEC MALL").yellow
|
51
|
+
puts "--------------------"
|
52
|
+
doc.css('.schedule-title').children.each do |l|
|
53
|
+
puts l.content.color(:cyan)
|
54
|
+
end
|
55
|
+
puts "--------------------"
|
56
|
+
else
|
57
|
+
puts "Please check you choice!"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "spin_it", "FOR LOADING"
|
62
|
+
def spin_it(fps=10)
|
63
|
+
chars = %w[⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷]
|
64
|
+
delay = 1.0/fps
|
65
|
+
iter = 0
|
66
|
+
spinner = Thread.new do
|
67
|
+
while iter do # Keep spinning until told otherwise
|
68
|
+
print chars[(iter+=1) % chars.length]
|
69
|
+
sleep delay
|
70
|
+
print "\b"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
yield.tap{ # After yielding to the block, save the return value
|
74
|
+
iter = false # Tell the thread to exit, cleaning up after itself…
|
75
|
+
spinner.join # …and wait for it to do so.
|
76
|
+
} # Use the block's return value as the method's
|
77
|
+
end
|
78
|
+
desc "stack COMMANDS", "Get Stack overflow question"
|
79
|
+
subcommand "stack", Okbot::CLI::Stack
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Okbot
|
2
|
+
module CLI
|
3
|
+
class Stack < Thor
|
4
|
+
desc "title", "Search stack overflow question and get link"
|
5
|
+
option :tags
|
6
|
+
def title
|
7
|
+
title = ask "Input text: "
|
8
|
+
print "Doing your title..."
|
9
|
+
spin_it{
|
10
|
+
sleep rand(4)+2
|
11
|
+
}
|
12
|
+
|
13
|
+
url = "https://api.stackexchange.com/2.2/search/advanced?pagesize=5&order=desc&sort=activity&title=#{title}&site=stackoverflow&filter=!1zSk2G.tfS9G_M7ErPqm("
|
14
|
+
uri = URI(url)
|
15
|
+
response = Net::HTTP.get(uri)
|
16
|
+
output = JSON.parse(response)
|
17
|
+
rows = []
|
18
|
+
|
19
|
+
output["items"].each_index do |i, t|
|
20
|
+
rows << ['Tags', output["items"][i]["tags"]]
|
21
|
+
rows << ['Title', output["items"][i]["title"]]
|
22
|
+
rows << ['Is answered', output["items"][i]["is_answered"]]
|
23
|
+
rows << ['Link', output["items"][i]["link"]]
|
24
|
+
rows << :separator
|
25
|
+
end
|
26
|
+
puts table([nil, Rainbow("Result for: #{title}").red], *rows)
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "spin_it", "FOR LOADING"
|
30
|
+
def spin_it(fps=10)
|
31
|
+
chars = %w[⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷]
|
32
|
+
delay = 1.0/fps
|
33
|
+
iter = 0
|
34
|
+
spinner = Thread.new do
|
35
|
+
while iter do # Keep spinning until told otherwise
|
36
|
+
print chars[(iter+=1) % chars.length]
|
37
|
+
sleep delay
|
38
|
+
print "\b"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
yield.tap{ # After yielding to the block, save the return value
|
42
|
+
iter = false # Tell the thread to exit, cleaning up after itself…
|
43
|
+
spinner.join # …and wait for it to do so.
|
44
|
+
} # Use the block's return value as the method's
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/okbot.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'okbot/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "okbot"
|
8
|
+
spec.version = Okbot::VERSION
|
9
|
+
spec.authors = ["zainal mustofa"]
|
10
|
+
spec.email = ["zainalmustof@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{BLITZ and StackOverFlow}
|
13
|
+
spec.description = %q{Your smart assistances}
|
14
|
+
spec.homepage = "http://rubygems.org/gems/okbot"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
# if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'https://rubygems.org'"
|
20
|
+
# else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
# end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0")
|
25
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
26
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
spec.license = 'MIT'
|
29
|
+
|
30
|
+
spec.add_dependency 'thor', "~> 0.19.1"
|
31
|
+
spec.add_dependency 'httparty', "~> 0.14.0"
|
32
|
+
spec.add_dependency 'rainbow', "~> 2.0.0"
|
33
|
+
spec.add_dependency 'nokogiri', '~> 1.6.8'
|
34
|
+
spec.add_dependency 'json', "~> 1.8.3"
|
35
|
+
spec.add_dependency 'highline', "~> 1.7.8"
|
36
|
+
spec.add_dependency 'terminal-table', "~> 1.6.0"
|
37
|
+
|
38
|
+
spec.add_development_dependency 'pry', "~> 0.10.4"
|
39
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
end
|
data/pkg/okbot-0.1.0.gem
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: okbot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- zainal mustofa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.19.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.19.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.14.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.14.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rainbow
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.6.8
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.6.8
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.8.3
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.8.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: highline
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.7.8
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.7.8
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: terminal-table
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.6.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.6.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.10.4
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.10.4
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: bundler
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.12'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.12'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rake
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '10.0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '10.0'
|
153
|
+
description: Your smart assistances
|
154
|
+
email:
|
155
|
+
- zainalmustof@gmail.com
|
156
|
+
executables:
|
157
|
+
- console
|
158
|
+
- okbot
|
159
|
+
- setup
|
160
|
+
extensions: []
|
161
|
+
extra_rdoc_files: []
|
162
|
+
files:
|
163
|
+
- ".gitignore"
|
164
|
+
- Gemfile
|
165
|
+
- README.md
|
166
|
+
- Rakefile
|
167
|
+
- bin/console
|
168
|
+
- bin/okbot
|
169
|
+
- bin/setup
|
170
|
+
- lib/okbot.rb
|
171
|
+
- lib/okbot/cli.rb
|
172
|
+
- lib/okbot/cli/stack.rb
|
173
|
+
- lib/okbot/version.rb
|
174
|
+
- okbot.gemspec
|
175
|
+
- pkg/okbot-0.1.0.gem
|
176
|
+
homepage: http://rubygems.org/gems/okbot
|
177
|
+
licenses:
|
178
|
+
- MIT
|
179
|
+
metadata: {}
|
180
|
+
post_install_message:
|
181
|
+
rdoc_options: []
|
182
|
+
require_paths:
|
183
|
+
- lib
|
184
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - ">="
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
requirements: []
|
195
|
+
rubyforge_project:
|
196
|
+
rubygems_version: 2.4.8
|
197
|
+
signing_key:
|
198
|
+
specification_version: 4
|
199
|
+
summary: BLITZ and StackOverFlow
|
200
|
+
test_files: []
|