fb_graph 1.6.1 → 1.6.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.1
1
+ 1.6.2
data/fb_graph.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fb_graph}
8
- s.version = "1.6.1"
8
+ s.version = "1.6.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["nov matake"]
@@ -86,14 +86,14 @@ Gem::Specification.new do |s|
86
86
  "lib/fb_graph/friend_list.rb",
87
87
  "lib/fb_graph/group.rb",
88
88
  "lib/fb_graph/insight.rb",
89
+ "lib/fb_graph/klass.rb",
89
90
  "lib/fb_graph/link.rb",
90
91
  "lib/fb_graph/location.rb",
91
92
  "lib/fb_graph/message.rb",
92
93
  "lib/fb_graph/node.rb",
93
94
  "lib/fb_graph/note.rb",
94
95
  "lib/fb_graph/page.rb",
95
- "lib/fb_graph/page/categories.rb",
96
- "lib/fb_graph/page/categories/local_business.rb",
96
+ "lib/fb_graph/page/category_attributes.rb",
97
97
  "lib/fb_graph/photo.rb",
98
98
  "lib/fb_graph/place.rb",
99
99
  "lib/fb_graph/post.rb",
@@ -131,6 +131,10 @@ Gem::Specification.new do |s|
131
131
  "spec/fake_json/events/noreply/smartday_private.json",
132
132
  "spec/fake_json/groups/members/emacs_private.json",
133
133
  "spec/fake_json/pages/categories/local_business.json",
134
+ "spec/fake_json/pages/categories/movie.json",
135
+ "spec/fake_json/pages/categories/music.json",
136
+ "spec/fake_json/pages/categories/person.json",
137
+ "spec/fake_json/pages/categories/product.json",
134
138
  "spec/fake_json/pages/checkins/gowalla_private.json",
135
139
  "spec/fake_json/pages/checkins/gowalla_public.json",
136
140
  "spec/fake_json/pages/insights/FbGraph_private.json",
@@ -282,7 +286,11 @@ Gem::Specification.new do |s|
282
286
  "spec/fb_graph/message_spec.rb",
283
287
  "spec/fb_graph/node_spec.rb",
284
288
  "spec/fb_graph/note_spec.rb",
285
- "spec/fb_graph/page/categories/local_business_spec.rb",
289
+ "spec/fb_graph/page/local_business_spec.rb",
290
+ "spec/fb_graph/page/movie_spec.rb",
291
+ "spec/fb_graph/page/music_spec.rb",
292
+ "spec/fb_graph/page/person_spec.rb",
293
+ "spec/fb_graph/page/product_spec.rb",
286
294
  "spec/fb_graph/page_spec.rb",
287
295
  "spec/fb_graph/photo_spec.rb",
288
296
  "spec/fb_graph/place_spec.rb",
@@ -374,7 +382,11 @@ Gem::Specification.new do |s|
374
382
  "spec/fb_graph/message_spec.rb",
375
383
  "spec/fb_graph/node_spec.rb",
376
384
  "spec/fb_graph/note_spec.rb",
377
- "spec/fb_graph/page/categories/local_business_spec.rb",
385
+ "spec/fb_graph/page/local_business_spec.rb",
386
+ "spec/fb_graph/page/movie_spec.rb",
387
+ "spec/fb_graph/page/music_spec.rb",
388
+ "spec/fb_graph/page/person_spec.rb",
389
+ "spec/fb_graph/page/product_spec.rb",
378
390
  "spec/fb_graph/page_spec.rb",
379
391
  "spec/fb_graph/photo_spec.rb",
380
392
  "spec/fb_graph/place_spec.rb",
@@ -1,98 +1,4 @@
1
1
  module FbGraph
2
- # = Authentication
3
- #
4
- # * Access token is required to fetch album info.
5
- #
6
- # = Attributes
7
- #
8
- # +from+:: FbGraph::User or FbGraph::Page
9
- # +name+:: String
10
- # +description+:: String
11
- # +location+:: String <em>ex.) "NYC"</em>
12
- # +link+:: String
13
- # +privacy+:: String <em>ex.) "everyone"</em>
14
- # +count+:: Integer
15
- # +type+:: String <em>ex.) "normal"</em>
16
- # +created_time+:: Time (UTC)
17
- # +updated_time+:: Time (UTC)
18
- #
19
- # = Connections
20
- #
21
- # +photos+:: Array of FbGraph::Photo
22
- # +comments+:: Array of FbGraph::Comment
23
- # +likes+:: Array of FbGraph::Page
24
- #
25
- # = Examples
26
- #
27
- # == Fetch album info
28
- #
29
- # album = FbGraph::Album.new(ALBUM_ID)
30
- # album.fetch(:access_token => ACCESS_TOKEN)
31
- #
32
- # or
33
- #
34
- # FbGraph::album.fetch(ALBUM_ID, :access_token => ACCESS_TOKEN)
35
- #
36
- # == Fetch connection
37
- #
38
- # photos = album.photos
39
- # likes = album.likes
40
- # comments = album.comments
41
- #
42
- # === Pagination
43
- #
44
- # photos = album.photos
45
- # photos_next = photos.next
46
- # photos_previous = photos.previous
47
- # photos = album.photos(:since => '2010-09-01', :until => '2010-10-01')
48
- # photos = album.photos(:offset => 20, :limit => 20)
49
- #
50
- # == Creat new album
51
- #
52
- # See RDoc for FbGraph::Connections::Albums
53
- #
54
- # == Upload a photo
55
- #
56
- # album.photo!(
57
- # :image => File.new(File.join(File.dirname(__FILE__), 'nov.gif')),
58
- # :name => "name",
59
- # :message => 'message'
60
- # )
61
- #
62
- # == Post a comment
63
- #
64
- # album.comment!(
65
- # :access_token => ACCESS_TOKEN,
66
- # :message => 'Hey, I\'m testing you!'
67
- # )
68
- #
69
- # == Delete a comment
70
- #
71
- # comment = album.comments.last
72
- # comment.destroy
73
- #
74
- # == Like and unlike
75
- #
76
- # album.like!
77
- # album.unlike!
78
- #
79
- # = Notes
80
- #
81
- # == Attribute +from+
82
- #
83
- # Both facebook user and page can have albums, so +from+ can be either FbGraph::User or FbGraph::Page.
84
- # * When you called +ablums+ connection of FbGraph::User, all +from+ should be FbGraph::User.
85
- # * When you called +ablums+ connection of FbGraph::Page, all +from+ should be FbGraph::Page.
86
- # * When you fetched an album by objedt id, +from+ can be either FbGraph::User or FbGraph::Page.
87
- #
88
- # == Cached +comments+
89
- #
90
- # When album object fetched, several comments are included in the response.
91
- # So first time you called +album.comments+, those cached comments will be returned.
92
- # If you put any option parameter like +album.comments(:access_token => ACCESS_TOKEN)+,
93
- # fb_graph ignores those cached comments and fetch comments via Graph API.
94
- #
95
- # <em>If cached "album.comments" are blank, probably the album has no comments yet.</em>
96
2
  class Album < Node
97
3
  include Connections::Photos
98
4
  include Connections::Comments
@@ -26,23 +26,6 @@ module FbGraph
26
26
  @secret = attributes[:secret]
27
27
  end
28
28
 
29
- # == Get OAuth access token
30
- #
31
- # Obtain an OAuth access token associated with your application via the OAuth Client Credentials Flow.
32
- #
33
- # ref) http://developers.facebook.com/docs/api#analytics
34
- #
35
- # app = FbGraph::Application.new(APP_ID)
36
- # app.get_access_token
37
- # # => access token as String
38
- # app.access_token # once get_access_token is called, access token is cached.
39
- # # => access token as String
40
- #
41
- # This method is automatically called when access token needed and application secret has already given.
42
- #
43
- # app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
44
- # app.subscriptions # get_access_token is called automatically
45
- # # => Array of FbGraph::Subscription
46
29
  def get_access_token(secret = nil)
47
30
  self.secret ||= secret
48
31
  auth = Auth.new(self.identifier, self.secret)
data/lib/fb_graph/auth.rb CHANGED
@@ -1,19 +1,4 @@
1
1
  module FbGraph
