ckan 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ckan.rb +2 -1
- data/lib/ckan/model.rb +3 -2
- data/lib/ckan/package.rb +5 -5
- data/lib/ckan/version.rb +1 -1
- metadata +4 -18
data/lib/ckan.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module CKAN
|
2
|
-
API_BASE = "http://ckan.net/api/
|
2
|
+
API_BASE = "http://ckan.net/api/1/"
|
3
3
|
end
|
4
4
|
|
5
5
|
require 'open-uri'
|
6
6
|
require 'json'
|
7
7
|
require 'ckan/model'
|
8
|
+
require 'ckan/group'
|
8
9
|
require 'ckan/package'
|
9
10
|
require 'ckan/resource'
|
10
11
|
require 'ckan/version'
|
data/lib/ckan/model.rb
CHANGED
@@ -3,7 +3,7 @@ module CKAN
|
|
3
3
|
protected
|
4
4
|
|
5
5
|
def read_lazy_data
|
6
|
-
unless @lazy_data_read
|
6
|
+
unless @lazy_data_read
|
7
7
|
self.class.read_remote_json_data(self.class.site + "/" + self.id).
|
8
8
|
each do |name,value|
|
9
9
|
self.instance_variable_set("@"+name,value)
|
@@ -29,12 +29,13 @@ module CKAN
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.read_remote_json_data(address)
|
32
|
+
puts address
|
32
33
|
JSON.parse(open(address).read)
|
33
34
|
end
|
34
35
|
|
35
36
|
def self.lazy_reader(*names)
|
36
37
|
names.each do |name|
|
37
|
-
define_method(name) do
|
38
|
+
define_method(name) do
|
38
39
|
read_lazy_data
|
39
40
|
instance_variable_get("@" + name.to_s)
|
40
41
|
end
|
data/lib/ckan/package.rb
CHANGED
@@ -4,7 +4,8 @@ module CKAN
|
|
4
4
|
self.search = API_BASE + "search/package"
|
5
5
|
|
6
6
|
attr_reader :id
|
7
|
-
lazy_reader :name, :title, :url
|
7
|
+
lazy_reader :name, :title, :url, :version, :author, :author_email,
|
8
|
+
:maintainer, :maintainer_email, :license_id, :notes
|
8
9
|
|
9
10
|
def initialize(id)
|
10
11
|
@id = id
|
@@ -16,13 +17,12 @@ module CKAN
|
|
16
17
|
else
|
17
18
|
query = "?"
|
18
19
|
query += options.to_a.
|
19
|
-
map{|k,v| v.is_a?(Array) ? v.map{|vv| "#{k}=#{URI.encode(vv)}"}.join("&") :
|
20
|
+
map{|k,v| v.is_a?(Array) ? v.map{|vv| "#{k}=#{URI.encode(vv)}"}.join("&") :
|
20
21
|
"#{k}=#{URI.encode(v)}"}.join("&")
|
21
|
-
puts query
|
22
22
|
result = read_remote_json_data(self.search + query)
|
23
23
|
if result["count"] != result["results"].size
|
24
24
|
query += "&offset=#{result["results"].size}&limit=#{result["count"] + result["results"].size}"
|
25
|
-
result["results"] += read_remote_json_data(self.search + query)["results"]
|
25
|
+
result["results"] += read_remote_json_data(self.search + query)["results"]
|
26
26
|
end
|
27
27
|
|
28
28
|
result["results"].map{|id| Package.get(id)}
|
@@ -30,7 +30,7 @@ module CKAN
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def resources
|
33
|
-
read_lazy_data
|
33
|
+
read_lazy_data
|
34
34
|
@mapped_resources ||= @resources.
|
35
35
|
map{|r| Resource.new(r["url"],r["format"],r["description"],r["hash"])}
|
36
36
|
end
|
data/lib/ckan/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ckan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Aleksander Pohl
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-03-17 00:00:00 +01:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,10 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 0
|
31
|
-
- 0
|
32
24
|
version: 1.0.0
|
33
25
|
type: :development
|
34
26
|
version_requirements: *id001
|
@@ -67,23 +59,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
59
|
requirements:
|
68
60
|
- - ">="
|
69
61
|
- !ruby/object:Gem::Version
|
70
|
-
segments:
|
71
|
-
- 0
|
72
62
|
version: "0"
|
73
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
64
|
none: false
|
75
65
|
requirements:
|
76
66
|
- - ">="
|
77
67
|
- !ruby/object:Gem::Version
|
78
|
-
segments:
|
79
|
-
- 1
|
80
|
-
- 3
|
81
|
-
- 6
|
82
68
|
version: 1.3.6
|
83
69
|
requirements: []
|
84
70
|
|
85
71
|
rubyforge_project: ckan
|
86
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.5.2
|
87
73
|
signing_key:
|
88
74
|
specification_version: 3
|
89
75
|
summary: Ruby Client for Comprehensive Knowledge Archive Network
|