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 CHANGED
@@ -2,3 +2,7 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ lib/task/testing_installation.rb
6
+ bin/linked_data
7
+ init.rb
8
+ setup.rb
data/README CHANGED
@@ -1,6 +1,31 @@
1
- This is a gem proyect.
1
+ Installation
2
+ ===============
2
3
 
3
- This gem auto-generate Linked data information about models in Ruby on
4
- Rails projects.
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 "linked_data/version"
3
+ require "easy_data/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "easy_data"
7
- s.version = LinkedData::VERSION
7
+ s.version = EasyData::VERSION
8
8
  s.authors = ["jnillo"]
9
- s.email = ["juan.vazquez@betybyte.com"]
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
@@ -0,0 +1,3 @@
1
+ module EasyData
2
+ VERSION = "0.0.2"
3
+ end
@@ -1,8 +1,11 @@
1
- require "linked_data/version"
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
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+
3
+ rm easy_data-0.0.1.gem
4
+ gem build easy_data.gemspec
5
+ gem uninstall easy_data
6
+ gem install ./easy_data-0.0.1.gem
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: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
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-26 00:00:00 +02:00
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
- - juan.vazquez@betybyte.com
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
- - init.rb
39
- - lib/controllers/.linked_datas_controller.rb.swp
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/linked_data.rb
43
- - lib/linked_data/version.rb
44
- - lib/views/.rdf.html.erb.swp
45
- - lib/views/rdf.html.erb
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
@@ -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
@@ -1,3 +0,0 @@
1
- module LinkedData
2
- VERSION = "0.0.1"
3
- end
Binary file
@@ -1,6 +0,0 @@
1
- <rdf:RDF
2
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
3
- <%= get_namespaces @namespaces -%>
4
- >
5
- <%= generate_rdf_request(@request,@namespaces) -%>
6
- </rdf:RDF>
data/setup.rb DELETED
File without changes