ipp_quickbase_devkit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. data/LICENSE +87 -0
  2. data/README.rdoc +112 -0
  3. data/doc/QuickBaseClient.rb.htm +1896 -0
  4. data/doc/ReleaseNotes.txt +43 -0
  5. data/doc/qbc.makeCSVFile.qbc +4 -0
  6. data/doc/qbc.makeCSVFile.rb +4 -0
  7. data/doc/quickbase_adapter.rb.htm +399 -0
  8. data/examples/cookbookfiles/QuickBaseAPICookbook.html +2590 -0
  9. data/examples/cookbookfiles/addChangeRemoveUserRole.rb +21 -0
  10. data/examples/cookbookfiles/addOrEditRecord.rb +10 -0
  11. data/examples/cookbookfiles/application_object.rb +55 -0
  12. data/examples/cookbookfiles/applyRubyFormulas.rb +10 -0
  13. data/examples/cookbookfiles/average.rb +27 -0
  14. data/examples/cookbookfiles/backupApplication.rb +8 -0
  15. data/examples/cookbookfiles/cacheSchemas.rb +53 -0
  16. data/examples/cookbookfiles/calculateRunningTotals.rb +11 -0
  17. data/examples/cookbookfiles/copyrecords.rb +73 -0
  18. data/examples/cookbookfiles/count.rb +26 -0
  19. data/examples/cookbookfiles/createRecordNavigatorHTML.rb +42 -0
  20. data/examples/cookbookfiles/createReportDashboard.rb +35 -0
  21. data/examples/cookbookfiles/createTable.rb +12 -0
  22. data/examples/cookbookfiles/deviation.rb +25 -0
  23. data/examples/cookbookfiles/downloadCookbook.rb +97 -0
  24. data/examples/cookbookfiles/downloadFile.rb +10 -0
  25. data/examples/cookbookfiles/downloadFilesToFolder.rb +81 -0
  26. data/examples/cookbookfiles/downloadToTextFile.rb +64 -0
  27. data/examples/cookbookfiles/dumpSchema.rb +11 -0
  28. data/examples/cookbookfiles/duplicateRecord.rb +8 -0
  29. data/examples/cookbookfiles/dynamicMethods.rb +33 -0
  30. data/examples/cookbookfiles/editRecords.rb +15 -0
  31. data/examples/cookbookfiles/findJohnsLast10Records.rb +17 -0
  32. data/examples/cookbookfiles/findRubyRecords.rb +17 -0
  33. data/examples/cookbookfiles/formatCurrency.rb +24 -0
  34. data/examples/cookbookfiles/formatDate.rb +10 -0
  35. data/examples/cookbookfiles/formatDuration.rb +27 -0
  36. data/examples/cookbookfiles/formatPercent.rb +24 -0
  37. data/examples/cookbookfiles/getAllValuesForFields.rb +18 -0
  38. data/examples/cookbookfiles/getAppDTMInfo.rb +29 -0
  39. data/examples/cookbookfiles/getApplicationVariable.rb +5 -0
  40. data/examples/cookbookfiles/getChildTableDBID.rb +11 -0
  41. data/examples/cookbookfiles/getColumnListForReport.rb +6 -0
  42. data/examples/cookbookfiles/getFieldChoices.rb +13 -0
  43. data/examples/cookbookfiles/getFieldIDs.rb +6 -0
  44. data/examples/cookbookfiles/getFieldNames.rb +6 -0
  45. data/examples/cookbookfiles/getLastModTime.rb +8 -0
  46. data/examples/cookbookfiles/getLastRecModTime.rb +8 -0
  47. data/examples/cookbookfiles/getNumRecords.rb +8 -0
  48. data/examples/cookbookfiles/getNumTables.rb +4 -0
  49. data/examples/cookbookfiles/getRecord.rb +5 -0
  50. data/examples/cookbookfiles/getRecordDisplayURL.rb +13 -0
  51. data/examples/cookbookfiles/getRecordsAddedToday.rb +20 -0
  52. data/examples/cookbookfiles/getRecordsAsJSON.rb +6 -0
  53. data/examples/cookbookfiles/getReportNames.rb +25 -0
  54. data/examples/cookbookfiles/getRoleInfo.rb +48 -0
  55. data/examples/cookbookfiles/getServerStatus.rb +11 -0
  56. data/examples/cookbookfiles/getSortListForReport.rb +6 -0
  57. data/examples/cookbookfiles/getTableIDs.rb +6 -0
  58. data/examples/cookbookfiles/getTableName.rb +8 -0
  59. data/examples/cookbookfiles/getTableNames.rb +25 -0
  60. data/examples/cookbookfiles/getTimeCreated.rb +8 -0
  61. data/examples/cookbookfiles/getTimeInMilliseconds.rb +5 -0
  62. data/examples/cookbookfiles/getUserInfo.rb +26 -0
  63. data/examples/cookbookfiles/getUserRole.rb +15 -0
  64. data/examples/cookbookfiles/intranet.rb +101 -0
  65. data/examples/cookbookfiles/isAverageField.rb +17 -0
  66. data/examples/cookbookfiles/isDbidString.rb +8 -0
  67. data/examples/cookbookfiles/isTotalField.rb +16 -0
  68. data/examples/cookbookfiles/iterateDBPages.rb +8 -0
  69. data/examples/cookbookfiles/iterateFilteredRecords.rb +12 -0
  70. data/examples/cookbookfiles/iterateJoinRecords.rb +68 -0
  71. data/examples/cookbookfiles/iterateRecordInfos.rb +8 -0
  72. data/examples/cookbookfiles/iterateRecords.rb +23 -0
  73. data/examples/cookbookfiles/iterateSummaryRecords.rb +13 -0
  74. data/examples/cookbookfiles/iterateUnionRecords.rb +38 -0
  75. data/examples/cookbookfiles/listAccessibleApplications.rb +6 -0
  76. data/examples/cookbookfiles/logRequestAndResponseXML.rb +8 -0
  77. data/examples/cookbookfiles/lookupFieldPropertyByName.rb +62 -0
  78. data/examples/cookbookfiles/lookupFieldTypeByName.rb +10 -0
  79. data/examples/cookbookfiles/makeCSVFile.rb +4 -0
  80. data/examples/cookbookfiles/makeSlideShow.rb +42 -0
  81. data/examples/cookbookfiles/makerecs.rb +64 -0
  82. data/examples/cookbookfiles/max.rb +26 -0
  83. data/examples/cookbookfiles/min.rb +26 -0
  84. data/examples/cookbookfiles/percent.rb +29 -0
  85. data/examples/cookbookfiles/printChildElements.rb +54 -0
  86. data/examples/cookbookfiles/printNewRecords.rb +12 -0
  87. data/examples/cookbookfiles/processRESTRequest.rb +21 -0
  88. data/examples/cookbookfiles/provisionAndInviteNewUser.rb +13 -0
  89. data/examples/cookbookfiles/purgeRecords.rb +15 -0
  90. data/examples/cookbookfiles/quickbase_adapter.rb.htm +397 -0
  91. data/examples/cookbookfiles/quickbase_record_finder.zip +0 -0
  92. data/examples/cookbookfiles/recordAndFieldIterator.rb +24 -0
  93. data/examples/cookbookfiles/runImport.rb +9 -0
  94. data/examples/cookbookfiles/runQuickBaseTwitterConnector.rb +41 -0
  95. data/examples/cookbookfiles/sendToQuickBase.rb +33 -0
  96. data/examples/cookbookfiles/setDBvar.rb +6 -0
  97. data/examples/cookbookfiles/showRequestAndResponseXML.rb +8 -0
  98. data/examples/cookbookfiles/sqlQuery.rb +11 -0
  99. data/examples/cookbookfiles/stopOnError.rb +10 -0
  100. data/examples/cookbookfiles/sum.rb +26 -0
  101. data/examples/cookbookfiles/twitterFromQuickBase.rb +42 -0
  102. data/examples/cookbookfiles/twitterWithQuickBase.rb +36 -0
  103. data/examples/cookbookfiles/uploadCSVData.rb +20 -0
  104. data/examples/cookbookfiles/uploadExcelData.rb +22 -0
  105. data/examples/cookbookfiles/uploadFileEveryHour.rb +18 -0
  106. data/examples/cookbookfiles/uploadFileIntoNewRecord.rb +8 -0
  107. data/examples/cookbookfiles/uploadFilesFromFolder.exe +0 -0
  108. data/examples/cookbookfiles/uploadFilesFromFolder.rb +69 -0
  109. data/examples/cookbookfiles/useCompanyURL.rb +12 -0
  110. data/examples/cookbookfiles/userRoles.rb +49 -0
  111. data/examples/cookbookfiles/watchCommunityForum.rb +5 -0
  112. data/examples/cookbookfiles/wikifyTable.rb +29 -0
  113. data/examples/cookbookfiles/xmlShortcuts.rb +33 -0
  114. data/examples/pmp/app/controllers/application.rb +7 -0
  115. data/examples/pmp/app/controllers/contacts_controller.rb +8 -0
  116. data/examples/pmp/app/controllers/document_library_controller.rb +2 -0
  117. data/examples/pmp/app/controllers/issues_controller.rb +5 -0
  118. data/examples/pmp/app/controllers/projects_controller.rb +22 -0
  119. data/examples/pmp/app/controllers/resources_controller.rb +2 -0
  120. data/examples/pmp/app/controllers/tasks_controller.rb +13 -0
  121. data/examples/pmp/app/controllers/time_cards_controller.rb +5 -0
  122. data/examples/pmp/app/helpers/application_helper.rb +3 -0
  123. data/examples/pmp/app/helpers/contacts_helper.rb +2 -0
  124. data/examples/pmp/app/helpers/document_library_helper.rb +2 -0
  125. data/examples/pmp/app/helpers/issues_helper.rb +2 -0
  126. data/examples/pmp/app/helpers/projects_helper.rb +2 -0
  127. data/examples/pmp/app/helpers/resources_helper.rb +2 -0
  128. data/examples/pmp/app/helpers/tasks_helper.rb +2 -0
  129. data/examples/pmp/app/helpers/time_cards_helper.rb +2 -0
  130. data/examples/pmp/app/models/contacts.rb +26 -0
  131. data/examples/pmp/app/models/document_library.rb +2 -0
  132. data/examples/pmp/app/models/issues.rb +6 -0
  133. data/examples/pmp/app/models/projects.rb +26 -0
  134. data/examples/pmp/app/models/resources.rb +2 -0
  135. data/examples/pmp/app/models/tasks.rb +12 -0
  136. data/examples/pmp/app/models/time_cards.rb +7 -0
  137. data/examples/pmp/app/schemas/contacts.xml +1 -0
  138. data/examples/pmp/app/schemas/document_library.xml +1 -0
  139. data/examples/pmp/app/schemas/issues.xml +1 -0
  140. data/examples/pmp/app/schemas/pmp.xml +1 -0
  141. data/examples/pmp/app/schemas/projects.xml +1 -0
  142. data/examples/pmp/app/schemas/readme.txt +8 -0
  143. data/examples/pmp/app/schemas/resources.xml +1 -0
  144. data/examples/pmp/app/schemas/tasks.xml +1 -0
  145. data/examples/pmp/app/schemas/time_cards.xml +1 -0
  146. data/examples/pmp/app/views/contacts/companies.rhtml +31 -0
  147. data/examples/pmp/app/views/contacts/project_contacts.rhtml +31 -0
  148. data/examples/pmp/app/views/issues/filter_issues.rhtml +26 -0
  149. data/examples/pmp/app/views/layouts/application.rhtml +56 -0
  150. data/examples/pmp/app/views/projects/all_projects.rhtml +33 -0
  151. data/examples/pmp/app/views/projects/home.rhtml +11 -0
  152. data/examples/pmp/app/views/projects/my_open_projects.rhtml +27 -0
  153. data/examples/pmp/app/views/projects/open_projects.rhtml +44 -0
  154. data/examples/pmp/app/views/projects/project_sorted_by_company.rhtml +40 -0
  155. data/examples/pmp/app/views/projects/projects_sorted_by_priority.rhtml +30 -0
  156. data/examples/pmp/app/views/projects/updated_projects.rhtml +0 -0
  157. data/examples/pmp/app/views/tasks/all_tasks.rhtml +27 -0
  158. data/examples/pmp/app/views/tasks/search.rhtml +23 -0
  159. data/examples/pmp/app/views/tasks/search2.rhtml +23 -0
  160. data/examples/pmp/app/views/tasks/search3.rhtml +23 -0
  161. data/examples/pmp/app/views/time_cards/summary.rhtml +38 -0
  162. data/examples/pmp/config/boot.rb +45 -0
  163. data/examples/pmp/config/database.yml +30 -0
  164. data/examples/pmp/config/environment.rb +60 -0
  165. data/examples/pmp/config/environments/development.rb +21 -0
  166. data/examples/pmp/config/environments/production.rb +18 -0
  167. data/examples/pmp/config/environments/test.rb +19 -0
  168. data/examples/pmp/config/routes.rb +23 -0
  169. data/examples/pmp/db/migrate/001_create_projects.rb +10 -0
  170. data/examples/pmp/db/migrate/002_create_tasks.rb +10 -0
  171. data/examples/pmp/db/migrate/003_create_issues.rb +10 -0
  172. data/examples/pmp/db/migrate/004_create_document_libraries.rb +10 -0
  173. data/examples/pmp/db/migrate/005_create_resources.rb +10 -0
  174. data/examples/pmp/db/migrate/006_create_time_cards.rb +10 -0
  175. data/examples/pmp/db/migrate/007_create_contacts.rb +10 -0
  176. data/examples/pmp/public/404.html +30 -0
  177. data/examples/pmp/public/500.html +30 -0
  178. data/examples/pmp/public/app.index.html +277 -0
  179. data/examples/pmp/public/dispatch.cgi +10 -0
  180. data/examples/pmp/public/dispatch.fcgi +24 -0
  181. data/examples/pmp/public/dispatch.rb +10 -0
  182. data/examples/pmp/public/favicon.ico +0 -0
  183. data/examples/pmp/public/images/rails.png +0 -0
  184. data/examples/pmp/public/javascripts/application.js +2 -0
  185. data/examples/pmp/public/javascripts/controls.js +833 -0
  186. data/examples/pmp/public/javascripts/dragdrop.js +942 -0
  187. data/examples/pmp/public/javascripts/effects.js +1088 -0
  188. data/examples/pmp/public/javascripts/prototype.js +2515 -0
  189. data/examples/pmp/public/robots.txt +1 -0
  190. data/examples/pmp/test/fixtures/contacts.yml +5 -0
  191. data/examples/pmp/test/fixtures/document_libraries.yml +5 -0
  192. data/examples/pmp/test/fixtures/issues.yml +5 -0
  193. data/examples/pmp/test/fixtures/projects.yml +5 -0
  194. data/examples/pmp/test/fixtures/resources.yml +5 -0
  195. data/examples/pmp/test/fixtures/tasks.yml +5 -0
  196. data/examples/pmp/test/fixtures/time_cards.yml +5 -0
  197. data/examples/pmp/test/functional/contacts_controller_test.rb +18 -0
  198. data/examples/pmp/test/functional/document_library_controller_test.rb +18 -0
  199. data/examples/pmp/test/functional/issues_controller_test.rb +18 -0
  200. data/examples/pmp/test/functional/projects_controller_test.rb +18 -0
  201. data/examples/pmp/test/functional/resources_controller_test.rb +18 -0
  202. data/examples/pmp/test/functional/tasks_controller_test.rb +18 -0
  203. data/examples/pmp/test/functional/time_cards_controller_test.rb +18 -0
  204. data/examples/pmp/test/test_helper.rb +28 -0
  205. data/examples/pmp/test/unit/contacts_test.rb +10 -0
  206. data/examples/pmp/test/unit/document_library_test.rb +10 -0
  207. data/examples/pmp/test/unit/issues_test.rb +10 -0
  208. data/examples/pmp/test/unit/projects_test.rb +10 -0
  209. data/examples/pmp/test/unit/resources_test.rb +10 -0
  210. data/examples/pmp/test/unit/tasks_test.rb +10 -0
  211. data/examples/pmp/test/unit/time_cards_test.rb +10 -0
  212. data/lib/QuickBaseClient.rb +5054 -0
  213. data/lib/QuickBaseCommandLineClient.rb +401 -0
  214. data/lib/QuickBaseContactsAppBuilder.rb +419 -0
  215. data/lib/QuickBaseEmailer.rb +334 -0
  216. data/lib/QuickBaseEventNotifier.rb +592 -0
  217. data/lib/QuickBaseMisc.rb +96 -0
  218. data/lib/QuickBaseObjects.rb +566 -0
  219. data/lib/QuickBaseRSSGenerator.rb +286 -0
  220. data/lib/QuickBaseTextData.rb +545 -0
  221. data/lib/QuickBaseTwitterConnector.rb +300 -0
  222. data/lib/QuickBaseWebClient.rb +126 -0
  223. data/lib/WorkPlaceClient.rb +45 -0
  224. data/lib/qbc.makeCSVFile.qbc +4 -0
  225. data/lib/qbc.makeCSVFile.rb +17 -0
  226. data/lib/quickbase_adapter.rb +320 -0
  227. data/lib/runFieldEntryDialog.rb +151 -0
  228. data/lib/runOfflineFieldEntryDialog.rb +203 -0
  229. data/rakefile +100 -0
  230. data/test/run_tests.bat +7 -0
  231. data/test/spec_all_tests.rb +13 -0
  232. data/test/spec_smoke_tests.rb +58 -0
  233. data/test/spec_workplace_addrecord_test.rb +46 -0
  234. data/test/spec_workplace_base_test.rb +57 -0
  235. data/test/spec_workplace_editrecord_test.rb +38 -0
  236. data/test/spec_workplace_json_test.rb +38 -0
  237. data/test/spec_workplace_objects_test.rb +39 -0
  238. data/test/spec_workplace_smoke_tests.rb +45 -0
  239. metadata +353 -0
