quickbase_record 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODYyYTFkNjQ2ZWJlY2MyYmM4ZTIzMjMxZGIwZGQ0NmIxYmM2ZTk3OA==
4
+ ZWUzNzIwNjc3YjY3NjllMjcyODVmZWIyYzFjNWNjY2MxZjc2Zjg4NA==
5
5
  data.tar.gz: !binary |-
6
- ODM0YjlmNmM0ZWY2ODZlODhkZGYwNjRjYjAyZDlkOWNkZDZmYjU5Yw==
6
+ OTQ4MmNiNzE3M2JlNzRhYTFmN2Q0MmU3YmJhODE4YjBjNzFmYTg3Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWM1MTQ2OGQ0ZjIyMDFjM2U1MjhjNmEzZDBhZWZmZWM1M2VjMGQyMjgxZDFl
10
- ZjI1M2FjNjZjODFmNDU3Yjg1ZTNkN2Y1ZWM5Yzc2ODlhOWQ0NjQ2ZTYyNGUw
11
- OTRhYTA0ZTY1MjVhMTIxYWQ1MTQxMzUyMWNiMjUyMWYzYjdjN2E=
9
+ NDdiYmEwMjZmYWFmOWQzNTNjYWY2ZjU2ZDQyYWNhMTM3N2JmMTQwYjQwYWQ3
10
+ M2I4NTNiYjhjYjE5NjM2M2NjN2FkY2U2NjUyNzk5ZmQ1ZjY5NDQyYWEyN2Nk
11
+ ODJhYmUyZWJkYzhkN2U2MGE3OWU1MzUzYTdjZDYyZWZhODlkYjQ=
12
12
  data.tar.gz: !binary |-