2
- # = Parse & verify facebook auth cookie
3
- #
4
- # Used with Facebook JavaScript SDK
5
- #
6
- # app = FbGraph::Auth.new(APP_ID, APP_SECRET)
7
- # app.from_cookie(cookie_hash)
8
- # auth.access_token
9
- # # => OAuth2::AccessToken (not String!)
10
- # auth.user # only initialized
11
- # auth.user.fetch # fetch whole profile
12
- #
13
- # This method is called automatically if cookie is given when initializing
14
- #
15
- # auth = FbGraph::Auth.new(APP_ID, APP_SECRET, :cookie => {..})
16
- # auth.access_token # already parsed
17
2
  class Auth
18
3
  class VerificationFailed < Exception; end
19
4
 
@@ -34,13 +34,7 @@ module FbGraph
34
34
  end
35
35
  end
36
36
 
37
- # == Search for recent check-ins for an authorized user and his or her friends:
38
- #
39
- # FbGraph::Checkin.search(:access_token => ACCESS_TOKEN)
40
- # # => Array of FbGraph::Checkin
41
37
  def self.search(options = {})
42
- # NOTE:
43
- # checkin search doesn't support "q=***" parameter
44
38
  super(nil, options)
45
39
  end
46
40
  end
@@ -1,50 +1,5 @@
1
1
  module FbGraph
2
2
  module Connections
3
- # = What's "accounts"?
4
- #
5
- # Pages owned by the current user.
6
- #
7
- # ref) http://developers.facebook.com/docs/api#impersonation
8
- #
9
- # = Authentication
10
- #
11
- # * Access token is required.
12
- # * "manage_pages" permission is optional.
13
- #
14
- # If the "manage_pages" permission has been granted,
15
- # this connection also yields access_tokens that can be used to query the Graph API on behalf of the page.
16
- #
17
- # ref) http://developers.facebook.com/docs/reference/api/user
18
- #
19
- # = Connected with
20
- #
21
- # * FbGraph::User
22
- #
23
- # == Fetch
24
- #
25
- # pages = FbGraph::User.me(ACCESS_TOKEN).accounts
26
- # # => array of FbGraph::Page
27
- # pages.first.access_token
28
- # # => String if "manage_pages" permission has been granted, nil if not.
29
- #
30
- # = Notes
31
- #
32
- # == Access token of the page
33
- #
34
- # Using given access token, you can do those things as the page, not as yourself.
35
- #
36
- # * update the page's wall
37
- # * create new page's album and upload photos into it
38
- # * create and manage an event
39
- # * etc.
40
- #
41
- # See RDoc for FbGraph::Page for more details.
42
- #
43
- # page = FbGraph::User.me(ACCESS_TOKEN).accounts.first
44
- # page.access_token
45
- # # => given because "manage_pages" permission has been granted.
46
- # page.feed!(:message => 'Updating via FbGraph')
47
- # # => update the page's wall, not the user's wall
48
3
  module Accounts
49
4
  def accounts(options = {})
50
5
  accounts = self.connection(:accounts, options)
@@ -1,80 +1,5 @@
1
1
  module FbGraph
2
2
  module Connections
