kataba 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kataba.rb +34 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91cf7e773f0cead00236519792f3b0b6bf888fb8
|
4
|
+
data.tar.gz: 2033b27334cefc6ad872c7084759e60da09edc19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c2cf4238e8b166b3646427aeeb40ca80107e8a5b08f80eea2e02a8906a2fdeb94121d3465333ad4bff29ac766a7ce90187f84af84c9c5876c5aa5b727449eff
|
7
|
+
data.tar.gz: 38a54143ba8b1ac21f7c5da6b1556bfc810f2a9d2ceaf8bf7ff391b09cddb42f2f7f677e26a7a532e8074eace7538170d52b6d9202330286a3e5355571aabac3
|
data/lib/kataba.rb
CHANGED
@@ -6,9 +6,17 @@ require 'open-uri'
|
|
6
6
|
module Kataba
|
7
7
|
|
8
8
|
class << self
|
9
|
+
# Simple attribute for configuration
|
9
10
|
attr_accessor :configuration
|
10
11
|
end
|
11
12
|
|
13
|
+
# Allows for configuration by block
|
14
|
+
#
|
15
|
+
# Example:
|
16
|
+
# MegaLotto.configure do |config|
|
17
|
+
# config.drawing_count = 10
|
18
|
+
# end
|
19
|
+
|
12
20
|
def self.configure
|
13
21
|
yield(configuration) if block_given?
|
14
22
|
end
|
@@ -17,19 +25,45 @@ module Kataba
|
|
17
25
|
@configuration ||= Configuration.new
|
18
26
|
end
|
19
27
|
|
28
|
+
# Undoes any configuration - this method was built for testing purposes
|
29
|
+
#
|
30
|
+
# Example:
|
31
|
+
# Kataba.reset
|
32
|
+
|
20
33
|
def self.reset
|
21
34
|
@configuration = Configuration.new
|
22
35
|
end
|
23
36
|
|
24
37
|
class Configuration
|
38
|
+
# Offline storage is "#{Dir.tmpdir}/kataba" by default.
|
39
|
+
# This attribute allows the user to change that default value.
|
40
|
+
#
|
41
|
+
# Example:
|
42
|
+
# Kataba.configuration.offline_storage = "/tmp/kataba"
|
25
43
|
attr_accessor :offline_storage
|
44
|
+
# The user can optionally provide a mirror list to reduce stress on primary XSD providers.
|
45
|
+
# This attribute allows the user to configure Kataba to use a YAML file with key/value pairs of
|
46
|
+
# original/mirror values. Sample YAML file can be found at https://github.com/dgcliff/kataba/blob/master/test/fixtures/mirror.yml
|
47
|
+
#
|
48
|
+
# Example:
|
49
|
+
# Kataba.configuration.mirror_list = File.join(Rails.root, 'config', 'mirror.yml')
|
26
50
|
attr_accessor :mirror_list
|
27
51
|
|
52
|
+
# Default configuration values
|
28
53
|
def initialize
|
29
54
|
@offline_storage = "#{Dir.tmpdir}/kataba"
|
30
55
|
end
|
31
56
|
end
|
32
57
|
|
58
|
+
# If already downloaded, uses offline version. If not, downloads from the URI provided.
|
59
|
+
# If mirror list is configured, searches for mirrored URI instead.
|
60
|
+
#
|
61
|
+
# Example:
|
62
|
+
# Kataba.fetch_schema("http://www.loc.gov/standards/mods/v3/mods-3-5.xsd")
|
63
|
+
#
|
64
|
+
# Arguments:
|
65
|
+
# xsd_uri: (String)
|
66
|
+
|
33
67
|
def self.fetch_schema(xsd_uri)
|
34
68
|
uri_md5 = Digest::MD5.hexdigest(xsd_uri)
|
35
69
|
dir_path = "#{self.configuration.offline_storage}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kataba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cliff
|
@@ -24,8 +24,8 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
-
description:
|
28
|
-
|
27
|
+
description: Kataba allows for mirroring and offline storage of XSD files, to enhance
|
28
|
+
Nokogiri
|
29
29
|
email: d.cliff@northeastern.edu
|
30
30
|
executables: []
|
31
31
|
extensions: []
|