13
- ZDBkNjQzZmM0ZWViZTUwNjY0MWIzMDQ3MDgzOWFlYzViMDM2ZWU3NTgwZTI2
14
- OWNmNDcxYmZmNmI3YmU3MTE3ODZmNDI2OTM4NDk1MTU3MDZkYWQ4ODMxNTk2
15
- NTY0Y2JhMWFkN2U2NDAwODg2ZjdmYzFiNTNiNzU0NTFjMTUxMzQ=
13
+ Mzk2MDkzNWJjZmUxOGJiNDNlYWEwZTczYWQ3MmQwMjNiNDk1YzdjODBlNmJh
14
+ NmEyMTY0MzU0ZDUwMDQ4NjIxNzRjMDIwZjJhYzhiZjYxYWI2N2E1ODA5ZWMz
15
+ OWUwMjIwOWFiNmM0Nzg0MzgwZTU3OTg2MzM1OGFmZDgwNTQwZDg=
data/README.md CHANGED
@@ -30,6 +30,7 @@ QuickbaseRecord is built on top of the [Advantage Quickbase](https://github.com/
30
30
  config.realm = "your_apps_realm_name"
31
31
  config.username = "valid_username" (or something like ENV["QB_USERNAME"])
32
32
  config.password = "valid_password" (or something like ENV["QB_PASSWORD"])
33
+ config.token = "your_app_token_if_applicable"
33
34
  end
34
35
  ```
35
36
 
@@ -37,9 +38,9 @@ QuickbaseRecord is built on top of the [Advantage Quickbase](https://github.com/
37
38
  Simply `include QuickbaseRecord::Model` in your class and use the `.define_fields` method to supply the table's DBID and a mapping of desired field names => QuickBase FIDs
38
39
 
39
40
  ```
40
- # app/models/posts.rb
41
+ # app/models/post.rb
41
42
 
42
- class Posts
43
+ class Post
43
44
  include QuickbaseRecord::Model
44
45
 
45
46
  define_fields ({
@@ -58,7 +59,7 @@ Simply `include QuickbaseRecord::Model` in your class and use the `.define_field
58
59
  Classes that include QuickbaseRecord::Model and define their fields will have a handful of class and instance methods for interacting with your QuickBase application similar to ActiveRecord. The goal is to be able to use QuickBase as a database and treat your models the same way you would with a traditional database.
59
60
 
60
61
  ```
61
- @post = Posts.find(1) => <Post: @id=1, @content="Amazing post content", @author: 'Cullen Jett'>
62
+ @post = Post.find(1) => <Post: @id=1, @content="Amazing post content", @author: 'Cullen Jett'>
62
63
 
63
64
  --
64
65
 
@@ -88,38 +89,38 @@ Database callbacks (i.e. `before_save :create_token!`) are not fully functional
88
89
  - Intantiate *and* save a new object with the given attributes
89
90
  - Assigns the returned object it's new ID
90
91
  ```
91
- Posts.create(content: 'Amazing post content', author: 'Cullen Jett')
92
+ Post.create(content: 'Amazing post content', author: 'Cullen Jett')
92
93
  ```
93
94
 
94
95
  * **.find(id)**
95
96
  - Query for a specific QuickBase record by it's ID
96
97
  - Returns a single object
97
98
  ```
98
- Posts.find(params[:id])
99
+ Post.find(params[:id])
99
100
  ```
100
101
 
101
102
  * **.where(attributes_hash)**
102
103
  - Query QuickBase by any field name defined in your class' field mapping
103
104
  - Returns an array of objects
104
105
  ```
105
- Posts.where(author: 'Cullen Jett').first
106
+ Post.where(author: 'Cullen Jett').first
106
107
  ```
107
108
 
108
109
  - Multiple field_name/value pairs are joined with 'AND'
109
110
  ```
110
- Posts.where(id: 1, author: 'Cullen Jett')
111
+ Post.where(id: 1, author: 'Cullen Jett')
111
112
  # {'3'.EX.'1'}AND{'8'.EX.'Cullen Jett'}
112
113
  ```
113
114
 
114
115
  - Values in an array are joined with 'OR'
115
116
  ```
116
- Posts.where(author: ['Cullen Jett', 'Socrates')
117
+ Post.where(author: ['Cullen Jett', 'Socrates')
117
118
  # {'8'.EX.'Socrates'}OR{'8'.EX.'Socrates'}
118
119
  ```
119
120
 
120
121
  - To use a comparitor other than 'EX' pass the value as another hash with the key as the comparitor
121
122
  ```
122
- Posts.where(author: {XEX: 'Cullen Jett'})
123
+ Post.where(author: {XEX: 'Cullen Jett'})
123
124
  # {'8'.XEX.'Cullen Jett'}
124
125
  ```
125
126
 
@@ -128,15 +129,15 @@ Database callbacks (i.e. `before_save :create_token!`) are not fully functional
128
129
  - Returns an array of objects
129
130
  - Works with field names or FIDs
130
131
  ```
131
- Posts.query("{'3'.EX.'1'}")
132
- Posts.query("{author.XEX.'Cullen Jett'}")
132
+ Post.query("{'3'.EX.'1'}")
133
+ Post.query("{author.XEX.'Cullen Jett'}")
133
134
  ```
134
135
 
135
136
  * **.qid(id)**
136
137
  - Accepts a QID (QuickBase report ID)
137
138
  - Returns an array of objects
138
139
  ```
139
- Posts.qid(1)
140
+ Post.qid(1)
140
141
  ```
141
142
 
142
143
  * **#save**
@@ -144,7 +145,7 @@ Database callbacks (i.e. `before_save :create_token!`) are not fully functional
144
145
  - Returns the object (if #save created a record in QuickBase the the returned object will now have an ID)
145
146
  - Uses API_ImportFromCSV under the hood.
146
147
  ```
147
- @post = Posts.new(content: 'Amazing post content', author: 'Cullen Jett')
148
+ @post = Post.new(content: 'Amazing post content', author: 'Cullen Jett')
148
149
  @post.save # => <Post: @id: 1, @content: 'Amazing post content', @author: 'Cullen Jett'
149
150
 
150
151
  @post.author = 'Socrates'
@@ -160,10 +161,10 @@ Database callbacks (i.e. `before_save :create_token!`) are not fully functional
160
161
  ```
161
162
 
162
163
  * **#update_attributes(attributes_hash)**
163
- - Updates *and* saves the object with the new attributes
164
+ - ** IMPORTANT: Updates *and* saves the object with the new attributes**
164
165
  - Returns the object
165
166
  ```
166
- @post = Posts.where(author: 'Cullen Jett').first
167
+ @post = Post.where(author: 'Cullen Jett').first
167
168
  @post.update_attributes(author: 'Socrates', content: 'Something enlightening...') # => <Post: @id: 1, @author: 'Socrates', @content: 'Something enlightening...'
168
169
  ```
169
170
 
@@ -172,7 +173,7 @@ Database callbacks (i.e. `before_save :create_token!`) are not fully functional
172
173
  - Useful for assigning multiple attributes at once, otherwise you could use the field name's attr_accessor to change a single attribute.
173
174
  - Returns the object
174
175
  ```
175
- @post = Posts.where(author: 'Cullen Jett').first
176
+ @post = Post.where(author: 'Cullen Jett').first
176
177
  @post.assign_attributes(author: 'Socrates', content: 'Something enlightening...')
177
178
  @post.save
178
179
  ```
@@ -20,7 +20,7 @@ module QuickbaseRecord
20
20
  query_options = { query: build_query(id: id), clist: clist }
21
21
  query_response = qb_client.do_query(dbid, query_options).first
22
22
 
23
- return false if query_response.nil?
23
+ return nil if query_response.nil?
24
24
 
25
25
  converted_response = convert_quickbase_response(query_response)
26
26
  new(converted_response)
@@ -30,7 +30,7 @@ module QuickbaseRecord
30
30
  query_options = { query: build_query(query_hash), clist: clist }
31
31
  query_response = qb_client.do_query(dbid, query_options)
32
32
 
33
- return false if query_response.first.nil?
33
+ return [] if query_response.first.nil?
34
34
 
35
35
  build_array_of_new_objects(query_response)
36
36
  end
@@ -46,6 +46,8 @@ module QuickbaseRecord
46
46
  query_options = { qid: id, clist: clist }
47
47
  query_response = qb_client.do_query(dbid, query_options)
48
48
 
49
+ return [] if query_response.first.nil?
50
+
49
51
  build_array_of_new_objects(query_response)
50
52
  end
51
53
 
@@ -1,3 +1,3 @@
1
1
  module QuickbaseRecord
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
Binary file
data/spec/queries_spec.rb CHANGED
@@ -12,9 +12,9 @@ RSpec.describe QuickbaseRecord::Queries do
12
12
  expect(teacher).to be_a TeacherFake
13
13
  end
14
14
 
15
- it "returns false if no QuickBase records are found" do
15
+ it "returns nil if no QuickBase records are found" do
16
16
  teacher = TeacherFake.find(999999)
17
- expect(teacher).to be false
17
+ expect(teacher).to eq(nil)
18
18
  end
19
19
  end
20
20
 
@@ -39,9 +39,9 @@ RSpec.describe QuickbaseRecord::Queries do
39
39
  expect(teachers.first.id).to eq('1')
40
40
  end
41
41
 
42
- it "returns false if no QuickBase records are found" do
42
+ it "returns an empty array if no QuickBase records are found" do
43
43
  teachers = TeacherFake.where(name: 'Not a real TeacherFake name...')
44
- expect(teachers).to be false
44
+ expect(teachers).to eq([])
45
45
  end
46
46
  end
47
47
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickbase_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cullen Jett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-12 00:00:00.000000000 Z
11
+ date: 2015-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,7 +129,7 @@ files:
129
129
  - lib/quickbase_record/model.rb
130
130
  - lib/quickbase_record/queries.rb
131
131
  - lib/quickbase_record/version.rb
132
- - quickbase_record-0.0.2.gem
132
+ - quickbase_record-0.1.0.gem
133
133
  - quickbase_record.gemspec
134
134
  - spec/fakes/student_fake.rb
135
135
  - spec/fakes/teacher_fake.rb
Binary file