3
- # = Authentication
4
- #
5
- # * Access token is required to fetch/create albums.
6
- # * "publish_stream" permissin is required to create new album.
7
- #
8
- # = Connected with
9
- #
10
- # * FbGraph::Application
11
- # * FbGraph::USer
12
- # * FbGraph::Page
13
- #
14
- # = Example
15
- #
16
- # == Fetch albums
17
- #
18
- # me = FbGraph::User.me(ACCESS_TOKEN)
19
- # me.albums
20
- # # => Array of FbGraph::Album
21
- #
22
- # page = FbGraph::Page.new('fb_graph')
23
- # page.albums
24
- # # => Array of FbGraph::Album
25
- #
26
- # == Create an album
27
- #
28
- # me = FbGraph::User.me(ACCESS_TOKEN)
29
- # album = me.album!(
30
- # :name => 'FbGraph test',
31
- # :message => 'hello world!',
32
- # :description => 'hello world!'
33
- # )
34
- #
35
- # page = FbGraph::Page.new('fb_graph', :access_token => ACCESS_TOKEN)
36
- # album = page.album!(
37
- # :name => 'FbGraph test',
38
- # :message => 'hello world!',
39
- # :description => 'hello world!'
40
- # )
41
- #
42
- # = Notes
43
- #
44
- # == Attributes after created
45
- #
46
- # Only attributes you specified are saved in the created album object.
47
- # If you want to access any other attributes, you need to fetch the album info via Graph API.
48
- #
49
- # me = FbGraph::User.me(ACCESS_TOKEN)
50
- # album = me.album!(
51
- # :name => 'FbGraph test',
52
- # :message => 'hello world!',
53
- # :description => 'hello world!'
54
- # )
55
- # album.name # => 'FbGraoh test'
56
- # album.from # => nil
57
- # album.created_time # => nil
58
- # album.fetch
59
- # album.from # => me
60
- # album.created_time # => Sun Sep 12 01:18:36 +0900 2010
61
- #
62
- # == Bug of Graph API
63
- #
64
- # According facebook's document, the key for +description+ should be +description+ both when fetching and creating,
65
- # but actually you need to use +message+ instead of +description+ only when creating.
66
- # It probably facebook's bug, and it might be fixed suddenly.
67
- # I highly recommend to send same value both as +description+ and +message+ when creating,
68
- # then your code will work without any code change.
69
- #
70
- # ref) http://developers.facebook.com/docs/reference/api/album
71
- #
72
- # me = FbGraph::User.me(ACCESS_TOKEN)
73
- # album = me.album!(
74
- # :name => 'FbGraph test',
75
- # :message => 'hello world!',
76
- # :description => 'hello world!'
77
- # )
78
3
  module Albums
79
4
  def albums(options = {})
80
5
  albums = self.connection(:albums, options)
@@ -1,13 +1,5 @@
1
1
  module FbGraph
2
2
  module Connections
3
- # == Fetch checkins
4
- #
5
- # * To get a user's check-ins, request the "user_checkins".
6
- # * To see the user's friends' check-ins, request the "friends_checkins".
7
- # ref) http://developers.facebook.com/docs/api#places
8
- #
9
- # FbGraph::User.new("matake").checkins(:access_token => ACCESS_TOKEN)
10
- # FbGraph::Page.new("Tokyo").checkins(:access_token => ACCESS_TOKEN)
11
3
  module Checkins
12
4
  def checkins(options = {})
13
5
  checkins = self.connection(:checkins, options)
@@ -1,32 +1,6 @@
1
1
  module FbGraph
2
2
  module Connections
3
3
  module Feed
4
- # == Fetching Wall posts
5
- #
6
- # === User Wall
7
- #
8
- # FbGraph::User.new(username).feed
9
- # # => Array of FbGraph::Post
10
- #
11
- # === Page Wall
12
- #
13
- # FbGraph::Page.new(page_id).feed
14
- # # => Array of FbGraph::Post
15
- #
16
- # === Application Wall
17
- #
18
- # FbGraph::Application.new(page_id).feed
19
- # # => Array of FbGraph::Post
20
- #
21
- # === Event Wall
22
- #
23
- # FbGraph::Event.new(page_id).feed
24
- # # => Array of FbGraph::Post
25
- #
26
- # === Group Wall
27
- #
28
- # FbGraph::Group.new(page_id).feed
29
- # # => Array of FbGraph::Post
30
4
  def feed(options = {})
31
5
  posts = self.connection(:feed, options)
32
6
  posts.map! do |post|
@@ -36,49 +10,6 @@ module FbGraph
36
10
  end
37
11
  end
38
12
 
39
- # == Updating Wall
40
- #
41
- # * See supported arguments here http://developers.facebook.com/docs/reference/api/post
42
- # * You need admin user's access_token to update Page/Application/Event/Group wall as itself
43
- #
44
- # === User Wall
45
- #
46
- # me = FbGraph::User.me(ACCESS_TOKEN)
47
- # me.feed!(
48
- # :message => 'Updating via FbGraph'
49
- # )
50
- #
51
- # === Page Wall
52
- #
53
- # page = FbGraph::Page.new(page_id)
54
- # page.feed!(
55
- # :access_token => ACCESS_TOKEN,
56
- # :message => 'Updating via FbGraph'
57
- # )
58
- #
59
- # === Application Wall
60
- #
61
- # application = FbGraph::Page.new(application_id)
62
- # application.feed!(
63
- # :access_token => ACCESS_TOKEN,
64
- # :message => 'Updating via FbGraph'
65
- # )
66
- #
67
- # === Event Wall
68
- #
69
- # event = FbGraph::Event.new(event_id)
70
- # event.feed!(
71
- # :access_token => ACCESS_TOKEN,
72
- # :message => 'Updating via FbGraph'
73
- # )
74
- #
75
- # === Group Wall
76
- #
77
- # group = FbGraph::Group.new(group_id)
78
- # group.feed!(
79
- # :access_token => ACCESS_TOKEN,
80
- # :message => 'Updating via FbGraph'
81
- # )
82
13
  def feed!(options = {})
