fb_joy 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -0
- data/Gemfile.lock +38 -0
- data/LICENSE +20 -0
- data/README.md +78 -0
- data/Rakefile +39 -0
- data/VERSION +1 -0
- data/fb_joy.gemspec +88 -0
- data/lib/fb_joy.rb +12 -0
- data/lib/joey/action.rb +16 -0
- data/lib/joey/affiliation.rb +15 -0
- data/lib/joey/album.rb +42 -0
- data/lib/joey/comment.rb +20 -0
- data/lib/joey/education.rb +20 -0
- data/lib/joey/education_history.rb +15 -0
- data/lib/joey/fetching_array.rb +26 -0
- data/lib/joey/hs_info.rb +15 -0
- data/lib/joey/image.rb +5 -0
- data/lib/joey/like.rb +13 -0
- data/lib/joey/location.rb +17 -0
- data/lib/joey/model.rb +84 -0
- data/lib/joey/page.rb +31 -0
- data/lib/joey/parser_helpers.rb +7 -0
- data/lib/joey/photo.rb +41 -0
- data/lib/joey/post.rb +67 -0
- data/lib/joey/privacy.rb +15 -0
- data/lib/joey/profile.rb +33 -0
- data/lib/joey/property.rb +15 -0
- data/lib/joey/relative.rb +15 -0
- data/lib/joey/rest_api.rb +116 -0
- data/lib/joey/status.rb +15 -0
- data/lib/joey/tag.rb +15 -0
- data/lib/joey/television.rb +15 -0
- data/lib/joey/user.rb +83 -0
- data/lib/joey/version.rb +9 -0
- data/lib/joey/video.rb +22 -0
- data/lib/joey/work.rb +20 -0
- data/lib/joey/work_history.rb +18 -0
- metadata +167 -0
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'hashie'
|
4
|
+
|
5
|
+
# Add dependencies to develop your gem here.
|
6
|
+
# Include everything needed to run rake, tests, features, etc.
|
7
|
+
group :development do
|
8
|
+
gem "rspec", ">= 2.3.0"
|
9
|
+
gem "bundler", ">= 1.0.0"
|
10
|
+
gem "jeweler", ">= 1.6.3"
|
11
|
+
# gem 'yard'
|
12
|
+
gem "simplecov", ">= 0.5"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
git (1.2.5)
|
6
|
+
hashie (1.2.0)
|
7
|
+
jeweler (1.8.3)
|
8
|
+
bundler (~> 1.0)
|
9
|
+
git (>= 1.2.5)
|
10
|
+
rake
|
11
|
+
rdoc
|
12
|
+
json (1.6.6)
|
13
|
+
multi_json (1.3.2)
|
14
|
+
rake (0.9.2.2)
|
15
|
+
rdoc (3.12)
|
16
|
+
json (~> 1.4)
|
17
|
+
rspec (2.9.0)
|
18
|
+
rspec-core (~> 2.9.0)
|
19
|
+
rspec-expectations (~> 2.9.0)
|
20
|
+
rspec-mocks (~> 2.9.0)
|
21
|
+
rspec-core (2.9.0)
|
22
|
+
rspec-expectations (2.9.1)
|
23
|
+
diff-lcs (~> 1.1.3)
|
24
|
+
rspec-mocks (2.9.0)
|
25
|
+
simplecov (0.6.1)
|
26
|
+
multi_json (~> 1.0)
|
27
|
+
simplecov-html (~> 0.5.3)
|
28
|
+
simplecov-html (0.5.3)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bundler (>= 1.0.0)
|
35
|
+
hashie
|
36
|
+
jeweler (>= 1.6.3)
|
37
|
+
rspec (>= 2.3.0)
|
38
|
+
simplecov (>= 0.5)
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Waseem Ahmad
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
## FB Joy
|
2
|
+
|
3
|
+
FB Joy is Joey with a few fixes added.
|
4
|
+
|
5
|
+
Joey(<a href="http://github.com/waseem/joey">http://github.com/waseem/joey</a>) provides object wrappers for nodes in the Facebook OpenGraph. It also provides wrappers for the data returned from facebook REST api. This gem depends upon Koala(<a href="http://github.com/arsduo/koala">http://github.com/arsduo/koala</a>).
|
6
|
+
|
7
|
+
This discussion(<a href="http://groups.google.com/group/koala-users/browse_thread/thread/650be4f3377aef48">http://groups.google.com/group/koala-users/browse_thread/thread/650be4f3377aef48</a>) sums up the motivation to create Joey and what it intends to accomplish.
|
8
|
+
|
9
|
+
### Wrappers
|
10
|
+
|
11
|
+
Koala is a lightweight Ruby library which provides an interface to access Facebook Open Graph and REST API.
|
12
|
+
|
13
|
+
Facebook servers return data in the form of Json or XML. When you use Koala to make requests to the Graph, it converts the returned Json into ready to be used Ruby hashes. e.g.
|
14
|
+
|
15
|
+
koala_client = Koala::Facebook::GraphAndRestAPI.new(access_token)
|
16
|
+
# http://graph.facebook.com/me
|
17
|
+
me = koala_client.get_object('me')
|
18
|
+
# => {"name"=>"Phuddu Bandar", "timezone"=>5.5, "gender"=>"male", "id"=>"100000654222309", "birthday"=>"12/01/1986", "last_name"=>"Bandar", "updated_time"=>"2010-01-10T16:35:06+0000", "hometown"=>{"name"=>nil, "id"=>nil}, "link"=>"http://www.facebook.com/profile.php?id=100000654222309", "email"=>"phuddu.bandar@gmail.com", "first_name"=>"Phuddu"}
|
19
|
+
|
20
|
+
me['name'] # => 'Phuddu Bandar'
|
21
|
+
me['gender'] # => 'male'
|
22
|
+
me['hometown']['name'] # => nil
|
23
|
+
|
24
|
+
Above when tried with joey returns a Joey::User object. We can access different information associated with a user using accessor methods instead of hash keys.
|
25
|
+
|
26
|
+
koala_client = Koala::Facebook::GraphAndRestAPI.new(access_token)
|
27
|
+
# http://graph.facebook.com/me
|
28
|
+
me = koala_client.me
|
29
|
+
# => <#Joey::User about=nil about_me=nil activities=nil birthday="12/01/1986" birthday_date=nil books=nil email="phuddu.bandar@gmail.com" first_name="Phuddu" gender="male" id="100000654222309" interests=nil is_app_user=nil is_blocked=nil last_name="Bandar" link="http://www.facebook.com/profile.php?id=100000654222309" locale=nil meeting_for=nil meeting_sex=nil middle_name=nil movies=nil music=nil name="Phuddu Bandar" notes_count=nil pic=nil pic_big=nil pic_big_with_logo=nil pic_small=nil pic_small_with_logo=nil pic_square=nil pic_square_with_logo=nil pic_with_logo=nil political=nil profile_blurb=nil profile_update_time=nil profile_url=nil quotes=nil relationship_status=nil religion=nil sex=nil significant_other_id=nil timezone=5.5 tv=nil uid=nil updated_time="2010-01-10T16:35:06+0000" username=nil verified=nil wall_count=nil website=nil>
|
30
|
+
|
31
|
+
me.name # => 'Phuddu Bandar'
|
32
|
+
me.gender # => 'male'
|
33
|
+
me.hometown.name # => nil
|
34
|
+
|
35
|
+
|
36
|
+
The main advantage of creating wrapper classes for different nodes in the Graph is that one can add custom methods to different objects. e.g.
|
37
|
+
|
38
|
+
In Open Graph there is no method to know if a user has given some particular extended permission to your application. However in old REST api there is <a href="http://developers.facebook.com/docs/reference/rest/users.hasAppPermission">users.hasAppPermission</a> for the same.
|
39
|
+
|
40
|
+
If we use plain Koala, we can implement it in following way:
|
41
|
+
|
42
|
+
!koala_client.rest_call('users.hasAppPermission', :ext_perm => 'email').zero? # => true or false
|
43
|
+
|
44
|
+
In Joey, call to users.hasAppPermission is sheilded behind a Joey::User#has_app_permission?(ext_perm)
|
45
|
+
|
46
|
+
me = koala_client.me
|
47
|
+
me.has_app_permission?(:email) # => true or false
|
48
|
+
|
49
|
+
A more complex use case arises when someone intends to add application specific methods to different nodes. e.g.
|
50
|
+
|
51
|
+
An application intends to know if a user has given his proxy email while giving the email extended permission. One can include a module with custom methods.
|
52
|
+
|
53
|
+
module FacebookUser
|
54
|
+
|
55
|
+
def self.included(base)
|
56
|
+
base.extend(ClassMethods)
|
57
|
+
end
|
58
|
+
|
59
|
+
module ClassMethods
|
60
|
+
end
|
61
|
+
|
62
|
+
def has_proxy_email?
|
63
|
+
if self.has_app_permission?(:email)
|
64
|
+
return self.email =~ /@proxymail\.facebook\.com/
|
65
|
+
else
|
66
|
+
return true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
and somewhere when you intialize your application like 'config/initializers/joey_patch.rb' in Rails
|
72
|
+
|
73
|
+
Joey::User.send(:include, FacebookUser)
|
74
|
+
|
75
|
+
Now one can do
|
76
|
+
|
77
|
+
me = koala_client.me
|
78
|
+
me.has_proxy_email? # => true or false
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "fb_joy"
|
18
|
+
gem.homepage = "http://github.com/kristianmandrup/joey"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "Ruby Wrapper API for Facebook OpenGraph"
|
21
|
+
gem.description = "Object wrappers for nodes in the Facebook OpenGraph"
|
22
|
+
gem.email = "talk.to.waseem@gmail.com"
|
23
|
+
gem.authors = ["Waseem Ahmad"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
data/fb_joy.gemspec
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "fb_joy"
|
8
|
+
s.version = "0.1.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Waseem Ahmad"]
|
12
|
+
s.date = "2012-05-07"
|
13
|
+
s.description = "Object wrappers for nodes in the Facebook OpenGraph"
|
14
|
+
s.email = "talk.to.waseem@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"fb_joy.gemspec",
|
27
|
+
"lib/fb_joy.rb",
|
28
|
+
"lib/joey/action.rb",
|
29
|
+
"lib/joey/affiliation.rb",
|
30
|
+
"lib/joey/album.rb",
|
31
|
+
"lib/joey/comment.rb",
|
32
|
+
"lib/joey/education.rb",
|
33
|
+
"lib/joey/education_history.rb",
|
34
|
+
"lib/joey/fetching_array.rb",
|
35
|
+
"lib/joey/hs_info.rb",
|
36
|
+
"lib/joey/image.rb",
|
37
|
+
"lib/joey/like.rb",
|
38
|
+
"lib/joey/location.rb",
|
39
|
+
"lib/joey/model.rb",
|
40
|
+
"lib/joey/page.rb",
|
41
|
+
"lib/joey/parser_helpers.rb",
|
42
|
+
"lib/joey/photo.rb",
|
43
|
+
"lib/joey/post.rb",
|
44
|
+
"lib/joey/privacy.rb",
|
45
|
+
"lib/joey/profile.rb",
|
46
|
+
"lib/joey/property.rb",
|
47
|
+
"lib/joey/relative.rb",
|
48
|
+
"lib/joey/rest_api.rb",
|
49
|
+
"lib/joey/status.rb",
|
50
|
+
"lib/joey/tag.rb",
|
51
|
+
"lib/joey/television.rb",
|
52
|
+
"lib/joey/user.rb",
|
53
|
+
"lib/joey/version.rb",
|
54
|
+
"lib/joey/video.rb",
|
55
|
+
"lib/joey/work.rb",
|
56
|
+
"lib/joey/work_history.rb"
|
57
|
+
]
|
58
|
+
s.homepage = "http://github.com/kristianmandrup/joey"
|
59
|
+
s.licenses = ["MIT"]
|
60
|
+
s.require_paths = ["lib"]
|
61
|
+
s.rubygems_version = "1.8.24"
|
62
|
+
s.summary = "Ruby Wrapper API for Facebook OpenGraph"
|
63
|
+
|
64
|
+
if s.respond_to? :specification_version then
|
65
|
+
s.specification_version = 3
|
66
|
+
|
67
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
|
+
s.add_runtime_dependency(%q<hashie>, [">= 0"])
|
69
|
+
s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
|
70
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
71
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.6.3"])
|
72
|
+
s.add_development_dependency(%q<simplecov>, [">= 0.5"])
|
73
|
+
else
|
74
|
+
s.add_dependency(%q<hashie>, [">= 0"])
|
75
|
+
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
76
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
77
|
+
s.add_dependency(%q<jeweler>, [">= 1.6.3"])
|
78
|
+
s.add_dependency(%q<simplecov>, [">= 0.5"])
|
79
|
+
end
|
80
|
+
else
|
81
|
+
s.add_dependency(%q<hashie>, [">= 0"])
|
82
|
+
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
83
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
84
|
+
s.add_dependency(%q<jeweler>, [">= 1.6.3"])
|
85
|
+
s.add_dependency(%q<simplecov>, [">= 0.5"])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
data/lib/fb_joy.rb
ADDED
data/lib/joey/action.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Joey
|
2
|
+
class Action < Model
|
3
|
+
define_properties :name, :link
|
4
|
+
|
5
|
+
def validate
|
6
|
+
errors << { :message => "name should String but is #{name.inspect}" } unless name.is_a?(String)
|
7
|
+
errors << { :message => "link should String but is #{link.inspect}" } unless link.is_a?(String)
|
8
|
+
end
|
9
|
+
|
10
|
+
def valid?
|
11
|
+
self.validate
|
12
|
+
puts self.errors.inspect unless self.errors.empty?
|
13
|
+
self.errors.empty?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Joey
|
2
|
+
class Affiliation < Model
|
3
|
+
define_properties :type, :year, :name, :nid, :status
|
4
|
+
|
5
|
+
def validate
|
6
|
+
valid = true
|
7
|
+
end
|
8
|
+
|
9
|
+
def valid?
|
10
|
+
self.validate
|
11
|
+
puts self.errors.inspect unless self.errors.empty?
|
12
|
+
self.errors.empty?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/joey/album.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Joey
|
2
|
+
class Album < Model
|
3
|
+
|
4
|
+
define_properties :id, :name, :description, :link, :count, :created_time, :updated_time, :privacy, :location, :type, :picture,
|
5
|
+
:cover_photo
|
6
|
+
#creation_properties :name, :message
|
7
|
+
|
8
|
+
hash_populating_accessor :from, "User", "Page"
|
9
|
+
hash_populating_association :comments, "Comment"
|
10
|
+
# hash_populating_accessor :photos, "Photo"
|
11
|
+
# has_association :photos, "Photo"
|
12
|
+
hash_populating_association :photos, "Photo"
|
13
|
+
|
14
|
+
def validate
|
15
|
+
created_time.to_time rescue errors << { :message => 'created_time is not compatible' }
|
16
|
+
updated_time.to_time rescue errors << { :message => 'updated_time is not compatible' }
|
17
|
+
errors << { :message => 'id should not be nil' } if id.nil?
|
18
|
+
errors << { :message => "name is neither string nor nil but is #{name.inspect}" } unless name.is_a?(String) || name.nil?
|
19
|
+
errors << { :message => "description is neither string nor nil but is #{description.inspect}" } unless description.is_a?(String) || description.nil?
|
20
|
+
errors << { :message => "link is not a string but is #{link.inspect}" } unless link.is_a?(String)
|
21
|
+
errors << { :message => "count is neither integer nor nil but is #{count.inspect}" } unless count.is_a?(Integer) || count.nil?
|
22
|
+
errors << { :message => "location is neither string nor nil but is #{location.inspect}" } unless location.is_a?(String) || location.nil?
|
23
|
+
errors << { :message => "from is not a Joey::User or Joey::Page and is #{from.inspect}" } unless from.is_a?(Joey::User) || from.is_a?(Joey::Page)
|
24
|
+
|
25
|
+
#errors << { :message => "comments is not an array nor nil and is #{comments.inspect}" } unless comments.is_a?(Array) || comments.nil?
|
26
|
+
#if comments.is_a?(Array) && !(comments.collect(&:class).uniq - [Joey::Comment]).empty?
|
27
|
+
#errors << { :message => 'comments is not an array of Joey::Comment' }
|
28
|
+
#end
|
29
|
+
|
30
|
+
#errors << { :message => "photos is not an array nor nil and is #{photos.inspect}" } unless photos.is_a?(Array) || photos.nil?
|
31
|
+
#if photos.is_a?(Array) && !(photos.collect(&:class).uniq - [Joey::Photo]).empty?
|
32
|
+
#errors << { :message => 'photos is not an array of Joey::Comment' }
|
33
|
+
#end
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid?
|
37
|
+
self.validate
|
38
|
+
puts self.errors.inspect unless self.errors.empty?
|
39
|
+
self.errors.empty?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/joey/comment.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Joey
|
2
|
+
class Comment < Model
|
3
|
+
define_properties :id, :message, :created_time, :count, :likes
|
4
|
+
#creation_properties :message
|
5
|
+
hash_populating_accessor :from, "User","Page"
|
6
|
+
|
7
|
+
def validate
|
8
|
+
created_time.to_time rescue errors << { :message => 'created_time is not compatible' }
|
9
|
+
# updated_time.to_time rescue errors << { :message => 'updated_time is not compatible' }
|
10
|
+
errors << { :message => 'id should not be nil' } if id.nil?
|
11
|
+
errors << { :message => 'from is not a Joey::User or Joey::Page' } unless from.is_a?(Joey::User) || from.is_a?(Joey::Page)
|
12
|
+
end
|
13
|
+
|
14
|
+
def valid?
|
15
|
+
self.validate
|
16
|
+
puts self.errors.inspect unless self.errors.empty?
|
17
|
+
self.errors.empty?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Joey
|
2
|
+
class Education < Model
|
3
|
+
|
4
|
+
define_properties :start_date, :end_date, :degree, :type
|
5
|
+
|
6
|
+
hash_populating_accessor :school, "Page"
|
7
|
+
hash_populating_accessor :year, "Page"
|
8
|
+
hash_populating_accessor :concentration, "Page"
|
9
|
+
|
10
|
+
def validate
|
11
|
+
valid = true
|
12
|
+
end
|
13
|
+
|
14
|
+
def valid?
|
15
|
+
self.validate
|
16
|
+
puts self.errors.inspect unless self.errors.empty?
|
17
|
+
self.errors.empty?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Joey
|
2
|
+
class EducationHistory < Model
|
3
|
+
define_properties :name, :degree, :year, :school_type, :concentrations
|
4
|
+
|
5
|
+
def validate
|
6
|
+
valid = true
|
7
|
+
end
|
8
|
+
|
9
|
+
def valid?
|
10
|
+
self.validate
|
11
|
+
puts self.errors.inspect unless self.errors.empty?
|
12
|
+
self.errors.empty?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Joey
|
2
|
+
class FetchingArray < Array
|
3
|
+
attr_accessor :next_url, :previous_url, :client, :classes, :count
|
4
|
+
|
5
|
+
def fetch_next
|
6
|
+
return [] if next_url.blank?
|
7
|
+
# FIXME: following only returns a hash like {"id"=>"http://graph.facebook.com/100000637452380/feed"}
|
8
|
+
# try to write a method in koala which can request absolute urls
|
9
|
+
additions = client.get_and_map_url(next_url, classes)
|
10
|
+
self.next_url = additions.next_url
|
11
|
+
self.concat(additions)
|
12
|
+
additions
|
13
|
+
end
|
14
|
+
|
15
|
+
def fetch_previous
|
16
|
+
return [] if previous_url.blank?
|
17
|
+
# FIXME: following only returns a hash like {"id"=>"http://graph.facebook.com/100000637452380/feed"}
|
18
|
+
# try to write a method in koala which can request absolute urls
|
19
|
+
additions = client.get_and_map_url(previous_url, classes)
|
20
|
+
self.previous_url = additions.previous_url
|
21
|
+
self.unshift(*additions)
|
22
|
+
additions
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|