citysdk 0.1.2.5 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0fd4a218a56d9c50a060909e9d27308f7262b72
4
- data.tar.gz: dbcead5631b8cd87d3844d319e51843ec3b859c6
3
+ metadata.gz: 969313e0796217d8f9e3ec407c477a01b8a83e26
4
+ data.tar.gz: 4d06bd0a1e14fefdd92699b80733d35b7747f2aa
5
5
  SHA512:
6
- metadata.gz: 3c9c553e8e707ca27f07c12d57700c219471b60a5c1efeab62148f2912ab196cfd98739294143432cc6f63097d22beadeb5d10b0e5266e0ff91a56c8562327d1
7
- data.tar.gz: 1ffd5cd48feaabef893c68b558e6e6ace96a3a2de6cbed74d9ef8ab4a6c76c3424c466b207ab7760dffb7e0006c374d5da436939a8b516ba815ba2a1c1472dec
6
+ metadata.gz: da86200998e771230aecbcb3027af48ce77d23190898dfb9a1b9a57865e15221833c5b16d4cb038a2e10af2f9ca9e4235b9ceba61bcf7f44385ad6f6a5652a6d
7
+ data.tar.gz: fe3e3978db2a0f0eab25d9ee109873fcc56a81fa865a8cd1f203b46878aa05dbd7cf194a7184bf4c6cdc5e364176a9258c0682db339dac0244b50d573e78a344
data/.gitignore CHANGED
@@ -1 +1,34 @@
1
1
  *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/Gemfile.lock CHANGED
@@ -1,32 +1,38 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- citysdk (0.1.1.4)
5
- charlock_holmes (>= 0.6.9.4)
6
- dbf
7
- faraday (>= 0.8.5)
8
- georuby (>= 2.0.0)
4
+ citysdk (1.0)
5
+ charlock_holmes (~> 0.6)
6
+ curses (~> 1.0)
7
+ dbf (~> 2.0)
8
+ faraday (~> 0.8)
9
+ georuby (~> 2.0)
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
13
- charlock_holmes (0.6.9.4)
14
- dbf (2.0.6)
14
+ charlock_holmes (0.7.3)
15
+ curses (1.0.1)
16
+ dbf (2.0.7)
15
17
  fastercsv (~> 1.5.4)
16
- diff-lcs (1.2.4)
17
- faraday (0.8.7)
18
- multipart-post (~> 1.1)
18
+ diff-lcs (1.2.5)
19
+ faraday (0.9.0)
20
+ multipart-post (>= 1.2, < 3)
19
21
  fastercsv (1.5.5)
20
- georuby (2.0.0)
21
- multipart-post (1.2.0)
22
- rspec (2.14.0)
23
- rspec-core (~> 2.14.0)
24
- rspec-expectations (~> 2.14.0)
25
- rspec-mocks (~> 2.14.0)
26
- rspec-core (2.14.0)
27
- rspec-expectations (2.14.0)
28
- diff-lcs (>= 1.1.3, < 2.0)
29
- rspec-mocks (2.14.1)
22
+ georuby (2.2.1)
23
+ multipart-post (2.0.0)
24
+ rspec (3.0.0)
25
+ rspec-core (~> 3.0.0)
26
+ rspec-expectations (~> 3.0.0)
27
+ rspec-mocks (~> 3.0.0)
28
+ rspec-core (3.0.2)
29
+ rspec-support (~> 3.0.0)
30
+ rspec-expectations (3.0.2)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.0.0)
33
+ rspec-mocks (3.0.2)
34
+ rspec-support (~> 3.0.0)
35
+ rspec-support (3.0.2)
30
36
 
31
37
  PLATFORMS
32
38
  ruby
@@ -36,4 +42,4 @@ DEPENDENCIES
36
42
  citysdk!
37
43
  faraday
38
44
  georuby
39
- rspec
45
+ rspec (~> 3.0)
data/README.md CHANGED
@@ -1,47 +1,69 @@
1
- # Citysdk
1
+ # CitySDK GEM
2
2
 
