ruby_odata 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +9 -0
  2. data/LICENSE +24 -0
  3. data/README.rdoc +107 -0
  4. data/Rakefile +28 -0
  5. data/VERSION +1 -0
  6. data/config/cucumber.yml +7 -0
  7. data/doc/classes/OData/ClassBuilder.html +219 -0
  8. data/doc/classes/OData/Operation.html +194 -0
  9. data/doc/classes/OData/QueryBuilder.html +305 -0
  10. data/doc/classes/OData/Service.html +420 -0
  11. data/doc/classes/OData.html +126 -0
  12. data/doc/created.rid +1 -0
  13. data/doc/files/README_rdoc.html +252 -0
  14. data/doc/files/lib/odata_ruby/class_builder_rb.html +101 -0
  15. data/doc/files/lib/odata_ruby/operation_rb.html +101 -0
  16. data/doc/files/lib/odata_ruby/query_builder_rb.html +101 -0
  17. data/doc/files/lib/odata_ruby/service_rb.html +101 -0
  18. data/doc/files/lib/odata_ruby_rb.html +114 -0
  19. data/doc/fr_class_index.html +31 -0
  20. data/doc/fr_file_index.html +32 -0
  21. data/doc/fr_method_index.html +40 -0
  22. data/doc/index.html +24 -0
  23. data/doc/rdoc-style.css +208 -0
  24. data/features/service.feature +82 -0
  25. data/features/service_manage.feature +44 -0
  26. data/features/step_definitions/service_steps.rb +132 -0
  27. data/features/support/env.rb +4 -0
  28. data/features/support/hooks.rb +4 -0
  29. data/lib/odata_ruby/class_builder.rb +84 -0
  30. data/lib/odata_ruby/operation.rb +18 -0
  31. data/lib/odata_ruby/query_builder.rb +63 -0
  32. data/lib/odata_ruby/service.rb +207 -0
  33. data/lib/odata_ruby.rb +15 -0
  34. data/ruby_odata.gemspec +94 -0
  35. data/test/Cassini x64.bat +1 -0
  36. data/test/Cassini x86.bat +1 -0
  37. data/test/SampleService/App_Code/Entities.cs +39 -0
  38. data/test/SampleService/App_Code/Model.Designer.cs +414 -0
  39. data/test/SampleService/App_Code/Model.edmx +140 -0
  40. data/test/SampleService/App_Data/_TestDB.mdf +0 -0
  41. data/test/SampleService/App_Data/_TestDB_Log.ldf +0 -0
  42. data/test/SampleService/Entities.svc +1 -0
  43. data/test/SampleService/web.config +27 -0
  44. data/test/blueprints.rb +16 -0
  45. metadata +158 -0
