kataba 1.0.0 → 1.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/kataba.rb +34 -0
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd9fd6f5ee1170b5552d4345a4c23fab923efcaa
4
- data.tar.gz: e78ca648b702ecd40a576263eb6aaab7d4fd4d13
3
+ metadata.gz: 91cf7e773f0cead00236519792f3b0b6bf888fb8
4
+ data.tar.gz: 2033b27334cefc6ad872c7084759e60da09edc19
5
5
  SHA512:
6
- metadata.gz: 13ed9bbd4e28ee1e7e8e955f6ea9084b52e94da83458d395fb776a75b40094079e640bdb82c7424eca93dc27b1063968b3fb96791723d1a9d432a29837a18362
7
- data.tar.gz: 46f8e1813d56ecdd4cd689bd5ee2354d250861f1b627cd0812fed4ed36b4ccab8aa8313a779416e0ee69e12fb08c048c7f4bd109d2f626af1e20ac49c426ac5c
6
+ metadata.gz: 0c2cf4238e8b166b3646427aeeb40ca80107e8a5b08f80eea2e02a8906a2fdeb94121d3465333ad4bff29ac766a7ce90187f84af84c9c5876c5aa5b727449eff
7
+ data.tar.gz: 38a54143ba8b1ac21f7c5da6b1556bfc810f2a9d2ceaf8bf7ff391b09cddb42f2f7f677e26a7a532e8074eace7538170d52b6d9202330286a3e5355571aabac3
@@ -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.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: A simple gem that allows for the functionality that an XML catalog would
28
- provide
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: []