ckan 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +15 -0
- data/README.txt +9 -0
- data/changelog.txt +8 -0
- data/lib/ckan/group.rb +33 -0
- data/lib/ckan/model.rb +0 -1
- data/lib/ckan/version.rb +1 -1
- metadata +4 -1
data/Gemfile.lock
ADDED
data/README.txt
CHANGED
@@ -41,6 +41,15 @@ The gem is available at rubygems.org, so you can install it with:
|
|
41
41
|
# get the resources of the package
|
42
42
|
packages.first.resources
|
43
43
|
|
44
|
+
# query for CKAN groups
|
45
|
+
groups = CKAN::Group.find
|
46
|
+
|
47
|
+
# get the description of a group
|
48
|
+
groups.first.description
|
49
|
+
|
50
|
+
# get the list of packages inside a group
|
51
|
+
groups.first.packages
|
52
|
+
|
44
53
|
== LICENSE:
|
45
54
|
|
46
55
|
(The MIT License)
|
data/changelog.txt
ADDED
data/lib/ckan/group.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module CKAN
|
2
|
+
class Group < Model
|
3
|
+
self.site = API_BASE + "rest/group"
|
4
|
+
|
5
|
+
attr_reader :id, :name
|
6
|
+
lazy_reader :title, :description, :packages
|
7
|
+
|
8
|
+
def initialize(id)
|
9
|
+
@name = id
|
10
|
+
@id = id
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.find
|
14
|
+
@all_groups ||= read_remote_json_data(self.site).map{|id| Group.get(id)}
|
15
|
+
end
|
16
|
+
|
17
|
+
alias api_packages packages
|
18
|
+
protected :api_packages
|
19
|
+
|
20
|
+
def packages
|
21
|
+
@packages ||= self.api_packages.map{|p| Package.send(:get,p)}
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
def self.get(id)
|
26
|
+
@group_map ||= {}
|
27
|
+
unless @group_map[id]
|
28
|
+
@group_map[id] = Group.new(id)
|
29
|
+
end
|
30
|
+
@group_map[id]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/ckan/model.rb
CHANGED
data/lib/ckan/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ckan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Aleksander Pohl
|
@@ -36,10 +36,13 @@ extra_rdoc_files:
|
|
36
36
|
files:
|
37
37
|
- .gitignore
|
38
38
|
- Gemfile
|
39
|
+
- Gemfile.lock
|
39
40
|
- README.txt
|
40
41
|
- Rakefile
|
42
|
+
- changelog.txt
|
41
43
|
- ckan.gemspec
|
42
44
|
- lib/ckan.rb
|
45
|
+
- lib/ckan/group.rb
|
43
46
|
- lib/ckan/model.rb
|
44
47
|
- lib/ckan/package.rb
|
45
48
|
- lib/ckan/resource.rb
|