rest-graph 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "task"]
2
+ path = task
3
+ url = git://github.com/godfat/gemgem.git
data/CHANGES CHANGED
@@ -1,5 +1,36 @@
1
1
  = rest-graph changes history
2
2
 
3
+ == rest-graph 1.9.0 -- 2011-05-26
4
+
5
+ * [RestGraph] Removed deprecated rest-graph/auto_load.rb, and
6
+ rest-graph/autoload.rb. Please simply require 'rest-graph'
7
+
8
+ * [RestGraph] Removed deprecated strict option. Facebook had fixed their bug.
9
+
10
+ * [RestGraph] Removed deprecated broken_old_rest. Please use old_rest instead.
11
+
12
+ * [RestGraph] Removed deprecated suppress_decode. Plz use auto_decode instead.
13
+
14
+ * [RestGraph] Introduced RestGraph#attributes.
15
+
16
+ * [RestGraph] RestGraph#lighten and RestGraph#lighten! now takes an extra
17
+ argument which let you set attributes.
18
+
19
+ * [RestGraph] Now RestGraph#get/post has an option for timeout which
20
+ make this request use this timeout instead of the default one.
21
+
22
+ * [RestGraph] URI.encode on Facebook's broken paging URL. (thanks andy)
23
+
24
+ * [RestGraph] Now all old_rest based methods accept a :post option, which
25
+ means use POST for this API request, but still treating it
26
+ a GET request for rest-graph, so that caching and other
27
+ similar features would still work.
28
+
29
+ The reason for this option is that some FQL could be very long,
30
+ FQL multiquery could be even much more longer! Long URLs might
31
+ cause problems, thus we have provided this option to use POST
32
+ instead.
33
+
3
34
  == rest-graph 1.8.0 -- 2011-03-08
4
35
 
5
36
  * [RestGraph] Now require 'rest-graph/autoload' is deprecated, simply use
data/CONTRIBUTORS CHANGED
@@ -1,9 +1,10 @@
1
1
  Lin Jen-Shin (godfat)
2
+ Barnabas Debreczeni (keo)
3
+ John Fan (johnfan)
2
4
  Jaime Cham (jcham)
3
5
  Andrew Liu (eggegg)
4
- John Fan (johnfan)
5
- Barnabas Debreczeni (keo)
6
+ Mariusz Pruszynski (snicky)
6
7
  Florent Vaucelle (florent)
7
8
  Ethan Czahor (ethanz5)
8
9
  Nicolas Fouché (nfo)
9
- Mariusz Pruszynski (snicky)
10
+ andy (coopsite)
data/README CHANGED
@@ -53,7 +53,7 @@ A lightweight Facebook Graph API client
53
53
 
54
54
  Or if you want development version, put this in Gemfile:
55
55
 
56
- gem 'rest-graph', :git => 'git://github.com/cardinalblue/rest-graph.git
56
+ gem 'rest-graph', :git => 'git://github.com/cardinalblue/rest-graph.git'
57
57
 
58
58
  Or as a Rails2 plugin:
59
59
 
@@ -187,36 +187,36 @@ options for RestGraph instance are also valid options for rest_graph_setup.
187
187
 
188
188
  1. Set upon RestGraph object creation:
189
189
 
190
- rg = RestGraph.new :app_id => 1234
190
+ rg = RestGraph.new :app_id => 1234
191
191
 
192
192
  2. Set via the rest_graph_setup call in a Controller:
193
193
 
194
- rest_graph_setup :app_id => 1234
194
+ rest_graph_setup :app_id => 1234
195
195
 
196
196
  3. Load from a YAML file
197
197
 
198
- require 'rest-graph/config_util'
199
- RestGraph.load_config('path/to/rest-graph.yaml', 'production')
200
- rg = RestGraph.new
198
+ require 'rest-graph/config_util'
199
+ RestGraph.load_config('path/to/rest-graph.yaml', 'production')
200
+ rg = RestGraph.new
201
201
 
202
202
  4. Load config automatically
203
203
 
204
- require 'rest-graph' # under Rails, would load config/rest-graph.yaml
205
- rg = RestGraph.new
204
+ require 'rest-graph' # under Rails, would load config/rest-graph.yaml
205
+ rg = RestGraph.new
206
206
 
207
207
  5. Override directly
208
208
 
209
- module MyDefaults
210
- def default_app_id
211
- '456'
212
- end
209
+ module MyDefaults
210
+ def default_app_id
211
+ '456'
212
+ end
213
213
 
