locabulary 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/lib/locabulary.rb +11 -5
- data/locabulary.gemspec +2 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 489247339c648342440e9d1b9d88fd097cbb6d68
|
4
|
+
data.tar.gz: b272886c9ecfb23e4bf40a1c8d88bc6609e3f218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3777f6533b600f54c925ecf54e779e7427da9848b6e33dfb380ee91d7a9d2c80c76bd27bd5e8687524c2d7b48396cd6c933a8d9b9475c93675cb3d848cc1e84e
|
7
|
+
data.tar.gz: ebb02ec68abda37e2db01e350946420d344b8a3a4fba905f8ac4aad986f8968989f72521d9aee9e442634b66d03557b291b95eaf1d6a20607c36f34311641991
|
data/.travis.yml
CHANGED
data/lib/locabulary.rb
CHANGED
@@ -3,7 +3,7 @@ require 'json'
|
|
3
3
|
|
4
4
|
# @since 0.1.0
|
5
5
|
module Locabulary
|
6
|
-
VERSION='0.1.
|
6
|
+
VERSION='0.1.1'.freeze
|
7
7
|
DATA_DIRECTORY = File.expand_path("../../data/", __FILE__).freeze
|
8
8
|
|
9
9
|
class RuntimeError < ::RuntimeError
|
@@ -42,7 +42,9 @@ module Locabulary
|
|
42
42
|
# low churn rate. And while the date is important, I'm not as concerned
|
43
43
|
# about the local controlled vocabulary exposing a date that has expired.
|
44
44
|
# When we next deploy the server changes, the deactivated will go away.
|
45
|
-
def active_items_for(
|
45
|
+
def active_items_for(options = {})
|
46
|
+
predicate_name = options.fetch(:predicate_name)
|
47
|
+
as_of = options.fetch(:as_of) { Date.today }
|
46
48
|
active_cache[predicate_name] ||= begin
|
47
49
|
filename = filename_for_predicate_name(predicate_name: predicate_name)
|
48
50
|
JSON.parse(File.read(filename)).each_with_object([]) do |item_values, mem|
|
@@ -63,7 +65,9 @@ module Locabulary
|
|
63
65
|
|
64
66
|
# @api public
|
65
67
|
# @since 0.1.0
|
66
|
-
def active_label_for_uri(
|
68
|
+
def active_label_for_uri(options = {})
|
69
|
+
predicate_name = options.fetch(:predicate_name)
|
70
|
+
term_uri = options.fetch(:term_uri)
|
67
71
|
object = active_items_for(predicate_name: predicate_name).detect { |obj| obj.term_uri == term_uri }
|
68
72
|
return object.term_label if object
|
69
73
|
term_uri
|
@@ -71,12 +75,14 @@ module Locabulary
|
|
71
75
|
|
72
76
|
# @api public
|
73
77
|
# @since 0.1.0
|
74
|
-
def active_labels_for(
|
78
|
+
def active_labels_for(options = {})
|
79
|
+
predicate_name = options.fetch(:predicate_name)
|
75
80
|
active_items_for(predicate_name: predicate_name).map(&:term_label)
|
76
81
|
end
|
77
82
|
|
78
83
|
# @api private
|
79
|
-
def filename_for_predicate_name(
|
84
|
+
def filename_for_predicate_name(options = {})
|
85
|
+
predicate_name = options.fetch(:predicate_name)
|
80
86
|
filename = File.join(DATA_DIRECTORY, "#{File.basename(predicate_name)}.json")
|
81
87
|
return filename if File.exist?(filename)
|
82
88
|
raise Locabulary::RuntimeError, "Unable to find predicate_name: #{predicate_name}"
|
data/locabulary.gemspec
CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "minitest"
|
22
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
24
|
spec.add_dependency "json", "~> 1.8"
|
24
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locabulary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
@@ -14,16 +14,30 @@ dependencies:
|
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
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
|
+
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|