parsecom 0.0.1 → 0.0.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/README.md CHANGED
@@ -67,7 +67,7 @@ game_score.obj_id # => 'Ed1nuqPvcm'
67
67
  ### Retrieving Objects
68
68
 
69
69
  There are two ways to retrieve objects. One is using Query objects directly and
70
- another is using Parse::Object as a facade of query objects.
70
+ another is using Parse::Object as a facade of a query object.
71
71
 
72
72
  ```ruby
73
73
  # useing Query object directly
@@ -81,7 +81,7 @@ results = GameScore.find :where => {:objectId => 'Ed1nuqPvcm'}
81
81
  result = GameScore.find 'Ed1nuqPvcm'
82
82
  ```
83
83
 
84
- More complex search
84
+ More complex query
85
85
 
86
86
  ```ruby
87
87
  # useing Query object directly
data/lib/parse/client.rb CHANGED
@@ -47,6 +47,10 @@ ex. Parse.credentials application_id: APPLICATION_ID, api_key: API_KEY
47
47
  URI.encode password}", nil, &block
48
48
  end
49
49
 
50
+ def log_out
51
+ @session_token = nil
52
+ end
53
+
50
54
  def find parse_class, object_id_or_conditions, opts={}
51
55
  if object_id_or_conditions.is_a? String
52
56
  find_by_id parse_class, object_id_or_conditions, opts
data/lib/parse/object.rb CHANGED
@@ -1,16 +1,25 @@
1
1
  # coding:utf-8
2
2
  module Parse
3
+ RESERVED_PARSE_CLASS = {
4
+ '_User' => 'Parse::User'
5
+ }
6
+
3
7
  class Object
8
+
4
9
  class << self
5
10
  attr_accessor :parse_class_name, :parse_client, :auto_camel_case
6
11
 
7
12
  def create parse_class_name, mod=::Object
8
13
  raise 'already defined' if mod.const_defined? parse_class_name
9
14
 
10
- klass = Class.new(Parse::Object)
11
- klass.parse_class_name = parse_class_name.to_sym
12
- klass.auto_camel_case = true
13
- mod.const_set parse_class_name, klass
15
+ if RESERVED_PARSE_CLASS.has_key? parse_class_name.to_s
16
+ eval RESERVED_PARSE_CLASS[parse_class_name.to_s]
17
+ else
18
+ klass = Class.new(Parse::Object)
19
+ klass.parse_class_name = parse_class_name.to_sym
20
+ klass.auto_camel_case = true
21
+ mod.const_set parse_class_name, klass
22
+ end
14
23
  end
15
24
 
16
25
  def parse_class_name
@@ -169,8 +178,12 @@ module Parse
169
178
  # subclass of ParseObject for the given parse_class_name
170
179
  #
171
180
  def self.Object parse_class_name, mod=::Object
172
- Parse::Object.create parse_class_name, mod \
173
- unless mod.const_defined? parse_class_name
174
- mod.const_get parse_class_name
181
+ if RESERVED_PARSE_CLASS.has_key? parse_class_name.to_s
182
+ eval RESERVED_PARSE_CLASS[parse_class_name.to_s]
183
+ else
184
+ Parse::Object.create parse_class_name, mod \
185
+ unless mod.const_defined? parse_class_name
186
+ mod.const_get parse_class_name
187
+ end
175
188
  end
176
189
  end
data/lib/parse/user.rb CHANGED
@@ -3,6 +3,10 @@ module Parse
3
3
  class User < Object
4
4
 
5
5
  class << self
6
+ def parse_class_name
7
+ '_User'
8
+ end
9
+
6
10
  def sign_up username, password, hash={}
7
11
  self.new(username, password, hash).sign_up
8
12
  end
@@ -12,10 +16,14 @@ module Parse
12
16
  end
13
17
  end
14
18
 
15
- def initialize username, password, hash={}
16
- super hash
17
- @username = username
18
- @password = password
19
+ def initialize username=nil, password=nil, hash={}
20
+ if username.is_a? Hash
21
+ super username
22
+ else
23
+ super hash
24
+ @username = username
25
+ @password = password
26
+ end
19
27
  end
20
28
 
21
29
  def sign_up
@@ -42,6 +50,8 @@ module Parse
42
50
  end
43
51
 
44
52
  def log_out
53
+ parse_client.log_out
54
+ self
45
55
  end
46
56
  end
47
57
  end
data/lib/parse/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Parse
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -46,7 +46,7 @@ describe Parse::Object, 'when it creates a new parse object' do
46
46
  :order => 'createdAt', :keys => 'columnB', :limit => 3
47
47
  class_as.size.should == 3
48
48
 
49
- class_a = ClassA.find :where => {'objectId' => 'avp6UKaG1k'},
49
+ class_a = ClassA.find :where => {'objectId' => 'UUqhbnuTYx'},
50
50
  :order => 'createdAt', :keys => 'columnB', :limit => 3
51
51
  class_a.size.should == 1
52
52
  end
@@ -21,3 +21,12 @@ describe Parse::User, 'when it logs out' do
21
21
  it 'should get the session token' do
22
22
  end
23
23
  end
24
+
25
+ describe Parse::User, 'when it is included in other query' do
26
+ it 'should return a valid User object' do
27
+ class_a = ClassA.find 'UUqhbnuTYx', :include => 'user'
28
+ user = class_a.user
29
+ user.should be_an_instance_of Parse::User
30
+ user.obj_id.should == '5VuUwoEe0j'
31
+ end
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsecom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-01 00:00:00.000000000 Z
12
+ date: 2013-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec