Project

dm-parse

0.0
No commit activity in last 3 years
No release in over 3 years
An extension to make DataMapper working on Parse.com
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.0.0
>= 1.1
>= 1.8.3
>= 0.9
>= 3.12
>= 2.10.0
>= 0.6
>= 0.7

Runtime

 Project Readme

dm-parse

A DataMapper extension for Parse, include an adapter and some types for Parse.

Installation

Include in your Gemfile:

gem "dm-parse"

Or just gem install:

gem install dm-parse

Usage

To setup the adapter:

DataMapper.setup(:default, adapter: :parse, app_id: "your-id", api_key: "your-rest-api-key")

To setup with Master Key:

DataMapper.setup(:default, adapter: :parse, app_id: "your-id", api_key: "your-master-key", master: true)

To define model for parse, use is :parse:

class Article
  include DataMapper::Resource

  is :parse # it defines id, created_at and updated_at for you

  property :title,      String
  property :body,       Text
  property :rank,       Integer
  property :closed_at,  ParseDate # Date type for Parse

  has n, :comments
end

class Comment
  include DataMapper::Resource

  is :parse

  property :body,       Text

  belongs_to :article
end

To define a user model, use is :parse_user:

class User
  include DataMapper::Resource

  # more than :parse, it also defines username, password and email.
  # it also sets the default storage_names to "_User"
  is :parse_user
  storage_names[:master] = "_User"
end

By this, you can use User.authenticate(username, password) to sign in, and use User.request_password_reset(email) to reset password.

Special properties for Parse

  • ParseKey: the property for objectId, is :parse will define it for you.
  • ParsePointer: the pointer, you just need to give it objectId value.
  • ParseDate: the date, use it like you use DateTime.
  • ParseFile: the file, give it an IO object from web form, it will be uploaded, and it will be loaded as a URI object.

Limits

  • Does not support many-to-many relationships.

Contributing to dm-parse

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2012 Zhi-Qiang Lei. See LICENSE.txt for further details.