adiwg-mdcodes 0.2.0 → 0.2.1

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: 882a4a567e9fc193221bb5dc67e9b09e25afeb26
4
- data.tar.gz: f71051a650b8024d366b5c5babd35c70bd9dfca0
3
+ metadata.gz: 27148550d8503791cdf58ffb8cd0e012a1a23fb7
4
+ data.tar.gz: 9ce920947a7ec0284261dab3815a6bd4176a06f1
5
5
  SHA512:
6
- metadata.gz: 45b87e8aff5350e4a2a8da3aa4f1e328e8a4b6b917565f8f06d42b10071e86d9bea218b847af44c8b28c0715de6624b2acf6c19d57b669d063d44f75673b082c
7
- data.tar.gz: e2b73efc0bb18a9bcc538ec83e9c82275d3261033080e2806cdae471b55c7437438d3efef7ee99a0392bf0ab1d86de3c411c7c5dc4081e4358a6e92e20497ad4
6
+ metadata.gz: ab38525674af2337f43c43064460c2c07079a02cc032b4a90aff8d570946f367d7040ff5d9492a4f5ea9b352e9ba863d28ebab7b564d504f4a8424bd81c17efb
7
+ data.tar.gz: fc87fdc70f80994986fd2e8afb8089dfd9c818007bda3b7e2a504ea87c8fb28c48d5691c203b2ff3d0be2b8e5f49a9a72c0b88288c5ebdc7372d9e494dad5306
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
+ /.project
2
+ /resources/json/mdcodes.json
1
3
  *.gem
2
4
  *.rbc
3
5
  .bundle
@@ -22,3 +24,4 @@ tmp
22
24
  *.o
23
25
  *.a
24
26
  mkmf.log