3
- The CitySDK gem encapulates the CItySDK API, and offers high-level file import functionalities.
4
- The CitySDK API is part of an (open)data distribution platform developed in the EU CitySDK program by [Waag Society](http://waag.org).
5
- Find the platform itself on [github](https://github.com/waagsociety/citysdk), platform documentation is [here](http://dev.citysdk.waag.org).
3
+ The CitySDK gem encapulates the CitySDK LD-API, and offers high-level file import functionalities.
4
+ The CitySDK LD-API is part of an (open)data distribution platform developed in the EU CitySDK program by [Waag Society](http://waag.org).
5
+ Find the platform itself on [github](https://github.com/waagsociety/citysdk-ld), background is [here](http://dev.citysdk.waag.org).
6
+
7
+ In order to best get an overview of the way to use the GEM to import files into the CitySDK LD-API, have a look at the 'admr' importer for the top-level administrative regions in the Netherlands.
8
+ The data consists of three ESRI shape files; the importer is well commented, explaining most of the possibilities of the GEM.
9
+ Please download the importer [here](https://github.com/waagsociety/citysdk-amsterdam/tree/master/importers/admr)
10
+
11
+ ## Installation
12
+
13
+ To install it just install the gem:
14
+
15
+ gem install citysdk
16
+
17
+ If you're using Bundler, add the gem to Gemfile.
18
+
19
+ gem 'citysdk'
20
+
21
+ Then run `bundle install`.
6
22
 
7
23
 
8
24
  ## Usage
25
+ The GEM can be used on two different levels, either simply as a wrapper around the API, or as a means to read, convert and import various types of data files.
26
+ The gem exposes it's functionality through three different objects:
27
+
28
+ - CitySDK::API
29
+ - CitySDK::FileReader
30
+ - CitySDK::Importer
31
+
32
+ The FileReader can be used stand-alone to read, edit and save data files, the Importer builds on the FileReader and API objects.
33
+
34
+ The FileReader has support for CSV, Shape and (Geo)Json files. XML is currently not supported; we recommend [OpenRefine](https://github.com/OpenRefine/OpenRefine/wiki/Downloads) to convert these to either CSV or JSON.
35
+
36
+
37
+ ### CitySDK::API Usage
38
+
9
39
 
10
- require 'citysdk'
11
-
12
- # check the dev site for api usage.
40
+ CALL | Description
41
+ |:-------------------------------------|:-------------------------------------------------------
42
+ `@api = CitySDK::API.new('<endpoint IP>')` | Establish a link to the particular endpoint
43
+ `@api.authenticate('<name>','<password>')` | For reading this is not necessary, for writing and deleting you need to authenticate. The authentication times out if not used (is reset by writing to the API). This call takes an optional block for immediate automatic release when the block has been called.
44
+ `@api.get path` | Simply issue a 'GET' against the API; the results are returned as a ruby Hash.
45
+ `@api.put path,data` | PUT a resource; see [Documentation](https://github.com/waagsociety/citysdk-ld/wiki/Objects)
46
+ `@api.post path,data` | POST a resource; see [Documentation](https://github.com/waagsociety/citysdk-ld/wiki/Objects)
47
+ `@api.patch path,data` | PATCH a resource; see [Documentation](https://github.com/waagsociety/citysdk-ld/wiki/Objects)
48
+ `@api.delete path` | Issue a DELETE to the API; path points to the resource to delete. Requires authentication.
49
+ `@api.release` | This call will flush any buffered object that were scheduled to be created or updated. See also batch_size, below.
50
+ `@api.set_layer(layername)` | Set the the layer for subsequent 'create_object' calls. User must be authenticate for this layer in order to sucesfully create objects.
51
+ `@api.create_object(objhash)` | Adds an object to the database. See also batch_size, below.
52
+ `@api.layers` | Shortcut for `get '/layers'`
53
+ `@api.owners` | Shortcut for `get '/owners'`
54
+ `@api.objects(layer=nil)` | Shortcut for `get '/objects'`. When a layer name is supplied, returns only objects from with data on this layer, and the layerdata itself.
55
+ `@api.next` | When more results are available, returns the next page.
56
+ `@api.format = <format>` | Specify the output format. Currently supported are (Geo)JSON and (Geo)JSON-LD.
57
+ `@api.page_size = <page_size>` | Specify the number of features returned; default is 25.
58
+ `@api.batch_size = <n>` | When adding objects thorugh 'create_object', they are buffered until '<n>' objects are available, then a single call is issuesd to the API.
59
+ `@api.last_result` | Returns a Hash with the last HTTP status and the headers returned from the last call.
13
60
 
14
- api = CitySDK::API.new('api.citysdk.waag.org')
15
61
 
16
- # simple GET
17
- # GET requests do not need authentication
18
- first10layers = api.get('/layers')
19
- puts "Number of layers: #{first10layers[:record_count]}"
20
- puts "First layer: #{JSON.pretty_generate(first10layers[:results][0])}"
21
-
22
62
 
23
- # authenticate for write actions.
24
- exit if not api.authenticate(<email>,<passw>)
25
63
 
26
- # make a layer
27
- # when you own the 'my' top level layer domain:
28
- @api.put('/layers',{:data => {
29
- :name => 'my.layer',
30
- :description => 'for testing',
31
- :organization => 'me',
32
- :category => 'civic.test'
33
- }})
34
64
 
35
- # add data to this layer
36
- # attach to the node representing the city of Rotterdam
37
- api.put('/admr.nl.rotterdam/my.layer', {:data => {:key1=>'value1', :key2=>10}})
38
65
 
39
66
 
40
- ...
41
-
42
- # don't forget to release! this will also send 'unfilled' batches to the backend.
43
- api.release
44
-
45
67
 
46
68
  ## Contributing
47
69
 
@@ -49,4 +71,4 @@ Find the platform itself on [github](https://github.com/waagsociety/citysdk), pl
49
71
  2. Create your feature branch (`git checkout -b my-new-feature`)
50
72
  3. Commit your changes (`git commit -am 'Add some feature'`)
51
73
  4. Push to the branch (`git push origin my-new-feature`)
52
- 5. Create new Pull Request
74
+ 5. Create new Pull Request