facebookcl 0.3.1 → 0.3.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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/facebookcl.gemspec +2 -2
  3. data/lib/facebookcl.rb +42 -21
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{facebookcl}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Bishop"]
12
- s.date = %q{2010-06-24}
12
+ s.date = %q{2010-06-25}
13
13
  s.default_executable = %q{facebook}
14
14
  s.description = %q{Retrofacebook. Interact via the commandline.}
15
15
  s.email = %q{jubishop@facebook.com}
@@ -24,36 +24,43 @@ module FacebookCL; class << self
24
24
  self.access_token = data['access_token']
25
25
  self.uid = data['uid']
26
26
  else
27
- auth_url = "https://#{GRAPH_URL}/oauth/authorize?client_id=#{APP_ID}&redirect_uri=#{NEXT_URL}&type=user_agent&display=page&scope=publish_stream,create_event,offline_access,email,read_stream,read_mailbox"
27
+ perms = ['publish_stream',
28
+ 'create_event',
29
+ 'offline_access',
30
+ 'email',
31
+ 'read_stream',
32
+ 'read_mailbox']
33
+
34
+ params = {'client_id' => APP_ID,
35
+ 'redirect_uri' => NEXT_URL,
36
+ 'type' => 'user_agent',
37
+ 'display' => 'page',
38
+ 'scope' => perms.join(',')}
39
+
40
+ auth_url = "https://#{GRAPH_URL}/oauth/authorize?" +
41
+ params.map{|key, value| "#{key}=#{value}"}.join('&')
42
+
28
43
  if (RUBY_PLATFORM.downcase.include?("darwin"))
29
44
  `open '#{auth_url}'`
30
45
  else
31
- puts %Q{
32
- Welcome New User! You need to auth this application. So please visit here in your browser of choice:
33
-
34
- #{auth_url}}
46
+ puts 'Welcome New User! ' +
47
+ 'You need to authorize FacebookCL. ' +
48
+ "Please visit this URL in your browser of choice: \n\n" +
49
+ auth_url
35
50
  end
36
51
 
37
- server = TCPServer.new('127.0.0.1', SERVER_PORT)
38
- session = server.accept
39
- session.print "HTTP/1.1 200/OK\r\nContent-type:text/html\r\n\r\n"
40
- session.gets
41
- session.print "
52
+ serve_content(%Q{
42
53
  <script>
43
54
  window.location.replace(window.location.toString().replace('#', '?'));
44
- </script>"
45
- session.close
46
-
47
- session = server.accept
48
- session.print "HTTP/1.1 200/OK\r\nContent-type:text/html\r\n\r\n"
49
- request = session.gets.strip
50
- session.print "Success!
51
- You can now close this window and return to FacebookCL.
55
+ </script>})
56
+
57
+ request = serve_content(%q{
58
+ Success! You can now close this window and return to FacebookCL.
52
59
  <script>
53
60
  window.close();
54
- </script>"
55
- session.close
56
- server.close
61
+ </script>})
62
+
63
+ @server.close
57
64
 
58
65
  self.access_token = request.
59
66
  gsub(/^GET \/\?access_token=/, '').
@@ -106,4 +113,18 @@ Welcome New User! You need to auth this application. So please visit here in y
106
113
  value
107
114
  end
108
115
  end
116
+
117
+ def serve_content(content)
118
+ @server ||= TCPServer.new('127.0.0.1', SERVER_PORT)
119
+
120
+ session = @server.accept
121
+ session.print "HTTP/1.1 200/OK\r\nContent-type:text/html\r\n\r\n"
122
+
123
+ request = session.gets.strip
124
+
125
+ session.print content
126
+ session.close
127
+
128
+ request
129
+ end
109
130
  end; end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebookcl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Bishop
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-24 00:00:00 -07:00
18
+ date: 2010-06-25 00:00:00 -07:00
19
19
  default_executable: facebook
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency