fbapp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +26 -0
- data/Rakefile +2 -0
- data/bin/fbapp +4 -0
- data/fbapp.gemspec +25 -0
- data/lib/fbapp.rb +9 -0
- data/lib/fbapp/cli.rb +20 -0
- data/lib/fbapp/drivers/base.rb +27 -0
- data/lib/fbapp/drivers/celerity.rb +41 -0
- data/lib/fbapp/drivers/mechanize.rb +51 -0
- data/lib/fbapp/version.rb +3 -0
- metadata +124 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fbapp (0.0.1)
|
5
|
+
highline (~> 1.6)
|
6
|
+
mechanize (~> 1.0)
|
7
|
+
thor (= 0.14.3)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
highline (1.6.1)
|
13
|
+
mechanize (1.0.0)
|
14
|
+
nokogiri (>= 1.2.1)
|
15
|
+
nokogiri (1.4.3.1)
|
16
|
+
thor (0.14.3)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
java
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
fbapp!
|
24
|
+
highline (~> 1.6)
|
25
|
+
mechanize (~> 1.0)
|
26
|
+
thor (= 0.14.3)
|
data/Rakefile
ADDED
data/bin/fbapp
ADDED
data/fbapp.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "fbapp/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "fbapp"
|
7
|
+
s.version = Fbapp::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ben Marini"]
|
10
|
+
s.email = ["bmarini@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/bmarini/fbapp"
|
12
|
+
s.summary = %q{Command line interface to your facebook apps}
|
13
|
+
s.description = %q{Command line interface to your facebook apps}
|
14
|
+
|
15
|
+
s.add_dependency "thor", "0.14.3"
|
16
|
+
# s.add_dependency "celerity", "0.8.2"
|
17
|
+
# s.add_dependency "jruby-openssl"
|
18
|
+
s.add_dependency "mechanize", "~> 1.0"
|
19
|
+
s.add_dependency "highline", "~> 1.6"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
end
|
data/lib/fbapp.rb
ADDED
data/lib/fbapp/cli.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Fbapp
|
4
|
+
class CLI < Thor
|
5
|
+
desc "list", "List your facebook apps"
|
6
|
+
def list
|
7
|
+
driver.list
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "show", "Show app settings"
|
11
|
+
def show(app)
|
12
|
+
driver.show(app)
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
def driver
|
17
|
+
@driver ||= Drivers::Mechanize.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'highline'
|
2
|
+
|
3
|
+
module Fbapp
|
4
|
+
module Drivers
|
5
|
+
class Base
|
6
|
+
|
7
|
+
def get_or_cache_credentials
|
8
|
+
credfile = File.expand_path("~/fbapp")
|
9
|
+
if File.exist?(credfile)
|
10
|
+
email, pass = File.read(credfile).split("\n")
|
11
|
+
else
|
12
|
+
highline = HighLine.new
|
13
|
+
email = highline.ask("Email: ")
|
14
|
+
pass = highline.ask("Password: ") { |q| q.echo = false }
|
15
|
+
|
16
|
+
File.open(credfile, "w+") do |f|
|
17
|
+
f.puts email
|
18
|
+
f.puts pass
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
return [email, pass]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "celerity"
|
2
|
+
|
3
|
+
module Fbapp
|
4
|
+
module Drivers
|
5
|
+
class Celerity < Base
|
6
|
+
def list
|
7
|
+
login
|
8
|
+
browser.goto("http://www.facebook.com/developers/apps.php")
|
9
|
+
puts browser.div(:id, "dev_app_list").text
|
10
|
+
end
|
11
|
+
|
12
|
+
def show(app)
|
13
|
+
login
|
14
|
+
browser.goto("http://www.facebook.com/developers/apps.php")
|
15
|
+
lnk = browser.div(:id, "dev_app_list").links.find { |l| l.text == app }
|
16
|
+
lnk.click
|
17
|
+
|
18
|
+
id = lnk.parent.id.split("_").first
|
19
|
+
dl = browser.div(:id, "#{id}_info").div(:class, "dev_application_info").dl
|
20
|
+
|
21
|
+
titles, values = dl.dts, dl.dds
|
22
|
+
titles.zip(values).each do |k, v|
|
23
|
+
puts "#{k.text.ljust(19)} : #{v.text}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def browser
|
28
|
+
@browser ||= ::Celerity::Browser.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def login
|
32
|
+
email, pass = get_or_cache_credentials
|
33
|
+
browser.goto("http://www.facebook.com")
|
34
|
+
browser.text_field(:name, "email").value = email
|
35
|
+
browser.text_field(:name, "pass").value = pass
|
36
|
+
browser.button(:value, "Login").click
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
|
3
|
+
module Fbapp
|
4
|
+
module Drivers
|
5
|
+
class Mechanize < Base
|
6
|
+
def list
|
7
|
+
login
|
8
|
+
page = browser.get("http://www.facebook.com/developers/apps.php")
|
9
|
+
page.search("#dev_app_list a").each do |app|
|
10
|
+
puts " * " + app.text
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def show(appname)
|
15
|
+
login
|
16
|
+
page = browser.get("http://www.facebook.com/developers/apps.php")
|
17
|
+
link = page.search("#dev_app_list a").find { |a| a.text == appname }
|
18
|
+
|
19
|
+
id = link.parent["id"].split("_").first
|
20
|
+
dl = page.search("##{id}_info .dev_application_info dl")
|
21
|
+
|
22
|
+
titles, values = dl.search("dt"), dl.search("dd")
|
23
|
+
titles = titles.to_a.map { |t| t.text }
|
24
|
+
values = values.to_a.map { |v| v.text }
|
25
|
+
|
26
|
+
puts "Settings for #{appname}:"
|
27
|
+
|
28
|
+
settings = Hash[ titles.zip(values) ]
|
29
|
+
titles.sort.each do |title|
|
30
|
+
puts "* #{title.ljust(19)} : #{settings[title]}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def browser
|
35
|
+
@browser ||= ::Mechanize.new
|
36
|
+
end
|
37
|
+
|
38
|
+
def login
|
39
|
+
email, pass = get_or_cache_credentials
|
40
|
+
|
41
|
+
page = browser.get("http://www.facebook.com")
|
42
|
+
form = page.forms.first
|
43
|
+
form.email = email
|
44
|
+
form.pass = pass
|
45
|
+
|
46
|
+
browser.submit(form)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fbapp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Ben Marini
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-24 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: thor
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - "="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 33
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 14
|
33
|
+
- 3
|
34
|
+
version: 0.14.3
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: mechanize
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 15
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 0
|
49
|
+
version: "1.0"
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: highline
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 6
|
64
|
+
version: "1.6"
|
65
|
+
type: :runtime
|
66
|
+
version_requirements: *id003
|
67
|
+
description: Command line interface to your facebook apps
|
68
|
+
email:
|
69
|
+
- bmarini@gmail.com
|
70
|
+
executables:
|
71
|
+
- fbapp
|
72
|
+
extensions: []
|
73
|
+
|
74
|
+
extra_rdoc_files: []
|
75
|
+
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- Rakefile
|
81
|
+
- bin/fbapp
|
82
|
+
- fbapp.gemspec
|
83
|
+
- lib/fbapp.rb
|
84
|
+
- lib/fbapp/cli.rb
|
85
|
+
- lib/fbapp/drivers/base.rb
|
86
|
+
- lib/fbapp/drivers/celerity.rb
|
87
|
+
- lib/fbapp/drivers/mechanize.rb
|
88
|
+
- lib/fbapp/version.rb
|
89
|
+
has_rdoc: true
|
90
|
+
homepage: http://github.com/bmarini/fbapp
|
91
|
+
licenses: []
|
92
|
+
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
requirements: []
|
117
|
+
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 1.3.7
|
120
|
+
signing_key:
|
121
|
+
specification_version: 3
|
122
|
+
summary: Command line interface to your facebook apps
|
123
|
+
test_files: []
|
124
|
+
|