@@ -0,0 +1,252 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: README.rdoc</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>README.rdoc</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>README.rdoc
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Jun 09 22:59:40 -0400 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h1>odata_ruby</h1>
73
+ <p>
74
+ The <b>Open Data Protocol</b> (<a href="../classes/OData.html">OData</a>)
75
+ is a fantastic way to query and update data over standard Web technologies.
76
+ The odata_ruby library acts as a consumer of <a
77
+ href="../classes/OData.html">OData</a> services.
78
+ </p>
79
+ <h2>Usage</h2>
80
+ <p>
81
+ The API is a work in progress. Notably, changes can&#8216;t be bundled
82
+ (through save_changes, only the last operation before save_changes is
83
+ persisted).
84
+ </p>
85
+ <h3>Adding</h3>
86
+ <p>
87
+ When you point at a service, an AddTo&lt;EntityName&gt; method is created
88
+ for you. This method takes in the new entity to create. To commit the
89
+ change, you need to call the save_changes method on the service. To add a
90
+ new category for example, you would simply do the following:
91
+ </p>
92
+ <pre>
93
+ require 'lib/odata_ruby'
94
+
95
+ svc = OData::Service.new &quot;http://127.0.0.1:8888/SampleService/Entities.svc&quot;
96
+ new_category = Category.new
97
+ new_category.Name = &quot;Sample Category&quot;
98
+ svc.AddToCategories(new_category)
99
+ category = svc.save_changes
100
+ puts category.to_json
101
+ </pre>
102
+ <h3>Updating</h3>
103
+ <p>
104
+ To update an object, simply pass the modified object to the update_object
105
+ method on the service. Updating, like adding requires you to call
106
+ save_changes in order to persist the change. For example:
107
+ </p>
108
+ <pre>
109
+ require 'lib/odata_ruby'
110
+
111
+ svc = OData::Service.new &quot;http://127.0.0.1:8888/SampleService/Entities.svc&quot;
112
+ new_category = Category.new
113
+ new_category.Name = &quot;Sample Category&quot;
114
+ svc.AddToCategories(new_category)
115
+ category = svc.save_changes
116
+ puts category.to_json
117
+
118
+ category.Name = 'Updated Category'
119
+ svc.update_object(category)
120
+ result = svc.save_changes
121
+ puts &quot;Was the category updated? #{result}&quot;
122
+ </pre>
123
+ <h3>Deleting</h3>
124
+ <p>
125
+ Deleting an object involves passing the tracked object to the delete_object
126
+ method on the service. Deleting is another function that involves the
127
+ save_changes method (to commit the change back to the server). In this
128
+ example, we&#8216;ll add a category and then delete it.
129
+ </p>
130
+ <pre>
131
+ require 'lib/odata_ruby'
132
+
133
+ svc = OData::Service.new &quot;http://127.0.0.1:8888/SampleService/Entities.svc&quot;
134
+ new_category = Category.new
135
+ new_category.Name = &quot;Sample Category&quot;
136
+ svc.AddToCategories(new_category)
137
+ category = svc.save_changes
138
+ puts category.to_json
139
+
140
+ svc.delete_object(category)
141
+ result = svc.save_changes
142
+ puts &quot;Was the category deleted? #{result}&quot;
143
+ </pre>
144
+ <h3>Querying</h3>
145
+ <p>
146
+ Querying is easy, for example to pull all the categories from the
147
+ SampleService, you simply can run:
148
+ </p>
149
+ <pre>
150
+ require 'lib/odata_ruby'
151
+
152
+ svc = OData::Service.new &quot;http://127.0.0.1:8888/SampleService/Entities.svc&quot;
153
+ svc.Categories
154
+ categories = svc.execute
155
+ puts categories.to_json
156
+ </pre>
157
+ <p>
158
+ You can also expand and add filters to the query before executing it. For
159
+ example:
160
+ </p>
161
+ <h3>Expanding</h3>
162
+ <pre>
163
+ # Without expanding the query
164
+ svc.Products(1)
165
+ prod1 = svc.execute
166
+ puts &quot;Without expanding the query&quot;
167
+ puts &quot;#{prod1.to_json}\n&quot;
168
+
169
+ # With expanding the query
170
+ svc.Products(1).expand('Category')
171
+ prod1 = svc.execute
172
+ puts &quot;Without expanding the query&quot;
173
+ puts &quot;#{prod1.to_json}\n&quot;
174
+ </pre>
175
+ <h3>Filtering</h3>
176
+ <pre>
177
+ # You can access by ID (but that isn't is a filter)
178
+ # The syntax is just svc.ENTITYNAME(ID) which is shown in the expanding examples above
179
+
180
+ svc.Products.filter(&quot;Name eq 'Product 2'&quot;)
181
+ prod = svc.execute
182
+ puts &quot;Filtering on Name eq 'Product 2'&quot;
183
+ puts &quot;#{prod.to_json}&quot;
184
+ </pre>
185
+ <h3>Combining Expanding and Filtering</h3>
186
+ <pre>
187
+ svc.Products.filter(&quot;Name eq 'Product 2'&quot;).expand(&quot;Category&quot;)
188
+ prod = svc.execute
189
+ puts &quot;Filtering on Name eq 'Product 2' and expanding&quot;
190
+ puts &quot;#{prod.to_json}&quot;
191
+ </pre>
192
+ <h2>Tests</h2>
193
+ <p>
194
+ *DATABASE SETUP - DO THIS FIRST* Within /test/SampleService/App_Data/
195
+ rename _TestDB*.* to TestDB*.*. This file is just the inital database, and
196
+ needs to be renamed so that unwanted changes to that DB aren&#8216;t
197
+ persisted in source control.
198
+ </p>
199
+ <p>
200
+ All of the tests are written using Cucumber going against a sample service
201
+ (Found in /test/SampleService/*). The SampleService is an ASP.NET Web Site
202
+ running a SQLEXPRESS 2008 R2 Database (TestDB), as well as the ADO.NET
203
+ Entity Framework and a WCF Data Service. In order to run the tests, you
204
+ need to spin up the SampleService and have it running on port 8888 (<a
205
+ href="http://localhost:8888/SampleService">localhost:8888/SampleService</a>).
206
+ </p>
207
+ <p>
208
+ One way to do this is to open the SampleService within Visual Studio 2010
209
+ and run it from there. Another option is to use Cassini (the built ASP.NET
210
+ Development server that comes with Visual Studio 2010). There is a batch
211
+ file found in /test called &quot;Cassini x64.bat&quot;, you can run the
212
+ batch file and just close the command window. There is a also a
213
+ &quot;Cassini x86.bat&quot; file for those of you running a 32-bit machine,
214
+ however it hasn&#8216;t been tested. The only difference is the path to the
215
+ Program Files directory. Once you run the batch file, the web server will
216
+ spin up and you can find the instance in your systray just like if Visual
217
+ Studio ran it for you. To stop the server, right click on the icon in your
218
+ systray and tell it to stop
219
+ </p>
220
+
221
+ </div>
222
+
223
+
224
+ </div>
225
+
226
+
227
+ </div>
228
+
229
+
230
+ <!-- if includes -->
231
+
232
+ <div id="section">
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+ <!-- if method_list -->
242
+
243
+
244
+ </div>
245
+
246
+
247
+ <div id="validator-badges">
248
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
249
+ </div>
250
+
251
+ </body>
252
+ </html>
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: class_builder.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>class_builder.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/odata_ruby/class_builder.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Fri Jun 04 22:12:22 -0400 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+
73
+ </div>
74
+
75
+
76
+ </div>
77
+
78
+
79
+ <!-- if includes -->
80
+
81
+ <div id="section">
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <!-- if method_list -->
91
+
92
+
93
+ </div>
94
+
95
+
96
+ <div id="validator-badges">
97
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
98
+ </div>
99
+
100
+ </body>
101
+ </html>
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: operation.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>operation.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/odata_ruby/operation.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Thu May 20 09:26:51 -0400 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+
73
+ </div>
74
+
75
+
76
+ </div>
77
+
78
+
79
+ <!-- if includes -->
80
+
81
+ <div id="section">
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <!-- if method_list -->
91
+
92
+
93
+ </div>
94
+
95
+
96
+ <div id="validator-badges">
97
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
98
+ </div>
99
+
100
+ </body>
101
+ </html>
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: query_builder.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>query_builder.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/odata_ruby/query_builder.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Jun 09 20:45:17 -0400 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+
73
+ </div>
74
+
75
+
76
+ </div>
77
+
78
+
79
+ <!-- if includes -->
80
+
81
+ <div id="section">
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <!-- if method_list -->
91
+
92
+
93
+ </div>
94
+
95
+
96
+ <div id="validator-badges">
97
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
98
+ </div>
99
+
100
+ </body>
101
+ </html>
@@ -0,0 +1,101 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: service.rb</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>service.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/odata_ruby/service.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Fri Jun 11 00:13:55 -0400 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+
72
+
73
+ </div>
74
+
75
+
76
+ </div>
77
+
78
+
79
+ <!-- if includes -->
80
+
81
+ <div id="section">
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <!-- if method_list -->
91
+
92
+
93
+ </div>
94
+
95
+
96
+ <div id="validator-badges">
97
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
98
+ </div>
99
+
100
+ </body>
101
+ </html>