83
14
  post = post(options.merge(:connection => :feed))
84
15
  Post.new(post.delete(:id), options.merge(post).merge(
@@ -23,7 +23,7 @@ module FbGraph
23
23
  @classes = []
24
24
  if attributes[:classes]
25
25
  attributes[:classes].each do |klass|
26
- @classes << Page.new(klass.delete(:id), klass)
26
+ @classes << Klass.new(klass.delete(:id), klass)
27
27
  end
28
28
  end
29
29
  @type = attributes[:type]
@@ -0,0 +1,31 @@
1
+ module FbGraph
2
+ class Klass < Page
3
+ attr_accessor :with, :start_date, :end_date
4
+
5
+ def initialize(identifier, attributes = {})
6
+ super
7
+ @with = []
8
+ if attributes[:with]
9
+ attributes[:with].each do |user|
10
+ @with << User.new(user.delete(:id), user)
11
+ end
12
+ end
13
+ if attributes[:start_date]
14
+ year, month = attributes[:start_date].split('-').collect(&:to_i)
15
+ @start_date = if month.blank? || month == 0
16
+ Date.new(year)
17
+ else
18
+ Date.new(year, month)
19
+ end
20
+ end
21
+ if attributes[:end_date]
22
+ year, month = attributes[:end_date].split('-').collect(&:to_i)
23
+ @end_date = if month.blank? || month == 0
24
+ Date.new(year)
25
+ else
26
+ Date.new(year, month)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,108 @@
1
+ module FbGraph
2
+ class Page
3
+ module CategoryAttributes
4
+ @@attributes = {}
5
+ @@attributes[:raw] = [
6
+ :affiliation,
7
+ :artists_we_like,
8
+ :attire,
9
+ :awards,
10
+ :band_interests,
11
+ :band_members,
12
+ :bio,
13
+ :booking_agent,
14
+ :can_post,
15
+ :company_overview,
16
+ :culinary_team,
17
+ :current_location,
18
+ :directed_by,
19
+ :features,
20
+ :general_info,
21
+ :general_manager,
22
+ :genre,
23
+ :influences,
24
+ :is_community_page,
25
+ :link,
26
+ :location,
27
+ :mission,
28
+ :mpg,
29
+ :personal_info,
30
+ :personal_interests,
31
+ :phone,
32
+ :plot_outline,
33
+ :press_contact,
34
+ :price_range,
35
+ :produced_by,
36
+ :products,
37
+ :public_transit,
38
+ :record_label,
39
+ :screenplay_by,
40
+ :starring,
41
+ :studio,
42
+ :website,
43
+ :written_by
44
+ ]
45
+ @@attributes[:symbols] = [
46
+ :parking,
47
+ :payment_options,
48
+ :restaurant_services,
49
+ :restaurant_specialties
50
+ ]
51
+ @@attributes[:date] = [
52
+ :birthday,
53
+ :built,
54
+ :founded,
55
+ :release_date
56
+ ]
57
+ @@attributes[:others] = [
58
+ :checkin_count,
59
+ :hours,
60
+ :location
61
+ ]
62
+ attr_accessor *@@attributes.values.flatten
63
+
64
+ def self.included(klass)
65
+ klass.alias_method_chain :initialize, :category_specific_attributes
66
+ end
67
+
68
+ def initialize_with_category_specific_attributes(identifier, attributes = {})
69
+ initialize_without_category_specific_attributes identifier, attributes
70
+ @@attributes[:raw].each do |key|
71
+ self.send :"#{key}=", attributes[key]
72
+ end
73
+ @@attributes[:symbols].each do |key|
74
+ self.send :"#{key}=", []
75
+ if attributes[key]
76
+ self.send :"#{key}=", attributes[key].keys.collect(&:to_sym)
77
+ end
78
+ end
79
+ @@attributes[:date].each do |key|
80
+ if attributes[key]
81
+ value = Date.parse(attributes[key]) rescue attributes[key]
82
+ self.send :"#{key}=", value
83
+ end
84
+ end
85
+ @checkin_count = attributes[:checkins]
86
+ @hours = {}
87
+ if attributes[:hours]
88
+ utc_beginning_of_day = Time.now.utc.beginning_of_day
89
+ attributes[:hours].each do |key, value|
90
+ date, index, mode = key.split('_')
91
+ index = index.to_i - 1
92
+ date, mode = date.to_sym, mode.to_sym
93
+ time = value.since(utc_beginning_of_day)
94
+ time = Time.utc(1970, 1, 1, time.hour, time.min)
95
+ @hours[date] ||= []
96
+ @hours[date][index] ||= {}
97
+ @hours[date][index][mode] = time
98
+ end
99
+ end
100
+ if attributes[:location]
101
+ @location = Venue.new(attributes[:location])
102
+ end
103
+ end
104
+ end
105
+
106
+ include CategoryAttributes
107
+ end
108
+ end
data/lib/fb_graph/page.rb CHANGED
@@ -16,45 +16,16 @@ module FbGraph
16
16
  include Connections::Videos
17
17
  extend Searchable
18
18
 
19
- attr_accessor :name, :username, :link, :category, :founded, :can_post, :is_community_page, :company_overview, :general_info, :mission, :products, :public_transit, :release_date, :location, :website, :websites, :like_count, :checkin_count, :with, :created_time
19
+ attr_accessor :name, :username, :category, :like_count
20
20
 
21
21
  def initialize(identifier, attributes = {})
22
22
  super
23
- @name = attributes[:name]
24
- @username = attributes[:username]
25
- @link = attributes[:link]
26
- @category = attributes[:category]
27
- if (founded = attributes[:founded])
28
- @founded = Date.parse(founded) rescue Date.new(founded.to_i)
29
- end
30
- @can_post = attributes[:can_post]
31
- @is_community_page = attributes[:is_community_page]
32
- @company_overview = attributes[:company_overview]
33
- @general_info = attributes[:general_info]
34
- @mission = attributes[:mission]
35
- @products = attributes[:products]
36
- @public_transit = attributes[:public_transit]
37
- if (release_date = attributes[:release_date])
38
- @release_date = Date.parse(release_date) rescue release_date
39
- end
40
- if (location = attributes[:location])
41
- @location = Venue.new(location)
42
- end
43
- @website = attributes[:website]
44
- @websites = attributes[:website].to_s.split
45
- @like_count = attributes[:likes]
46
- @checkin_count = attributes[:checkins]
47
- @with = []
48
- if attributes[:with]
49
- attributes[:with].each do |user|
50
- @with << User.new(user.delete(:id), user)
51
- end
52
- end
53
- if attributes[:created_time]
54
- @created_time = Time.parse(attributes[:created_time]).utc
23
+ [:name, :username, :category].each do |key|
24
+ self.send :"#{key}=", attributes[key]
55
25
  end
26
+ @like_count = attributes[:likes] || attributes[:fan_count]
56
27
  end
57
28
  end
58
29
  end
59
30
 
60
- require 'fb_graph/page/categories'
31
+ require 'fb_graph/page/category_attributes'
@@ -1,25 +1,4 @@
1
1
  module FbGraph
2
- class Project < Page
3
- attr_accessor :start_date, :end_date
4
-
5
- def initialize(identifier, attributes = {})
6
- super
7
- if attributes[:start_date]
8
- year, month = attributes[:start_date].split('-').collect(&:to_i)
9
- @start_date = if month.blank? || month == 0
10
- Date.new(year)
11
- else
12
- Date.new(year, month)
13
- end
14
- end
15
- if attributes[:end_date]
16
- year, month = attributes[:end_date].split('-').collect(&:to_i)
17
- @end_date = if month.blank? || month == 0
18
- Date.new(year)
19
- else
20
- Date.new(year, month)
21
- end
22
- end
23
- end
2
+ class Project < Klass
24
3
  end
25
4
  end