27
+ node_modules
data/Gruntfile.js ADDED
@@ -0,0 +1,32 @@
1
+ module.exports = function(grunt) {
2
+
3
+ // Project configuration.
4
+ grunt.initConfig({
5
+ // This line makes your node configurations available for use
6
+ pkg: grunt.file.readJSON('package.json'),
7
+ convert: {
8
+ yml2json: {
9
+ files: [{
10
+ expand: true,
11
+ cwd: 'resources/',
12
+ src: ['**/*.yml'],
13
+ dest: 'resources/json/',
14
+ ext: '.json'
15
+ }]
16
+ }
17
+ },
18
+
19
+ yamllint: {
20
+ all: ['resources/**/*.yaml']
21
+ }
22
+ });
23
+ // Each plugin must be loaded following this pattern
24
+ grunt.loadNpmTasks('grunt-convert');
25
+ grunt.loadNpmTasks('grunt-yamllint');
26
+ // Custom task(s).
27
+ // First argument names the task for use in command line
28
+ // Second argument is a list of tasks to be run
29
+ grunt.registerTask('default', ['yamllint:all', 'convert:yml2json']);
30
+ grunt.registerTask('lint', ['yamllint:all']);
31
+
32
+ };
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  [![Build Status](https://travis-ci.org/adiwg/mdCodes.svg)](https://travis-ci.org/adiwg/mdCodes)
2
+ [![Gem Version](https://badge.fury.io/rb/adiwg-mdcodes.svg)](http://badge.fury.io/rb/adiwg-mdcodes)
2
3
 
3
4
  # Mdcodes
4
5
 
5
- adiwg-mdcodes provides code lists in JSON formats for loading of mdEditor or other metadata
6
- editors using adiwg-json-schema. The codes include all ISO 19115-2 and ISO 19115-1 codes plus
7
- additional codes from NGDC and ADIwg.
6
+ adiwg-mdcodes provides code lists in hash or JSON formats for loading of mdEditor and other metadata
7
+ tools that use the adiwg-json-schema. The code lists include all ISO 19115-2 and ISO 19115-1 codes plus
8
+ supplemental codes added NGDC and ADIwg.
8
9
 
9
10
  ## Installation
10
11
 
@@ -20,13 +21,34 @@ Or install it yourself as:
20
21
 
21
22
  $ gem install adiwg-mdcodes
22
23
 
23
- ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ## Methods
26
+
27
+ ### getYamlPath
28
+ > returns the path to the YAML file of code lists.
29
+
30
+ ### getCodeLists( returnFormat )
31
+ > returns all code lists with all code list data
32
+ > returnFormat = \[__hash__ | json] (string)
33
+
34
+ ### getCodeList( codeListName, returnFormat )
35
+ > returns a single code list with all code list data
36
+ > codeListName = name of code list to return (string)
37
+ > returnFormat = \[ __hash__ | json ] (string)
38
+
39
+ ### getCodeNames( returnFormat )
40
+ > returns all code lists with only the code list item names
41
+ > returnFormat = \[__hash__ | json] (string)
42
+
43
+ ### getCodeName( codeListName, returnFormat )
44
+ > returns a single code list with only the code list item names
45
+ > codeListName = name of code list to return (string)
46
+ > returnFormat = \[__hash__ | json] (string)
47
+
26
48
 
27
49
  ## Contributing
28
50
 
29
- 1. Fork it ( https://github.com/[my-github-username]/mdCodes/fork )
51
+ 1. Fork it (https://github.com/adiwg/mdCodes/fork)
30
52
  2. Create your feature branch (`git checkout -b my-new-feature`)
31
53
  3. Commit your changes (`git commit -am 'Add some feature'`)
32
54
  4. Push to the branch (`git push origin my-new-feature`)
@@ -23,4 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake", "~>10"
24
24
  spec.add_development_dependency "minitest", "~>5"
25
25
 
26
+ spec.add_runtime_dependency "json", "~>1.8"
27
+
26
28
  end
data/lib/adiwg/mdcodes.rb CHANGED
@@ -6,10 +6,13 @@
6
6
  # Stan Smith 2014-11-07 original script
7
7
  # Stan Smith 2014-11-07 add methods to return only codeNames
8
8
  # Josh Bradley 2014-11-07 moved resources directory outside lib, add getYamlPath
9
+ # Stan Smith 2014-11-10 added support for JSON returns
10
+ # Stan Smith 2014-11-10 added README.md text
9
11
 
10
12
  # add main directories to load_path
11
13
 
12
14
  require 'yaml'
15
+ require 'json'
13
16
 
14
17
  module ADIWG
15
18
 
@@ -20,21 +23,30 @@ module ADIWG
20
23
  end
21
24
 
22
25
  # read the yml file into ruby
23
- def self.getCodeLists
26
+ def self.getCodeLists(format='hash')
24
27
  file = getYamlPath
25
- return YAML.load_file(file)
28
+ codes = YAML.load_file(file)
29
+ if format == 'json'
30
+ return codes.to_json
31
+ else
32
+ return codes
33
+ end
26
34
  end
27
35
 
28
36
  # return a single code list
29
- def self.getCodeList(codeList)
37
+ def self.getCodeList(codeList, format='hash')
30
38
  codeLists = getCodeLists
31
39
  hCodeList = {}
32
40
  hCodeList[codeList] = codeLists[codeList]
33
- return hCodeList
41
+ if format == 'json'
42
+ return hCodeList.to_json
43
+ else
44
+ return hCodeList
45
+ end
34
46
  end
35
47
 
36
48
  # return only code names
37
- def self.getCodeNames
49
+ def self.getCodeNames(format='hash')
38
50
  codeLists = getCodeLists
39
51
  hCodeNames = {}
40
52
  codeLists.each do |key, value|
@@ -44,12 +56,16 @@ module ADIWG
44
56
  aList << item['codeName']
45
57
  end
46
58
  hCodeNames[key] = aList
47
- end
48
- return hCodeNames
59
+ end
60
+ if format == 'json'
61
+ return hCodeNames.to_json
62
+ else
63
+ return hCodeNames
64
+ end
49
65
  end
50
66
 
51
67
  # return a single code name list
52
- def self.getCodeName(codeList)
68
+ def self.getCodeName(codeList, format='hash')
53
69
  hCodeList = getCodeList(codeList)
54
70
  hCodeNames = {}
55
71
  aItems = hCodeList[codeList]['items']
@@ -58,7 +74,11 @@ module ADIWG
58
74
  aList << item['codeName']
59
75
  end
60
76
  hCodeNames[codeList] = aList
61
- return hCodeNames
77
+ if format == 'json'
78
+ return hCodeNames.to_json
79
+ else
80
+ return hCodeNames
81
+ end
62
82
  end
63
83
 
64
84
  end
@@ -6,11 +6,12 @@
6
6
  # 0.1.1 2014-11-06 added factSheet to scope
7
7
  # 0.2.0 2014-11-07 add option to return only codeNames
8
8
  # ... moved resources directory outside of lib
9
+ # 0.2.1 2014-11-10 added support for JSON returns
9
10
 
10
11
  module ADIWG
11
12
 
12
13
  module Mdcodes
13
- VERSION = "0.2.0"
14
+ VERSION = "0.2.1"
14
15
  end
15
16
 
16
17
  end
data/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "mdCodes",
3
+ "version": "0.2.1",
4
+ "description": "CodeLists for ADIwg mdJSON",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/adiwg/mdCodes.git"
8
+ },
9
+ "keywords": [
10
+ "metadata",
11
+ "adiwg",
12
+ "json"
13
+ ],
14
+ "author": "https://github.com/stansmith907, https://github.com/jlblcc",
15
+ "license": "UNLICENSE",
16
+ "bugs": {
17
+ "url": "https://github.com/adiwg/mdCodes/issues"
18
+ },
19
+ "homepage": "https://github.com/adiwg/mdCodes",
20
+ "devDependencies": {
21
+ "grunt": "^0.4.5",
22
+ "grunt-convert": "^0.1.11",
23
+ "grunt-yamllint": "^0.2.0"
24
+ }
25
+ }
@@ -1,8 +1,7 @@
1
-
1
+ ---
2
2
  # adiwgJson codelists
3
3
  # compiled from ISO 19115-2, 19115-1, NGDC, and ADIwg
4
4
 
5
- ---
6
5
  associationType:
7
6
  isoName: "DS_AssociationTypeCode"
8
7
  description: "justification for the correlation of two resources (datasets or projects)"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adiwg-mdcodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - stansmith907
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-08 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
55
69
  description: adiwg-mdcodes provides code lists for use in ISO 19139 compliant metadata,
56
70
  especially mdJSON. The codes include all ISO 19115-2 and ISO 19115-1 codes plus
57
71
  additional codes from NGDC and ADIwg.
@@ -64,6 +78,7 @@ files:
64
78
  - .gitignore
65
79
  - .travis.yml
66
80
  - Gemfile
81
+ - Gruntfile.js
67
82
  - LICENSE.txt
68
83
  - README.md
69
84
  - Rakefile
@@ -71,6 +86,7 @@ files:
71
86
  - lib/adiwg-mdcodes.rb
72
87
  - lib/adiwg/mdcodes.rb
73
88
  - lib/adiwg/mdcodes/version.rb
89
+ - package.json
74
90
  - resources/mdcodes.yml
75
91
  - test/dev.rb
76
92
  - test/tc_mdcodes.rb
@@ -101,4 +117,3 @@ summary: adiwg-mdcodes provides code lists for mdJSON.
101
117
  test_files:
102
118
  - test/dev.rb
103
119
  - test/tc_mdcodes.rb
104
- has_rdoc: