odlifier 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 634ab239c836b776514d2c56b0c9c4efeead831f
4
+ data.tar.gz: bf11a97d0f6d6a5597cdc1d957b588e995291206
5
+ SHA512:
6
+ metadata.gz: d3ab4a4bfb98e9115fe1b1df484d9707f8edeb98e33768819ecc7358da71f659c00da85d296761e71f2e10fd6501b56f628d5429f92a3909114233dad27a89c1
7
+ data.tar.gz: e1cc676d743a1beaf54802391b8095c59788d5843e20dea41555063d71406076bb54f5a3f133ffc1384e5e936097db22588c2afef5fe35cc4d57d438692f7d18
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 The Open Data Institute
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ [![Build Status](http://img.shields.io/travis/theodi/odlifier.svg)](https://travis-ci.org/theodi/odlifier)
2
+ [![Dependency Status](http://img.shields.io/gemnasium/theodi/odlifier.svg)](https://gemnasium.com/theodi/odlifier)
3
+ [![Coverage Status](http://img.shields.io/coveralls/theodi/odlifier.svg)](https://coveralls.io/r/theodi/odlifier)
4
+ [![Code Climate](http://img.shields.io/codeclimate/github/theodi/odlifier.svg)](https://codeclimate.com/github/theodi/odlifier)
5
+ [![Gem Version](http://img.shields.io/gem/v/odlifier.svg)](https://rubygems.org/gems/odlifier)
6
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://theodi.mit-license.org)
7
+ [![Badges](http://img.shields.io/:badges-7/7-ff6799.svg)](https://github.com/pikesley/badger)
8
+
9
+ # ODLifier
10
+
11
+ Gets information on a license from the Open Knowledge Foundation's [Open Licenses Service](http://licenses.opendefinition.org/).
12
+
13
+ # Licence
14
+
15
+ This code is open source under the MIT license. See the LICENSE.md file for full details.
16
+
17
+ # Usage
18
+
19
+ Add the gem to your Gemfile:
20
+
21
+ gem 'odlifier'
22
+
23
+ Require if you need to:
24
+
25
+ require 'odlifier'
26
+
27
+ Request a licence
28
+
29
+ license = Odlifier::License.define("odc-by-1.0")
30
+
31
+ Use the results
32
+
33
+ license.domain_content
34
+ license.domain_data
35
+ license.domain_software
36
+ license.family
37
+ license.id
38
+ license.is_okd_compliant
39
+ license.is_osi_compliant
40
+ license.is_osi_compliant
41
+ license.status
42
+ license.title
43
+ license.url
44
+
45
+ # Contributing
46
+
47
+ 1. Fork it
48
+ 2. Create your feature branch (git checkout -b my-new-feature)
49
+ 3. Commit your changes (git commit -am 'Add some feature')
50
+ 4. Push to the branch (git push origin my-new-feature)
51
+ 5. Create new Pull Request
data/lib/odlifier.rb ADDED
@@ -0,0 +1,71 @@
1
+ require 'httparty'
2
+
3
+ module Odlifier
4
+ class License
5
+ include HTTParty
6
+
7
+ def initialize(hash)
8
+ hash.each do |key, val|
9
+ self.class.send(:define_method, key.to_sym) { val }
10
+ end
11
+ end
12
+
13
+ def self.define(id)
14
+ response = self.get("http://licenses.opendefinition.org/licenses/#{id.upcase}.json")
15
+ unless response.header.code == "404"
16
+ License.new(response.parsed_response)
17
+ else
18
+ # Try and get an ID with a version number
19
+ candidates = gather_candidiates(id)
20
+ if candidates.count == 0
21
+ raise ArgumentError, "License with the id '#{id}' cannot be found"
22
+ else
23
+ License.new(candidates.last) # Assume the latest version
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.gather_candidiates(id)
29
+ candidates = []
30
+ response = self.get("http://licenses.opendefinition.org/licenses/groups/all.json")
31
+ response.parsed_response.each do |key, val|
32
+ candidates << val if key.match /#{id}-[0-9]+\.[0-9]+/i
33
+ end
34
+ candidates
35
+ end
36
+
37
+ end
38
+
39
+ # List a load of content license IDs
40
+ def self.content_licenses
41
+ [
42
+ 'cc-by',
43
+ 'cc-by-sa',
44
+ 'cc-zero',
45
+ 'cc-nc',
46
+ 'fal',
47
+ 'odc-pddl',
48
+ 'odc-by',
49
+ 'odc-odbl',
50
+ 'other-pd',
51
+ 'uk-ogl',
52
+ ]
53
+ end
54
+
55
+ # Translate license IDs into English titles
56
+ def self.translate(license_id, default = nil)
57
+ {
58
+ 'cc-by' => 'Creative Commons Attribution',
59
+ 'cc-by-sa' => 'Creative Commons Attribution Share-Alike',
60
+ 'cc-zero' => 'Creative Commons CCZero',
61
+ 'cc-nc' => 'Creative Commons Non-Commercial',
62
+ 'fal' => 'Free Art License',
63
+ 'odc-pddl' => 'Open Data Commons Public Domain Dedication and Licence',
64
+ 'odc-by' => 'Open Data Commons Attribution License',
65
+ 'odc-odbl' => 'Open Data Commons Open Database License',
66
+ 'other-pd' => 'Public domain',
67
+ 'uk-ogl' => 'UK Open Government Licence',
68
+ }[license_id] || default
69
+ end
70
+
71
+ end
@@ -0,0 +1,3 @@
1
+ module Odlifier
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: odlifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stuart Harrison
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fakeweb
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email: tech@theodi.org
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - lib/odlifier/version.rb
104
+ - lib/odlifier.rb
105
+ - LICENSE.md
106
+ - README.md
107
+ homepage: http://github.com/odlifier
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.0.3
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Get information about an open licence using a simple identifier
131
+ test_files: []