ckan_cli 1.0.1 → 1.0.2

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
  SHA256:
3
- metadata.gz: e6e9e4fe9afdc7e11b96c179e7eefe16b7c19247d4d1f08b029965688528bdf6
4
- data.tar.gz: bd4ed9291ff176a1303f7ba30283070dd732ba30342347e60e25b856fdb33f16
3
+ metadata.gz: aae7a1a299b2acc616508accc17acfe671ccd039a1775e59982509f5df7a60d6
4
+ data.tar.gz: 635bd944a050cf905efc5f5368e43e6c83cc598e5a38e3813731dabd875a9424
5
5
  SHA512:
6
- metadata.gz: 5cb9bbe079a905983d59158537b87ccc49901efa3e63b8ef9ca66a910224eba9b9cc7d253b864af9bd14bf1e152f828cd78ab0351a8a63767c8a93c2216b2c0f
7
- data.tar.gz: 29f6dd5cf5a07bb95284dffe88529815544bb7fb95b0dc32b9ccf27542913bec7bd32307492060ead203b084fe4e49c0990be68f4591d26b72a106636dd2f4f3
6
+ metadata.gz: dcf056959aabfbc704a77afe4447202245efb63eaf17d44b81767a9325b90ec98dd6ccd8e6be6d43c23135f68594234398fa1be62ea34447b33b326e9daf84a5
7
+ data.tar.gz: 70c62017fe322b14df7fe7c98f43194799222b4acd2e22adf7f118f6c3aa1fe05b540091dd1cd8205f74cd78b4687d98e61b024ac8ef586becfb13fceb98f7c6
data/README.md CHANGED
@@ -34,6 +34,66 @@ To see help do
34
34
  $ ckancli.rb help
35
35
  ```
36
36
 
37
+ ## Commands and options
38
+
39
+ > All available commands and options are also described in command line help.
40
+
41
+ ### Basic usage
42
+
43
+ Mandatory options for CSV upload are:
44
+ - directory "-d". Local path to file/directory or URL to online resource (starting with http or https).
45
+ - global configuration "-c". Path to global configuration file. Path should be absolute or relative to directory option. See configuration section for more information.
46
+ - resource configuration "-r". Path to resource metadata file. Path should be absolute or relative to directory option. See configuration section for more information.
47
+
48
+ ```shell
49
+ $ ckancli.rb upload -d C:\my_csv_collection\ -c config.json -r resource.json
50
+ ```
51
+
52
+ ### Validation
53
+
54
+ To validate CSV resources before uploading, use validation schema option:
55
+ - validation schema "-v". Path to JSON validation schema file. Path should be absolute or relative to directory option. See configuration section for more information.
56
+
57
+ ```shell
58
+ $ ckancli.rb upload -d C:\my_csv_collection\ -c config.json -r resource.json -v schema.json
59
+ ```
60
+
61
+ ### Ignore file extensions
62
+
63
+ By default, CKAN CLI processes only CSV files. To process all files in direcotry, ignoring extension, use ignore extension option:
64
+ - ignore extension "-i". If set, all files in specified directory will be processed.
65
+
66
+ ```shell
67
+ $ ckancli.rb upload -d C:\my_csv_collection\ -c config.json -r resource.json -i
68
+ ```
69
+
70
+ ### Overwriting existing resources
71
+
72
+ By default, CKAN CLI will not overwrite resources if the same is found by resource identifier. To overwrite existing resource, use overwrite option:
73
+ - overwrite "-w". If set, existing resource will be overwritten.
74
+
75
+ ```shell
76
+ $ ckancli.rb upload -d C:\my_csv_collection\ -c config.json -r resource.json -w
77
+ ```
78
+
79
+ ### Updating modified date
80
+
81
+ To automatically set resources modified date in CKAN, use update modified option:
82
+ - update modified "-m". If set, resources metadata field "modified date" will be updated to current date.
83
+
84
+ ```shell
85
+ $ ckancli.rb upload -d C:\my_csv_collection\ -c config.json -r resource.json -m
86
+ ```
87
+
88
+ ### Updating package metadata
89
+
90
+ To also update package metadata, use dataset configuration option:
91
+ - package configuration "-p". Path to package metadata file. Path should be absolute or relative to directory option. See configuration section for more information.
92
+
93
+ ```shell
94
+ $ ckancli.rb upload -d C:\my_csv_collection\ -c config.json -r resource.json -p package.json
95
+ ```
96
+
37
97
  ## Configuration
38
98
 
39
99
  > Example files including schemas and configurations are located in 'example_files' directory.
@@ -66,7 +126,9 @@ Contains configuration for CKAN API and e-mail notifications (sections "email_se
66
126
 
67
127
  ### Resource configuration
68
128
 
69
- Contains configuration for resource metadata (parameters as specified in CKAN API guidelines). If resource name is not specified, file name will be used. If resource identifier is not specified, new resource will be created.
129
+ Contains configuration for resource metadata (parameters as specified in CKAN API guidelines). Specified parameters will be passed to CKAN API with resource file.
130
+ - If resource name is not specified, file name will be used.
131
+ - If resource identifier is not specified, new resource will be created.
70
132
 
71
133
  ```javascript
72
134
  {
@@ -114,6 +114,7 @@ module Ckancli
114
114
  :path => r,
115
115
  :valid => true,
116
116
  :summary => nil,
117
+ :error => nil,
117
118
  :log_file => File.open(File.join(@dir, "#{File.basename(r)}.log"), "w"),
118
119
  :log => nil
119
120
  }
@@ -217,8 +218,10 @@ module Ckancli
217
218
 
218
219
  if !exception.nil?
219
220
  res[:log].error msg, exception
221
+ res[:error] = msg
220
222
  elsif !msg.nil?
221
223
  res[:log].info msg
224
+ res[:error] = msg
222
225
  else
223
226
  res[:log].info "OK - Validation successfull"
224
227
  end
@@ -256,8 +259,11 @@ module Ckancli
256
259
  # attachments
257
260
  @resources.each do |res|
258
261
  msg = "#{msg}\r\n- #{File.basename(res[:path])}"
259
- if !res[:summary].nil?
260
- msg = "#{msg} (#{res[:summary][:errors].length} errors, #{res[:summary][:warnings].length} warnings)"
262
+ if !res[:error].nil?
263
+ msg = "#{msg} (#{res[:error]})"
264
+ has_errors = true
265
+ elsif !res[:summary].nil?
266
+ msg = "#{msg} (#{res[:summary][:errors].length} validation errors, #{res[:summary][:warnings].length} validation warnings)"
261
267
  if res[:summary][:errors].length > 0
262
268
  has_errors = true
263
269
  end
@@ -319,6 +325,7 @@ module Ckancli
319
325
 
320
326
  if !ok
321
327
  res[:log].error msg
328
+ res[:error] = msg
322
329
  else
323
330
  res[:log].info "OK - upload successfull"
324
331
  end
@@ -1,3 +1,3 @@
1
1
  module Ckancli
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ckan_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - datagovlv
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-19 00:00:00.000000000 Z
11
+ date: 2019-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-color