fbapp 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -0
- data/lib/fbapp/drivers/mechanize.rb +22 -5
- data/lib/fbapp/version.rb +1 -1
- metadata +4 -3
data/README.md
ADDED
@@ -3,21 +3,29 @@ require 'mechanize'
|
|
3
3
|
module Fbapp
|
4
4
|
module Drivers
|
5
5
|
class Mechanize < Base
|
6
|
+
|
7
|
+
App = Struct.new(:app_id, :name)
|
8
|
+
|
6
9
|
def list
|
7
10
|
login
|
8
11
|
page = browser.get("http://www.facebook.com/developers/apps.php")
|
9
|
-
page
|
10
|
-
|
12
|
+
apps = fetch_apps(page)
|
13
|
+
|
14
|
+
apps.each do |app|
|
15
|
+
puts " * %s %s" % [app.app_id, app.name]
|
11
16
|
end
|
12
17
|
end
|
13
18
|
|
14
19
|
def show(appname)
|
15
20
|
login
|
16
21
|
page = browser.get("http://www.facebook.com/developers/apps.php")
|
17
|
-
link = page.search("#dev_app_list a").find { |a| a.text == appname }
|
18
22
|
|
19
|
-
id
|
20
|
-
|
23
|
+
id = begin
|
24
|
+
apps = fetch_apps(page)
|
25
|
+
apps.find { |a| a.name == appname || a.app_id == appname }.app_id
|
26
|
+
end
|
27
|
+
|
28
|
+
dl = page.search("##{id}_info .dev_application_info dl")
|
21
29
|
|
22
30
|
titles, values = dl.search("dt"), dl.search("dd")
|
23
31
|
titles = titles.to_a.map { |t| t.text }
|
@@ -46,6 +54,15 @@ module Fbapp
|
|
46
54
|
browser.submit(form)
|
47
55
|
end
|
48
56
|
|
57
|
+
# Assumes page is http://www.facebook.com/developers/apps.php
|
58
|
+
def fetch_apps(page)
|
59
|
+
page.search("#dev_app_list a").collect do |a|
|
60
|
+
id = a.parent["id"].split("_").first
|
61
|
+
name = a.text
|
62
|
+
|
63
|
+
App.new(id, name)
|
64
|
+
end
|
65
|
+
end
|
49
66
|
end
|
50
67
|
end
|
51
68
|
end
|
data/lib/fbapp/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Marini
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- .gitignore
|
78
78
|
- Gemfile
|
79
79
|
- Gemfile.lock
|
80
|
+
- README.md
|
80
81
|
- Rakefile
|
81
82
|
- bin/fbapp
|
82
83
|
- fbapp.gemspec
|