@@ -0,0 +1,203 @@
1
+ #--#####################################################################
2
+ # Copyright (c) 2009 Gareth Lewis and Intuit, Inc.
3
+ #
4
+ # All rights reserved. This program and the accompanying materials
5
+ # are made available under the terms of the Eclipse Public License v1.0
6
+ # which accompanies this distribution, and is available at
7
+ # http://www.opensource.org/licenses/eclipse-1.0.php
8
+ #
9
+ # Contributors:
10
+ # Gareth Lewis - Initial contribution.
11
+ # Intuit Partner Platform.
12
+ #++#####################################################################
13
+
14
+ require 'QuickBaseTextData'
15
+ require 'tk'
16
+
17
+ # Display a dialog with one text entry field, and buttons to send the text to a
18
+ # field in a new record in QuickBase, go to QuickBase, and to close the dialog.
19
+ # * 'dbid' must be a valid table id.
20
+ # * 'field' must be the name or id of a text field in the 'dbid' table.
21
+ # If you can't connect to QuickBase, data will be written to a file in your
22
+ # current working directory then sent to QuickBase next time you are
23
+ # able to connect. Note that you must have connected to QuickBase at least
24
+ # once before you can enter data offline.
25
+ def runOfflineFieldEntryDialog(username,password,dbid,field)
26
+
27
+ connected = false
28
+ appendToOfflineFile = false
29
+
30
+ numTextLines = 1
31
+ tableName = ""
32
+ fieldID = ""
33
+ fieldName = ""
34
+
35
+ offlineDataFileName = "#{dbid}.offline.txt"
36
+ offlineConfigFileName = "#{dbid}.offline.cfg"
37
+
38
+ if FileTest.exist?(offlineConfigFileName)
39
+ File.open(offlineConfigFileName,"r"){|f|
40
+ cfg = f.gets
41
+ tableName, numTextLines, fieldID, fieldName = cfg.split(":::")
42
+ numTextLines = numTextLines.to_i
43
+ }
44
+ end
45
+
46
+ @qbc = QuickBase::Client.new(username,password)
47
+ if @qbc and @qbc.requestSucceeded
48
+ connected = true
49
+ if FileTest.exist?(offlineDataFileName)
50
+ QuickBase::TextData.uploadData(username,password,offlineDataFileName)
51
+ File.delete(offlineDataFileName)
52
+ end
53
+ else
54
+ appendToOfflineFile = true if FileTest.exist?(offlineDataFileName)
55
+ end
56
+
57
+ @offlineDataFile = nil
58
+ if connected
59
+ @qbc.getSchema(dbid)
60
+ if @qbc.requestSucceeded
61
+ field = field.join(' ')
62
+ field.strip!
63
+ fieldID = @qbc.lookupFieldIDByName(field)
64
+ if fieldID
65
+ fieldName = field
66
+ else
67
+ fieldName = lookupFieldNameFromID(field)
68
+ fieldID = field if fieldName
69
+ end
70
+ tableName = @qbc.getResponseElement( "table/name" ).text
71
+ if fieldID and fieldName
72
+ fieldElement = @qbc.lookupField(fieldID)
73
+ numLinesProc = proc { |element|
74
+ if element.is_a?(REXML::Element) and element.name == "num_lines" and element.has_text?
75
+ numTextLines = element.text.to_i
76
+ end
77
+ }
78
+ @qbc.processChildElements(fieldElement, true, numLinesProc)
79
+ File.open(offlineConfigFileName,"w"){|f|f.write("#{tableName}:::#{numTextLines}:::#{fieldID}:::#{fieldName}")}
80
+ else
81
+ Tk.messageBox({"icon"=>"error","title"=>"Oops!", "message" => "Error finding the QuickBase field '#{fieldName}' in the '#{tableName}' table."})
82
+ end
83
+ else
84
+ Tk.messageBox({"icon"=>"error","title"=>"Oops!", "message" => "Error finding the QuickBase table with the '#{dbid}' id."})
85
+ end
86
+ elsif appendToOfflineFile
87
+ @offlineDataFile = File.open(offlineDataFileName, "a")
88
+ else
89
+ @offlineDataFile = File.open(offlineDataFileName, "w")
90
+ @offlineDataFile.puts("dbid:#{dbid}")
91
+ end
92
+
93
+ root = TkRoot.new{ title tableName }
94
+ frame = TkFrame.new(root){
95
+ borderwidth 4
96
+ width 60
97
+ pack "side" => "top"
98
+ }
99
+ if numTextLines == 1
100
+ labelText = "Enter '#{fieldName}' and press Enter or click 'Send to QuickBase':"
101
+ else
102
+ labelText = "Enter '#{fieldName}' and click 'Send to QuickBase':"
103
+ end
104
+ fieldLabel = TkLabel.new(frame){
105
+ text labelText
106
+ font "Arial 10 bold"
107
+ pack "side"=>"top", "expand" => true
108
+ }
109
+
110
+ entryField = nil
111
+ if numTextLines == 1
112
+ entryField = TkEntry.new(frame){
113
+ font "Arial 10 bold"
114
+ pack "fill" => "x", "expand" => true, "side" => "top", "padx" =>5, "pady"=>5
115
+ }
116
+ entryField.bind('Key-Return') {|e|
117
+ value = entryField.get
118
+ if connected
119
+ @qbc.clearFieldValuePairList
120
+ @qbc.addFieldValuePair(nil,fieldID,nil,value)
121
+ @qbc.addRecord(dbid,@qbc.fvlist)
122
+ else
123
+ @offlineDataFile.puts("record:\n#{fieldName}:#{value}")
124
+ end
125
+ entryField.value = ""
126
+ }
127
+ elsif numTextLines > 1
128
+ entryField = TkText.new(frame){
129
+ height numTextLines
130
+ width 60
131
+ font "Arial 10 bold"
132
+ pack "fill" => "both", "expand" => true, "side" => "top", "padx" =>5, "pady"=>5
133
+ wrap "word"
134
+ }
135
+ end
136
+ entryField.focus
137
+
138
+ buttonFrame = TkFrame.new(frame){
139
+ pack "side" => "bottom"
140
+ width 50
141
+ }
142
+ sendButton = TkButton.new(buttonFrame){
143
+ text "Send To QuickBase"
144
+ underline 0
145
+ font "Arial 10 bold"
146
+ pack "side"=>"left", "padx"=>5, "pady"=>5
147
+ }
148
+ sendButton.command {
149
+ if numTextLines > 1
150
+ value = entryField.get("1.0","end")
151
+ else
152
+ value = entryField.get
153
+ end
154
+ if connected
155
+ @qbc.clearFieldValuePairList
156
+ @qbc.addFieldValuePair(nil,fieldID,nil,value)
157
+ @qbc.addRecord(dbid,@qbc.fvlist)
158
+ else
159
+ @offlineDataFile.puts("record:\n#{fieldName}:#{value}")
160
+ end
161
+ entryField.value = ""
162
+ }
163
+
164
+ if connected
165
+ launchButton = TkButton.new(buttonFrame){
166
+ text "Go to QuickBase..."
167
+ underline 0
168
+ font "Arial 10 bold"
169
+ pack "side"=>"left","padx"=>5, "pady"=>5
170
+ }
171
+ launchButton.command {
172
+ url = "http://www.quickbase.com/db/#{dbid}"
173
+ url = "start #{url}" if RUBY_PLATFORM.split("-")[1].include?("mswin")
174
+ system(url)
175
+ }
176
+ end
177
+ closeButton = TkButton.new(buttonFrame){
178
+ text "Close"
179
+ underline 0
180
+ font "Arial 10 bold"
181
+ pack "side"=>"right","padx"=>5, "pady"=>5
182
+ }
183
+ closeButton.command { Tk.exit }
184
+
185
+ root.bind('Alt-KeyRelease-s') {|e| sendButton.invoke }
186
+ root.bind('Alt-KeyRelease-l') {|e| launchButton.invoke }
187
+ root.bind('Alt-KeyRelease-c') {|e| closeButton.invoke }
188
+
189
+ Tk.mainloop
190
+ end
191
+
192
+ if ARGV[3]
193
+ runOfflineFieldEntryDialog(ARGV[0],ARGV[1],ARGV[2],ARGV[3..-1])
194
+ else
195
+ puts "\nusage: ruby runOfflineFieldEntryDialog.rb username password dbid field"
196
+ puts "\n'dbid' must be a valid table id."
197
+ puts "'field' must be the name or id of a text field in the 'dbid' table."
198
+ puts "'field' can be more than one word, e.g. 'To-Do Item'."
199
+ puts "If you can't connect to QuickBase, data will be written to a file in"
200
+ puts "your current working directory then sent to QuickBase next time you"
201
+ puts "are able to connect. Note that you must have connected to QuickBase"
202
+ puts "at least once before you can enter data offline.\n"
203
+ end
data/rakefile ADDED
@@ -0,0 +1,100 @@
1
+
2
+ require 'rake'
3
+ require 'rake/gempackagetask'
4
+ require 'spec/rake/spectask'
5
+
6
+ spec = Gem::Specification.new do |s|
7
+ s.rubyforge_project = "orphans" # prevents WARNING
8
+
9
+ if RUBY_PLATFORM == "java" # jruby
10
+ s.name = "ipp_quickbase_devkit_jruby" # saves people having to download additional jruby-specific gems
11
+ s.description = "The ipp_quickbase_devkit_jruby wraps the QuickBase HTTP API and adds a lot of classes and methods to minimize the amount of code need to get useful things done."
12
+ s.add_dependency("json-jruby")
13
+ s.add_dependency("jruby-openssl")
14
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--main", "README.rdoc", "--title", "ipp_quickbase_devkit_jruby: JRuby client for database applications on www.quickbase.com and workplace.intuit.com"]
15
+ s.post_install_message = %q{**************************************************
16
+
17
+ Thank you for installing ipp_quickbase_devkit_jruby.
18
+ Distributed under the Eclipse Public License Version 1.0.
19
+
20
+ **************************************************
21
+ }
22
+ else
23
+ s.name = "ipp_quickbase_devkit"
24
+ s.description = "The ipp_quickbase_devkit wraps the QuickBase HTTP API and adds a lot of classes and methods to minimize the amount of code need to get useful things done."
25
+ s.add_dependency("json") if RUBY_VERSION.include?("1.8.")
26
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--main", "README.rdoc", "--title", "ipp_quickbase_devkit: Ruby client for database applications on www.quickbase.com and workplace.intuit.com"]
27
+ s.post_install_message = %q{**************************************************
28
+
29
+ Thank you for installing ipp_quickbase_devkit.
30
+ Distributed under the Eclipse Public License Version 1.0.
31
+
32
+ **************************************************
33
+ }
34
+
35
+ end
36
+ s.version = "0.0.1"
37
+ s.date = "2009-07-01"
38
+ s.authors = ["Gareth Lewis"]
39
+ s.email = "dev-ipp_dev_kits@code.intuit.com"
40
+ s.summary = "The ipp_quickbase_devkit is a Ruby wrapper for the QuickBase HTTP API."
41
+ s.homepage = "https://code.intuit.com/sf/projects/ipp_dev_kits"
42
+ s.has_rdoc = true
43
+ s.extra_rdoc_files = ["LICENSE","README.rdoc"]
44
+ s.require_paths = ["lib"]
45
+ s.add_dependency("rspec", [">= 1.2.7"])
46
+ s.add_development_dependency("rspec", [">= 1.2.7"])
47
+ s.required_ruby_version = ">=1.8.6"
48
+ s.platform = Gem::Platform::RUBY
49
+ s.files = FileList["LICENSE","README.rdoc","rakefile","examples/**/*.","examples/**/*.*","doc/*.*","lib/*.rb","lib/*.qbc","test/*.rb","test/*.bat"].exclude(".svn").to_a
50
+ end
51
+
52
+ Rake::GemPackageTask.new(spec).define
53
+
54
+ Spec::Rake::SpecTask.new(:spec) do |t|
55
+ t.spec_files = FileList['spec_all_tests.rb']
56
+ t.ruby_opts = ['-C test']
57
+ end
58
+
59
+ desc 'Uninstall dev gem'
60
+ task :uninstall_gem do
61
+ if RUBY_PLATFORM == "java"
62
+ sh 'jruby -S gem uninstall ipp_quickbase_devkit_jruby'
63
+ else
64
+ sh 'gem uninstall ipp_quickbase_devkit'
65
+ end
66
+ end
67
+
68
+ desc 'Build dev gem'
69
+ task :build_gem do
70
+ Rake::Task[:repackage].invoke
71
+ end
72
+
73
+ desc 'Install dev gem'
74
+ task :install_gem do
75
+ if RUBY_PLATFORM == "java"
76
+ sh 'jruby -S gem install pkg/ipp_quickbase_devkit_jruby'
77
+ else
78
+ sh 'gem install pkg/ipp_quickbase_devkit'
79
+ end
80
+ end
81
+
82
+ desc '(Default task) Uninstalls, rebuilds & installs gem from source'
83
+ task :full_rebuild do
84
+ Rake::Task[:uninstall_gem].invoke
85
+ Rake::Task[:repackage].invoke
86
+ Rake::Task[:install_gem].invoke
87
+ end
88
+
89
+ desc 'Full rebuild, then run tests'
90
+ task :full_rebuild_and_test do
91
+ Rake::Task[:full_rebuild].invoke
92
+ puts "**************************************************"
93
+ puts ""
94
+ puts " Running unit tests"
95
+ puts ""
96
+ puts "**************************************************"
97
+ Rake::Task[:spec].invoke
98
+ end
99
+
100
+ task :default => :full_rebuild
@@ -0,0 +1,7 @@
1
+ @echo off
2
+
3
+ set RUBYLIB=
4
+
5
+ call spec spec_all_tests.rb > testresults.txt
6
+
7
+ REM pause
@@ -0,0 +1,13 @@
1
+
2
+
3
+ def ruby19?
4
+ RUBY_VERSION >= "1.9"
5
+ end
6
+
7
+ require 'rubygems'
8
+ require 'spec_smoke_tests'
9
+ require 'spec_workplace_smoke_tests'
10
+ require 'spec_workplace_objects_test'
11
+ require 'spec_workplace_addrecord_test'
12
+ require 'spec_workplace_editrecord_test'
13
+ require 'spec_workplace_json_test'
@@ -0,0 +1,58 @@
1
+
2
+ require 'spec'
3
+
4
+ describe "Smoke Test" do
5
+
6
+ it "should show that the basic ruby files are in the regular ruby paths" do
7
+ found = false
8
+ $:.each{|path| found = true if File.exist?("#{path}/date.rb") }
9
+ found.should == true
10
+ end
11
+
12
+ it "should show that the main ipp_quickbase_devkit src file is not in the regular ruby paths" do
13
+ found = false
14
+ $:.each{|path| found = true if File.exist?("#{path}/QuickBaseClient.rb") } unless ruby19?
15
+ found.should == false
16
+ end
17
+
18
+ it "should show that the main ipp_quickbase_devkit src file is not loaded by default" do
19
+ found = false
20
+ $".each{|path| found = true if path.include? "QuickBaseClient.rb" }
21
+ found.should == false
22
+ end
23
+
24
+ it "should find ipp_quickbase_devkit" do
25
+ found = require 'QuickBaseClient'
26
+ found.should == true
27
+ end
28
+
29
+ it "should create a QuickBase::Client" do
30
+ qbc_required = require 'QuickBaseClient'
31
+ qbc = QuickBase::Client.new
32
+ qbc.should_not == nil
33
+ end
34
+
35
+ it "should create a QuickBase::CommandLineClient" do
36
+ require 'QuickBaseCommandLineClient'
37
+ qbc = QuickBase::CommandLineClient.new
38
+ qbc.should_not == nil
39
+ end
40
+
41
+ it "should create a QuickBase::WebClient" do
42
+ require 'QuickBaseWebClient'
43
+ qbc = QuickBase::WebClient.new(false)
44
+ qbc.should_not == nil
45
+ end
46
+
47
+ it "should show that the gem searching is turned on" do
48
+ gemSearching = ENV["RUBYOPT"].include? "-rubygems"
49
+ gemSearching.should == true
50
+ end
51
+
52
+ it "should NOT find ipp_quickbase_devkit when -rubygems option is off" do
53
+ ENV["RUBYOPT"]=""
54
+ found = require 'QuickBaseClient'
55
+ found.should == false
56
+ end
57
+
58
+ end
@@ -0,0 +1,46 @@
1
+
2
+ require 'spec_workplace_base_test'
3
+ require 'spec'
4
+
5
+ describe "Workplace Add Record test" do
6
+
7
+ it "should add a Person" do
8
+
9
+ require 'WorkPlaceClient'
10
+ class WorkPlaceAddRecordTest
11
+ include WorkPlaceBaseTest
12
+ end
13
+ wpart = WorkPlaceAddRecordTest.new
14
+ workPlaceClient = wpart.setup
15
+ workPlaceClient.should_not == nil
16
+
17
+ personFieldValues = Hash["First Name", "FirstName", "Last Name", "LastName", "Email", "FirstNameLastName@email.com","Web Page","http://www.FirstNameLastName.com","Opt In","1","DOB","12-12-1978","Attention Span","1","Favorite Number","7","Amount Owed", "34.87","Rating", "4","PhoneNumber", "454-323-3456","Bedtime", "23","Address", "10 Downing Street"]
18
+ workPlaceClient.setFieldValues(personFieldValues)
19
+ rid, update_id = workPlaceClient.addRecord(wpart.personTableDBID,workPlaceClient.fvlist)
20
+ rid.should_not == nil
21
+
22
+ end
23
+
24
+ it "should add a Person with an Image file attachment" do
25
+
26
+ require 'WorkPlaceClient'
27
+ class WorkPlaceAddRecordTest
28
+ include WorkPlaceBaseTest
29
+ end
30
+ wpart = WorkPlaceAddRecordTest.new
31
+ workPlaceClient = wpart.setup
32
+ workPlaceClient.should_not == nil
33
+
34
+ workPlaceClient.addFieldValuePair("First Name",nil,nil,"Whatever")
35
+ workPlaceClient.addFieldValuePair("Last Name",nil,nil,"Works")
36
+ workPlaceClient.addFieldValuePair("Image",nil,"FileName","File Contents") # contents from memory
37
+ rid, update_id = workPlaceClient.addRecord(wpart.personTableDBID,workPlaceClient.fvlist)
38
+ rid.should_not == nil
39
+
40
+ fid = workPlaceClient.lookupFieldIDByName("Image", wpart.personTableDBID)
41
+ response, filecontents = workPlaceClient._downLoadFile(rid,fid)
42
+ filecontents.should == "File Contents"
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,57 @@
1
+
2
+ module WorkPlaceBaseTest
3
+
4
+ attr_reader :workPlaceClient, :testAppDBID, :testAppName, :personTableDBID, :personFields
5
+
6
+ def setup
7
+
8
+ if not File.exist?("test.config")
9
+ File.open("test.config","w"){|f|
10
+ f.puts("username:<enter your workplace username>")
11
+ f.puts("password:<enter your workplace password>")
12
+ f.puts("appname:<enter the name of an existing test application, e.g. MyTestApp>")
13
+ f.puts("apptoken:<enter a valid application token for your test application>")
14
+ raise "***Please fill out the fields in test.config***"
15
+ }
16
+ end
17
+
18
+ @options = {}
19
+ #@options["printRequestsAndResponses"]=true
20
+ @options["stopOnError"]=true
21
+ IO.foreach("test.config"){|line|
22
+ key,value = line.split(/:/)
23
+ @options[key]=value.strip if key and value
24
+ }
25
+
26
+ raise "'username' missing from test.config" if !@options["username"]
27
+ raise "'password' missing from test.config" if !@options["password"]
28
+ raise "'appname' missing from test.config" if !@options["appname"]
29
+ raise "'apptoken' missing from test.config" if !@options["apptoken"]
30
+
31
+ @workPlaceClient = QuickBase::WorkPlaceClient.init(@options)
32
+
33
+ #@workPlaceClient.printRequestsAndResponses=true
34
+
35
+ @workPlaceClient.grantedDBs().each{|dbinfo| @testAppDBID = dbinfo.dbid if dbinfo.dbname == @options["appname"] }
36
+
37
+ @testAppName = "Test copy of #{@options['appname']}"
38
+ @workPlaceClient.grantedDBs().each{|dbinfo| @workPlaceClient.deleteDatabase(dbinfo.dbid) if dbinfo.dbname == @testAppName }
39
+ @testAppDBID = @workPlaceClient.cloneDatabase(@testAppDBID, @testAppName, @testAppName, true) if @testAppDBID
40
+
41
+ @testAppName = @options['appname'] unless @testAppDBID
42
+ @testAppDBID = @workPlaceClient.createDatabase(@options["appname"],@options["appname"]) unless @testAppDBID
43
+
44
+ raise "Unable to clone or create an application with the name #{@options['appname']}" unless @testAppDBID
45
+
46
+ @personsTableName = "Persons"
47
+ @personTableDBID = @workPlaceClient.createTable(@personsTableName, @testAppDBID)
48
+ @personFields = Hash["First Name", "text", "Last Name", "text", "Email", "email","Image","file","Web Page","url","Opt In","checkbox","DOB","date","Attention Span","duration","Favorite Number","float","Favorite Number Squared","float","Amount Owed", "currency","Rating", "rating","PhoneNumber", "phone","Bedtime", "timeofday","Address", "text"]
49
+ @personFields.each{|name,type|
50
+ fid,label = @workPlaceClient.addField(@personTableDBID,name,type)
51
+ @workPlaceClient.setFieldProperties(@personTableDBID,{"formula" => "[Favorite Number] * [Favorite Number]"},fid) if name == "Favorite Number Squared"
52
+ @workPlaceClient.setFieldProperties(@personTableDBID,{"num_lines" => "3"},fid) if name == "Address"
53
+ }
54
+ @workPlaceClient
55
+ end
56
+
57
+ end