portable 1.0.0.pre.alpha.4 → 1.0.0.pre.alpha.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79f24ff23c62ae9aa19e46c4f63d7db4a54edd80f4450c8b9042166d5823f3f4
4
- data.tar.gz: 4eb7d7ad21a4c51af23f2a915e5e7ff893fe7adfa37d320cb99b25f6adc2daf8
3
+ metadata.gz: 7b9fa7e8020098fb9dd2d9e2c9c984e0d71ff0aa02d4f568879bb013ae65b8d4
4
+ data.tar.gz: 1e01f15d35797f4954b5a4861b6a8d44e54f3571fc81cd73c5ff2c08ac8ef550
5
5
  SHA512:
6
- metadata.gz: ae92f80d1b767fd32256061db8efdad5dfe70d706f9b43076cc01b174af0c4a455b5a2101a8f2ed6002caa0353c89a414736b8d13e7973ba2fe767cea0db8689
7
- data.tar.gz: 9b16676405f572b58e90f1cb551620549a193215076d99f3505d1a1564e4bea68305385d68a5df56f9df782994b09b803ef4d87161713186c6f4dd8fd2b61f7c
6
+ metadata.gz: 97d59eb7d25b5ea806d908995f8978c8f711d280bd9c8b1e2dd0c09ca173f1c2fcf132f828e2218c17f3637fc6d92e8f7e12b827212ae404c153b2c5722cbbeb
7
+ data.tar.gz: 3878dc2b2f38b9de6cc90c6644e3913379cecefd21adef98b35adf9cbcce3bf0fae4832491de6f3a063477b2d64416778c55e4f0383820cdfc75970d0ece5152
@@ -17,6 +17,8 @@ module Portable
17
17
  include Uniqueness
18
18
  acts_as_hashable
19
19
 
20
+ DEFAULT_NAME = ''
21
+
20
22
  def initialize(data_sources: [])
21
23
  sources = Source.array(data_sources)
22
24
  @data_sources_by_name = pivot_by_name(sources)
@@ -26,8 +28,13 @@ module Portable
26
28
  freeze
27
29
  end
28
30
 
31
+ # Use exact name if possible, if not then use the "default" one (noted by a blank name).
32
+ # Fail hard if we cannot identify which data source to use. This should help prevent
33
+ # possible configuration issues (i.e. typos.)
29
34
  def data_source(name)
30
- data_sources_by_name.fetch(name.to_s, Source.new)
35
+ data_sources_by_name[name.to_s] ||
36
+ data_sources_by_name[DEFAULT_NAME] ||
37
+ raise(ArgumentError, "data source: '#{name}' cannot be found.")
31
38
  end
32
39
 
33
40
  private
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Portable
11
- VERSION = '1.0.0-alpha.4'
11
+ VERSION = '1.0.0-alpha.5'
12
12
  end
@@ -20,6 +20,14 @@ module Portable
20
20
 
21
21
  freeze
22
22
  end
23
+
24
+ private
25
+
26
+ def ensure_directory_exists(filename)
27
+ path = File.dirname(filename)
28
+
29
+ FileUtils.mkdir_p(path) unless File.exist?(path)
30
+ end
23
31
  end
24
32
  end
25
33
  end
@@ -67,12 +67,6 @@ module Portable
67
67
  sheet.footer_rows.each { |row| csv << row }
68
68
  end
69
69
 
70
- def ensure_directory_exists(filename)
71
- path = File.dirname(filename)
72
-
73
- FileUtils.mkdir_p(path) unless File.exist?(path)
74
- end
75
-
76
70
  def extrapolate_filenames(filename, count)
77
71
  dir = File.dirname(filename)
78
72
  ext = File.extname(filename)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.alpha.4
4
+ version: 1.0.0.pre.alpha.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio