easy_data 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/.gitignore +4 -0
- data/README +28 -3
- data/{linked_data.gemspec → easy_data.gemspec} +3 -3
- data/lib/controllers/easy_datas_controller.rb +40 -0
- data/lib/easy_data/version.rb +3 -0
- data/lib/{linked_data.rb → easy_data.rb} +8 -3
- data/lib/routes.rb +13 -0
- data/lib/tasks/testing_installation.rb +6 -0
- metadata +11 -15
- data/bin/.linked_data.swp +0 -0
- data/init.rb +0 -14
- data/lib/controllers/.linked_datas_controller.rb.swp +0 -0
- data/lib/controllers/linked_datas_controller.rb +0 -11
- data/lib/linked_data/version.rb +0 -3
- data/lib/views/.rdf.html.erb.swp +0 -0
- data/lib/views/rdf.html.erb +0 -6
- data/setup.rb +0 -0
data/.gitignore
CHANGED
data/README
CHANGED
@@ -1,6 +1,31 @@
|
|
1
|
-
|
1
|
+
Installation
|
2
|
+
===============
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
copy this lines to config/environment.rb:
|
5
|
+
|
6
|
+
begin
|
7
|
+
require "easy_data"
|
8
|
+
rescue LoadError
|
9
|
+
end
|
10
|
+
|
11
|
+
In config/routes.rb at the end of routes declarations include:
|
12
|
+
|
13
|
+
EasyDataRouting.routes(map)
|
14
|
+
|
15
|
+
|
16
|
+
Commandas and Query
|
17
|
+
======================
|
18
|
+
|
19
|
+
To get all possibles querys and URI's offers use this url:
|
20
|
+
|
21
|
+
http://[project_host]/list_models
|
22
|
+
|
23
|
+
After, to get any information about any model or resource, used this url:
|
24
|
+
|
25
|
+
http://[project_host]/foaf/[model]/[id][.format]
|
26
|
+
|
27
|
+
[model] = any model list in first url
|
28
|
+
[id] = to get any information with primary key
|
29
|
+
[format] = this is for advance users, get response in this format
|
5
30
|
|
6
31
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "
|
3
|
+
require "easy_data/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "easy_data"
|
7
|
-
s.version =
|
7
|
+
s.version = EasyData::VERSION
|
8
8
|
s.authors = ["jnillo"]
|
9
|
-
s.email = ["
|
9
|
+
s.email = ["jnillo@rubysemantic.com"]
|
10
10
|
s.homepage = "http://rubygems.org/gem/easy_data"
|
11
11
|
s.summary = "This is not a summary"
|
12
12
|
s.description = "this is a gem description"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "action_controller"
|
2
|
+
|
3
|
+
|
4
|
+
class EasyDatasController < ActionController::Base
|
5
|
+
|
6
|
+
def show
|
7
|
+
begin
|
8
|
+
model = eval params[:model].to_s
|
9
|
+
|
10
|
+
if params[:id]
|
11
|
+
@request = model.find params[:id]
|
12
|
+
else
|
13
|
+
@request={}
|
14
|
+
relations = {}
|
15
|
+
@request["model"] = params[:model].to_s
|
16
|
+
@request["attributes"] = model.columns.map{|att| att.name}.join(", ")
|
17
|
+
|
18
|
+
model.reflections.each do |relation,values|
|
19
|
+
relations[relation] = {"model" => values.class_name,"type" => values.macro.to_s}
|
20
|
+
end
|
21
|
+
@request["relations"] = relations
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
render :xml => @request
|
26
|
+
rescue
|
27
|
+
raise ActionController::RoutingError.new('Not Found')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def describe_api
|
32
|
+
models = DataModels.load_models
|
33
|
+
list = {}
|
34
|
+
models.each do |mod|
|
35
|
+
list[mod] = "foaf/#{mod}"
|
36
|
+
end
|
37
|
+
|
38
|
+
render :xml => list
|
39
|
+
end
|
40
|
+
end
|
@@ -1,8 +1,11 @@
|
|
1
|
-
require "
|
1
|
+
require "easy_data/version"
|
2
2
|
require "data_models/data_models"
|
3
|
+
require "action_controller"
|
4
|
+
require "controllers/easy_datas_controller"
|
5
|
+
require "routes"
|
6
|
+
|
7
|
+
module EasyData
|
3
8
|
|
4
|
-
module LinkedData
|
5
|
-
|
6
9
|
def show_linked_data
|
7
10
|
models = LinkedData.find :all
|
8
11
|
end
|
@@ -33,3 +36,5 @@ module LinkedData
|
|
33
36
|
end
|
34
37
|
|
35
38
|
end
|
39
|
+
|
40
|
+
|
data/lib/routes.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "action_controller"
|
2
|
+
|
3
|
+
module EasyDataRouting
|
4
|
+
def self.routes(map)
|
5
|
+
map.connect "foaf/:model/:id.:format", :controller => "easy_datas",
|
6
|
+
:action => 'show',
|
7
|
+
:conditions => {:method => :get}
|
8
|
+
|
9
|
+
map.connect "list_models.:format", :controller => "easy_datas",
|
10
|
+
:action => 'describe_api'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- jnillo
|
@@ -15,13 +15,13 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-27 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
22
|
description: this is a gem description
|
23
23
|
email:
|
24
|
-
-
|
24
|
+
- jnillo@rubysemantic.com
|
25
25
|
executables:
|
26
26
|
- linked_data
|
27
27
|
extensions: []
|
@@ -33,18 +33,14 @@ files:
|
|
33
33
|
- Gemfile
|
34
34
|
- README
|
35
35
|
- Rakefile
|
36
|
-
- bin/.linked_data.swp
|
37
36
|
- bin/linked_data
|
38
|
-
-
|
39
|
-
- lib/controllers
|
40
|
-
- lib/controllers/linked_datas_controller.rb
|
37
|
+
- easy_data.gemspec
|
38
|
+
- lib/controllers/easy_datas_controller.rb
|
41
39
|
- lib/data_models/data_models.rb
|
42
|
-
- lib/
|
43
|
-
- lib/
|
44
|
-
- lib/
|
45
|
-
- lib/
|
46
|
-
- linked_data.gemspec
|
47
|
-
- setup.rb
|
40
|
+
- lib/easy_data.rb
|
41
|
+
- lib/easy_data/version.rb
|
42
|
+
- lib/routes.rb
|
43
|
+
- lib/tasks/testing_installation.rb
|
48
44
|
has_rdoc: true
|
49
45
|
homepage: http://rubygems.org/gem/easy_data
|
50
46
|
licenses: []
|
data/bin/.linked_data.swp
DELETED
Binary file
|
data/init.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#require 'lib/routing/route'
|
2
|
-
#require 'action_controller/routing'
|
3
|
-
|
4
|
-
#ActionController::Routing::RouteSet::Mapper.send :include,
|
5
|
-
# LinkedData::Routing::Routes::MapperExtensions
|
6
|
-
|
7
|
-
ActionController::Routing::Routes.draw do |map|
|
8
|
-
map.resource ":namespace/:model/:id.:format", :controller => "",
|
9
|
-
:action => "foaf",
|
10
|
-
:conditions => {:method => :get
|
11
|
-
:namespace => ["foaf","owl","doap"]
|
12
|
-
},
|
13
|
-
:only => [:show]
|
14
|
-
end
|
Binary file
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class LinkedDatasController < ApplicationController
|
2
|
-
def foaf
|
3
|
-
if params[:id]
|
4
|
-
@request = ActiveRecord::Base.connection.select_all()
|
5
|
-
else
|
6
|
-
@request = ActiveRecord::Base.connection.select_all()
|
7
|
-
end
|
8
|
-
|
9
|
-
render :template => "request_objects"
|
10
|
-
end
|
11
|
-
end
|
data/lib/linked_data/version.rb
DELETED
data/lib/views/.rdf.html.erb.swp
DELETED
Binary file
|
data/lib/views/rdf.html.erb
DELETED
data/setup.rb
DELETED
File without changes
|