214
- def default_secret
215
- 'category theory'
216
- end
217
- end
218
- RestGraph.send(:extend, MyDefaults)
219
- rg = RestGraph.new
214
+ def default_secret
215
+ 'category theory'
216
+ end
217
+ end
218
+ RestGraph.send(:extend, MyDefaults)
219
+ rg = RestGraph.new
220
220
 
221
221
  ## API REFERENCE:
222
222
 
@@ -230,16 +230,20 @@ options for RestGraph instance are also valid options for rest_graph_setup.
230
230
  rg.get('me', :metadata => '1')
231
231
 
232
232
  # extra options:
233
- # auto_decode: Bool # decode with json or not in this method call
233
+ # auto_decode: Bool # decode with json or not in this API request
234
234
  # # default: auto_decode in rest-graph instance
235
+ # timeout: Int # the timeout for this API request
236
+ # # default: timeout in rest-graph instance
235
237
  # secret: Bool # use secret_acccess_token or not
236
238
  # # default: false
237
239
  # cache: Bool # use cache or not; if it's false, update cache, too
238
240
  # # default: true
239
241
  # expires_in: Int # control when would the cache be expired
240
- # # default: nothing
242
+ # # default: nil
241
243
  # async: Bool # use eventmachine for http client or not
242
244
  # # default: false, but true in aget family
245
+ # headers: Hash # additional hash you want to pass
246
+ # # default: {}
243
247
  rg.get('me', {:metadata => '1'}, :secret => true, expires_in => 600)
244
248
 
245
249
  #### post
data/README.md CHANGED
@@ -53,7 +53,7 @@ A lightweight Facebook Graph API client
53
53
 
54
54
  Or if you want development version, put this in Gemfile:
55
55
 
56
- gem 'rest-graph', :git => 'git://github.com/cardinalblue/rest-graph.git
56
+ gem 'rest-graph', :git => 'git://github.com/cardinalblue/rest-graph.git'
57
57
 
58
58
  Or as a Rails2 plugin:
59
59
 
@@ -187,36 +187,36 @@ options for RestGraph instance are also valid options for rest_graph_setup.
187
187
 
188
188
  1. Set upon RestGraph object creation:
189
189
 
190
- rg = RestGraph.new :app_id => 1234
190
+ rg = RestGraph.new :app_id => 1234
191
191
 
192
192
  2. Set via the rest_graph_setup call in a Controller:
193
193
 
194
- rest_graph_setup :app_id => 1234
194
+ rest_graph_setup :app_id => 1234
195
195
 
196
196
  3. Load from a YAML file
197
197
 
198
- require 'rest-graph/config_util'
199
- RestGraph.load_config('path/to/rest-graph.yaml', 'production')
200
- rg = RestGraph.new
198
+ require 'rest-graph/config_util'
199
+ RestGraph.load_config('path/to/rest-graph.yaml', 'production')
200
+ rg = RestGraph.new
201
201
 
202
202
  4. Load config automatically
203
203
 
204
- require 'rest-graph' # under Rails, would load config/rest-graph.yaml
205
- rg = RestGraph.new
204
+ require 'rest-graph' # under Rails, would load config/rest-graph.yaml
205
+ rg = RestGraph.new
206
206
 
207
207
  5. Override directly
208
208
 
209
- module MyDefaults
210
- def default_app_id
211
- '456'
212
- end
209
+ module MyDefaults
210
+ def default_app_id
211
+ '456'
212
+ end
213
213
 
214
- def default_secret
215
- 'category theory'
216
- end
217
- end
218
- RestGraph.send(:extend, MyDefaults)
219
- rg = RestGraph.new
214
+ def default_secret
215
+ 'category theory'
216
+ end
217
+ end
218
+ RestGraph.send(:extend, MyDefaults)
219
+ rg = RestGraph.new
220
220
 
221
221
  ## API REFERENCE:
222
222
 
@@ -230,16 +230,20 @@ options for RestGraph instance are also valid options for rest_graph_setup.
230
230
  rg.get('me', :metadata => '1')
231
231
 
232
232
  # extra options:
233
- # auto_decode: Bool # decode with json or not in this method call
233
+ # auto_decode: Bool # decode with json or not in this API request
234
234
  # # default: auto_decode in rest-graph instance
235
+ # timeout: Int # the timeout for this API request
236
+ # # default: timeout in rest-graph instance
235
237
  # secret: Bool # use secret_acccess_token or not
236
238
  # # default: false
237
239
  # cache: Bool # use cache or not; if it's false, update cache, too
238
240
  # # default: true
239
241
  # expires_in: Int # control when would the cache be expired
240
- # # default: nothing
242
+ # # default: nil
241
243
  # async: Bool # use eventmachine for http client or not
242
244
  # # default: false, but true in aget family
245
+ # headers: Hash # additional hash you want to pass
246
+ # # default: {}
243
247
  rg.get('me', {:metadata => '1'}, :secret => true, expires_in => 600)
244
248
 
245
249
  #### post
data/TODO CHANGED
@@ -8,4 +8,3 @@
8
8
  * error_handler can't be turned off
9
9
  * more docs?
10
10
  * more examples?
11
- * em is missing headers options
@@ -0,0 +1,186 @@
1
+ # Setting a Facebook app on Heroku
2
+
3
+ ## Software Installation and Configuration (1)
4
+
5
+ ### Mac OS
6
+
7
+ * Install Xcode from the install DVD or Apple website or Mac App Store.
8
+
9
+ * Install Homebrew (package manager).
10
+
11
+ curl https://gist.github.com/raw/323731/install_homebrew.rb > /tmp/install_homebrew.rb
12
+ ruby /tmp/install_homebrew.rb
13
+
14
+ * Install Git (source code manager).
15
+
16
+ brew install git
17
+
18
+ * Install database. You may pick anything that Rails supports, but since
19
+ Heroku uses PostgreSQL, we recommend to use the same database.
20
+
21
+ brew install postgresql
22
+ initdb /usr/local/var/postgres
23
+ pg_ctl -D /usr/local/var/postgres start
24
+ createuser --createdb YourProject
25
+
26
+ * Setup postgres to auto-start after boot.
27
+
28
+ cp `brew --prefix postgresql`/org.postgresql.postgres.plist ~/Library/LaunchAgents/
29
+ launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
30
+
31
+ * ...or start up postgres manually:
32
+
33
+ pg_ctl -D /usr/local/var/postgres start
34
+
35
+ * Install Ruby 1.9.2 (via Homebrew, but if you prefer RVM, it's fine).
36
+
37
+ brew install ruby
38
+
39
+ ### Ubuntu (Linux)
40
+
41
+ * Install various tools
42
+
43
+ sudo apt-get update
44
+ sudo apt-get install gcc g++ make libssl-dev zlib1g-dev libreadline5-dev libyaml-dev libxml2-dev
45
+
46
+ * Install Git (source code manger).
47
+
48
+ sudo apt-get install git
49
+
50
+ * Install database. You may pick anything Rails supports, but since
51
+ Heroku uses PostgreSQL, we recommend to use the same database.
52
+
53
+ sudo apt-get install postgresql libpq-dev
54
+ sudo /etc/init.d/postgresql restart
55
+ sudo -u postgres createuser --createdb YourProject
56
+
57
+ You might need to edit `pg_hba.conf` (the path would be something like this:
58
+ /etc/postgresql/8.4/main/pg_hba.conf) to make sure _YourProject_ has the
59
+ access to your local database. For example, has the following line:
60
+
61
+ local all YourProject trust
62
+
63
+ And make sure there's **NO** this line: (it conflicts with the above)
64
+
65
+ local all all ident
66
+
67
+ You should restart postgresql after updating `pg_hba.conf`
68
+
69
+ sudo /etc/init.d/postgresql restart
70
+
71
+ * Install Ruby 1.9.2
72
+
73
+ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
74
+ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> ~/.bash_profile
75
+ source $HOME/.rvm/scripts/rvm
76
+ rvm install 1.9.2
77
+ rvm use 1.9.2
78
+
79
+ ### Windows (not tested)
80
+
81
+ * Install Git <http://code.google.com/p/msysgit/downloads/list>
82
+ * Install Ruby 1.9.2 <http://rubyinstaller.org/downloads/>
83
+ * Install PostgreSQL <http://www.postgresql.org/download/>
84
+
85
+ ## Software Installation and Configuration (2)
86
+
87
+ ### General (OS-independent)
88
+
89
+ * Depending on the OS and your configuration, you may need to prefix with
90
+ "sudo" to install the gems. You don't have to if you're following the
91
+ instructions above to install Ruby (RVM or Homebrew), or running on Windows.
92
+
93
+ * Configure Git (~/.gitconfig)
94
+
95
+ git config --global user.name 'Your Name'
96
+ git config --global user.email 'your@email.com'
97
+
98
+ * Install gems
99
+
100
+ echo 'gem: --no-ri --no-rdoc' >> ~/.gemrc
101
+ gem install rails pg heroku
102
+
103
+ Note: on newer Macs, if pg fails to install, try this:
104
+
105
+ env ARCHFLAGS='-arch x86_64' gem install pg
106
+
107
+ * Generate RSA keys and upload to Heroku. (you'll need a [Heroku][] account)
108
+
109
+ ssh-keygen -t rsa -C 'your@email.com'
110
+ heroku keys:add ~/.ssh/id_rsa.pub
111
+
112
+ [Heroku]: http://heroku.com
113
+
114
+ ## Create a Rails application and push to Heroku
115
+
116
+ * Rails 3 project
117
+
118
+ rails new 'YourProject'
119
+ cd 'YourProject'
120
+
121
+ * Git initialization
122
+
123
+ git init
124
+ git add .
125
+ git commit -m 'first commit'
126
+
127
+ * Switch to PostgreSQL. Edit the Gemfile and change `gem 'sqlite3'` to `gem 'pg'`:
128
+
129
+ bundle check
130
+ git add Gemfile Gemfile.lock
131
+ git commit -m 'switch to postgresql'
132
+
133
+ * Set up the Heroku application
134
+
135
+ heroku create 'YourProject'
136
+
137
+ * Push to Heroku. (from local master branch to remote master branch)
138
+
139
+ git push heroku master:master
140
+
141
+ * Take a look at yourproject.heroku.com. If you have terminal browser lynx
142
+ installed, you can run this:
143
+
144
+ lynx yourproject.heroku.com
145
+
146
+ Otherwise, just use your favorite browser to view it.
147
+
148
+ ## For development, set up the application to run locally on your computer
149
+
150
+ * Edit `config/database.yml` with following:
151
+
152
+ development:
153
+ adapter: postgresql
154
+ username: YourProject
155
+ database: YourProject_development
156
+
157
+ test:
158
+ adapter: postgresql
159
+ username: YourProject
160
+ database: YourProject_test
161
+
162
+ * Setup local database
163
+
164
+ rake db:create
165
+ rake db:migrate
166
+ rake db:schema:dump # update schema.rb for reference
167
+ rake db:test:prepare # sometimes this is needed to run tests
168
+
169
+ * Run Ruby server (WEBrick)
170
+
171
+ rails server
172
+
173
+ * or run Thin server (need to update Gemfile with `gem 'thin'`)
174
+
175
+ gem install thin
176
+ rails server thin
177
+
178
+ ## Create a Facebook Application
179
+
180
+ * <http://devcenter.heroku.com/articles/facebook>
181
+
182
+ ## Using rest-graph
183
+
184
+ ### Tutorial
185
+
186
+ * <https://github.com/cardinalblue/samplergthree>
data/doc/tutorial.md CHANGED
@@ -28,6 +28,10 @@ The code in this tutorial could be found on [samplergthree][]
28
28
  gem 'rest-client', '>=1.6'
29
29
  gem 'json' # you may also use other JSON parsers/generators, i.e. 'yajl-ruby' or 'json_pure'
30
30
 
31
+ And run:
32
+
33
+ bundle install
34
+
31
35
 
32
36
  5. In order to configure your Rails application for the Facebook application you created, you must create a rest-graph.yaml file in your /config directory and fill it with your Facebook configuration. If you plan to run your application in the Facebook canvas, also provide a canvas name.
33
37
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  source 'http://rubygems.org'
3
3
 
4
- gem 'rails', '3.0.5'
4
+ gem 'rails', '3.0.7'
5
5
 
6
6
  gem 'rest-client' # for rest-graph
7
7
  gem 'yajl-ruby' # for rest-graph
@@ -0,0 +1,16 @@
1
+
2
+ require 'sinatra'
3
+ require 'rest-graph'
4
+
5
+ app_id = '123'
6
+ secret = 'abc'
7
+ config = {:app_id => app_id,
8
+ :secret => secret}
9
+
10
+ post '/' do
11
+ rg = RestGraph.new(config)
12
+ rg.parse_signed_request!(params['signed_request'])
13
+ "#{rg.get('me').inspect.gsub('<', '&lt;')}\n"
14
+ end
15
+
16
+ run Sinatra::Application