ruby_odata 0.0.4 → 0.0.5
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/CHANGELOG.rdoc +6 -1
- data/README.rdoc +16 -2
- data/VERSION +1 -1
- data/lib/ruby_odata.rb +3 -2
- data/lib/ruby_odata/class_builder.rb +12 -3
- data/lib/ruby_odata/service.rb +1 -1
- data/ruby_odata.gemspec +2 -2
- metadata +4 -4
data/CHANGELOG.rdoc
CHANGED
@@ -19,4 +19,9 @@
|
|
19
19
|
* Query Enhancement: skip
|
20
20
|
* Query Enhancement: top
|
21
21
|
* Ability to perform paging using skip and top together
|
22
|
-
* Updated README with examples for order_by, skip, and top
|
22
|
+
* Updated README with examples for order_by, skip, and top
|
23
|
+
|
24
|
+
=== 0.0.5
|
25
|
+
* Bug Fixes
|
26
|
+
* Works with Ruby 1.9.1
|
27
|
+
* Works with ActiveSupport 3.0.0.beta4
|
data/README.rdoc
CHANGED
@@ -1,11 +1,25 @@
|
|
1
|
-
Error: The word "DATABASE SETUP - DO THIS FIRST*" is invalid. The character ' ' (U+20) may not appear in the middle of a word.
|
2
1
|
= ruby_odata
|
3
2
|
|
4
3
|
The <b>Open Data Protocol</b> (OData) is a fantastic way to query and update data over standard Web technologies. The ruby_odata library acts as a consumer of OData services.
|
5
4
|
|
5
|
+
== Resources
|
6
|
+
|
7
|
+
* Source Code (hosted on GitHub): http://github.com/visoft/ruby_odata
|
8
|
+
* Documentation (hosted on rdoc.info): http://rdoc.info/projects/visoft/ruby_odata
|
9
|
+
* Issue tracking (hosted on Lighthouse): http://visoft.lighthouseapp.com/projects/54309/home
|
10
|
+
* Wiki (hosted on GitHub): http://wiki.github.com/visoft/ruby_odata/
|
11
|
+
* Gem (hosted on Gemcutter): http://gemcutter.org/gems/ruby_odata
|
12
|
+
* Blog articles: {Introducing a Ruby OData Client Library}[http://bit.ly/IntroRubyOData]
|
13
|
+
|
14
|
+
== Installation
|
15
|
+
You can install ruby_odata as a gem using:
|
16
|
+
gem install ruby_odata
|
17
|
+
|
6
18
|
== Usage
|
7
19
|
The API is a work in progress. Notably, changes can't be bundled (through save_changes, only the last operation before save_changes is persisted).
|
8
20
|
|
21
|
+
As of version 0.0.5, support has been added for ActiveSupport 3.0.0 beta 4 and Ruby 1.9.1
|
22
|
+
|
9
23
|
=== Adding
|
10
24
|
When you point at a service, an AddTo<EntityName> method is created for you. This method takes in the new entity to create. To commit the change, you need to call the save_changes method on the service. To add a new category for example, you would simply do the following:
|
11
25
|
|
@@ -130,7 +144,7 @@ Top allows you only retrieve the top X number of records when querying. This is
|
|
130
144
|
products = svc.execute # => returns only the first 5 items
|
131
145
|
|
132
146
|
== Tests
|
133
|
-
|
147
|
+
===DATABASE SETUP - DO THIS FIRST
|
134
148
|
Within /test/SampleService/App_Data/ rename _TestDB*.* to TestDB*.*. This file is just the initial database, and needs to be renamed so that unwanted changes to that DB aren't persisted in source control.
|
135
149
|
|
136
150
|
All of the tests are written using Cucumber going against a sample service (Found in /test/SampleService/*). The SampleService is an ASP.NET Web Site running a SQLEXPRESS 2008 R2 Database (TestDB), as well as the ADO.NET Entity Framework and a WCF Data Service. In order to run the tests, you need to spin up the SampleService and have it running on port 8888 (http://localhost:8888/SampleService).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/ruby_odata.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
lib = File.dirname(__FILE__)
|
2
|
-
$: << lib + '/ruby_odata/'
|
3
2
|
|
3
|
+
$: << lib + '/ruby_odata/'
|
4
4
|
require 'rubygems'
|
5
|
-
require 'active_support'
|
5
|
+
require 'active_support' # Used for serializtion to JSON
|
6
6
|
require 'active_support/inflector'
|
7
|
+
require 'active_support/core_ext'
|
7
8
|
require 'cgi'
|
8
9
|
require 'open-uri'
|
9
10
|
require 'rest_client'
|
@@ -22,7 +22,7 @@ module OData
|
|
22
22
|
return nil if @klass_name.nil?
|
23
23
|
|
24
24
|
# return if we can find constant corresponding to class name
|
25
|
-
if Object.
|
25
|
+
if Object.const_defined? @klass_name
|
26
26
|
@klass = @klass_name.constantize
|
27
27
|
return @klass
|
28
28
|
end
|
@@ -47,9 +47,18 @@ module OData
|
|
47
47
|
end
|
48
48
|
klass.send :define_method, :as_json do |options|
|
49
49
|
meta = '__metadata'
|
50
|
+
|
51
|
+
options ||= {}
|
52
|
+
options[:type] ||= :unknown
|
53
|
+
|
50
54
|
vars = self.instance_values
|
51
|
-
|
52
|
-
|
55
|
+
|
56
|
+
# For adds, we need to get rid of all attributes except __metadata when passing
|
57
|
+
# the object to the server
|
58
|
+
# TODO: There should be a universal way to figure out if we are on an addition
|
59
|
+
# activesupport 2.3.8 doesn't pass through the :type to all levels, but passes :seen
|
60
|
+
# activesupport 3.0.0.beta4 doesn't pass :seen in options
|
61
|
+
if (options[:type] == :add || !options[:seen].nil?) && vars.has_key?(meta)
|
53
62
|
vars.delete_if { |k,v| k != meta}
|
54
63
|
else
|
55
64
|
vars.delete(meta)
|
data/lib/ruby_odata/service.rb
CHANGED
@@ -72,7 +72,7 @@ class Service
|
|
72
72
|
|
73
73
|
if @save_operation.kind == "Add"
|
74
74
|
save_uri = "#{@uri}/#{@save_operation.klass_name}"
|
75
|
-
json_klass = @save_operation.klass.to_json
|
75
|
+
json_klass = @save_operation.klass.to_json(:type => :add)
|
76
76
|
post_result = RestClient.post save_uri, json_klass, :content_type => :json
|
77
77
|
result = build_classes_from_result(post_result)
|
78
78
|
elsif @save_operation.kind == "Update"
|
data/ruby_odata.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruby_odata}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Damien White"]
|
12
|
-
s.date = %q{2010-06-
|
12
|
+
s.date = %q{2010-06-13}
|
13
13
|
s.description = %q{An OData Client Library for Ruby. Use this to interact with OData services}
|
14
14
|
s.email = %q{damien.white@visoftinc.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_odata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Damien White
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-13 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|