ckan 0.0.2 → 0.0.3

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.
@@ -0,0 +1,15 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ckan (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ bundler (>= 1.0.0)
15
+ ckan!
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)
@@ -0,0 +1,8 @@
1
+ 0.0.3
2
+ - Minor fix: 0.0.2 release has a missing group.rb file
3
+ 0.0.2
4
+ - Implementation of the group API
5
+ - (temporary) Uses 1.0 CKAN API
6
+ 0.0.1
7
+ - Initial implementation of the CKAN API for packages and resources
8
+ - Uses 2.0 CKAN API
@@ -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
@@ -29,7 +29,6 @@ module CKAN
29
29
  end
30
30
 
31
31
  def self.read_remote_json_data(address)
32
- puts address
33
32
  JSON.parse(open(address).read)
34
33
  end
35
34
 
@@ -1,3 +1,3 @@
1
1
  module CKAN
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ckan
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
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