getbox 1.0.2 → 1.0.3
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/LICENSE +15 -0
- data/exe/getbox +2 -1
- data/lib/getbox/version.rb +1 -1
- data/lib/getbox.rb +33 -12
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba395aad4fccc81e34417d3ffa624864f720d881
|
4
|
+
data.tar.gz: 07c6d0877971f2b5a456b1fdef749dbcffb81b6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3519966842070571c56e84be6ad35e89a879f09e583c49799ad63c61a319c7563602030a9352e26f769df0a30d693dad17aa1fae7b5bfefde0e1a6a2df70b15d
|
7
|
+
data.tar.gz: 3137e1115833ae6b5d77130bf18ba892d5cae7c6dc82dc29c95270296fd275651314059170f1dcf69b53d6fed01fb8041b2d4e089d03e545f7d0ffd77c9a40a7
|
data/LICENSE
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Copyright (c) 2015, Andrew Monks <a@monks.co>
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for
|
4
|
+
any purpose with or without fee is hereby granted, provided that the
|
5
|
+
above copyright notice and this permission notice appear in all
|
6
|
+
copies.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
9
|
+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
10
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
11
|
+
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
12
|
+
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
|
13
|
+
OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
14
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
data/exe/getbox
CHANGED
data/lib/getbox/version.rb
CHANGED
data/lib/getbox.rb
CHANGED
@@ -1,24 +1,36 @@
|
|
1
1
|
require 'getbox/version'
|
2
|
-
require 'nokogiri'
|
3
|
-
require 'capybara/dsl'
|
4
|
-
require 'capybara-webkit'
|
5
|
-
require '
|
6
|
-
require 'json'
|
7
|
-
|
2
|
+
require 'nokogiri' # for parsing html
|
3
|
+
require 'capybara/dsl' # to operate the headless browser
|
4
|
+
require 'capybara-webkit' # the headless browser
|
5
|
+
require 'json' # for pretty json output
|
8
6
|
|
9
7
|
module Getbox
|
10
|
-
include Capybara::DSL
|
11
8
|
|
9
|
+
# configure Capybara
|
10
|
+
include Capybara::DSL
|
12
11
|
Capybara.default_driver = :webkit
|
13
12
|
Capybara.app_host = "http://app.gistboxapp.com"
|
14
13
|
Capybara.run_server = false
|
15
14
|
|
15
|
+
# to use getbox interactively and write output to a file
|
16
16
|
def prompt()
|
17
|
+
# people shouldn't feel comfortable typing passwords into things.
|
18
|
+
puts \
|
19
|
+
"I'm about to ask for your github password. \n"\
|
20
|
+
"You should probably read my source code\n"\
|
21
|
+
"before you go through with this...\n"\
|
22
|
+
"https://github.com/amonks/getbox/blob/master/lib/getbox.rb\n\n"\
|
23
|
+
\
|
24
|
+
"are you sure you want to continue?"
|
25
|
+
|
26
|
+
raise "Well, OK then." if gets.chomp.downcase.include? "no"
|
27
|
+
|
17
28
|
puts "What's your github username?"
|
18
29
|
username = gets.chomp
|
19
30
|
puts "How about your password, eh??"
|
20
31
|
password = gets.chomp
|
21
32
|
|
33
|
+
# doesn't support anything cool like ~, only a locally relative path
|
22
34
|
puts "Where should I save your gists? [gists.json]"
|
23
35
|
file = gets.chomp
|
24
36
|
file = "gists.json" if file.empty?
|
@@ -29,27 +41,34 @@ module Getbox
|
|
29
41
|
writeToFile(gists, file)
|
30
42
|
end
|
31
43
|
|
44
|
+
# method to go to app.gistboxapp.com, and log in with github credentials
|
32
45
|
def getGistsFromSite(username, password)
|
46
|
+
# partly to avoid warnings, and partly to avoid hitting analytics
|
33
47
|
whitelist_urls
|
34
48
|
|
35
49
|
puts "visiting app.gistboxapp.com"
|
36
50
|
visit '/'
|
37
|
-
click_on "Login"
|
51
|
+
click_on "Login" # redirect to github login page
|
52
|
+
|
38
53
|
puts "filling out github login form"
|
39
54
|
within("#login") do
|
40
55
|
fill_in("login", :with => username)
|
41
56
|
fill_in("password", :with => password)
|
42
|
-
click_on "Sign in"
|
57
|
+
click_on "Sign in" # back to gistbox.app
|
43
58
|
end
|
59
|
+
|
44
60
|
puts "gathering gists"
|
45
61
|
getGistsFromHtml(page.html)
|
46
62
|
end
|
47
63
|
|
64
|
+
# convenience wrapper for file.open.
|
65
|
+
# saving gistbox's dashboard html in chrome is faster than fetching it in ruby.
|
48
66
|
def getGistsFromFile(file)
|
49
67
|
f = File.open(file)
|
50
68
|
getGistsFromHtml(f)
|
51
69
|
end
|
52
70
|
|
71
|
+
# main function to parse the gist data from gistbox's interface
|
53
72
|
def getGistsFromHtml(html)
|
54
73
|
doc = Nokogiri::HTML(html)
|
55
74
|
|
@@ -79,15 +98,17 @@ module Getbox
|
|
79
98
|
gists
|
80
99
|
end
|
81
100
|
|
101
|
+
# convenience wrapper for json-and-print
|
82
102
|
def writeToFile(object, file)
|
83
103
|
json = JSON.pretty_generate(object)
|
84
|
-
File.open(file, 'w') { |
|
104
|
+
File.open(file, 'w') { |f| f.write(json) }
|
85
105
|
end
|
86
106
|
|
107
|
+
# set up capybara-webkit's whitelest
|
87
108
|
def whitelist_urls()
|
88
|
-
page.driver.block_unknown_urls
|
109
|
+
page.driver.block_unknown_urls # block tracking and media, disable warnings
|
89
110
|
urls = [
|
90
|
-
'app.gistboxapp.com',
|
111
|
+
'app.gistboxapp.com', # whitelist the servers we need
|
91
112
|
'github.com',
|
92
113
|
]
|
93
114
|
urls.each { |url| page.driver.allow_url(url) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: getbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Monks
|
@@ -90,6 +90,7 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- ".gitignore"
|
92
92
|
- Gemfile
|
93
|
+
- LICENSE
|
93
94
|
- README.md
|
94
95
|
- Rakefile
|
95
96
|
- exe/getbox
|