facterdb 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/facterdb.rb CHANGED
@@ -5,7 +5,7 @@ module FacterDB
5
5
 
6
6
  # @return [String] - returns a giant incomprehensible string of concatenated json data
7
7
  def self.database
8
- @database ||= "[#{facterdb_fact_files.map { |f| File.read(f) }.join(',')}]\n"
8
+ @database ||= "[#{facterdb_fact_files.map { |f| read_json_file(f) }.join(',')}]\n"
9
9
  end
10
10
 
11
11
  # @return [Boolean] - returns true if we should use the default facterdb database, false otherwise
@@ -15,6 +15,25 @@ module FacterDB
15
15
  ENV['FACTERDB_SKIP_DEFAULTDB'].nil?
16
16
  end
17
17
 
18
+ # @return [Boolean] - returns true if we should inject the source file name and file path into the json factsets.
19
+ # The default is false.
20
+ def self.inject_source?
21
+ !ENV['FACTERDB_INJECT_SOURCE'].nil?
22
+ end
23
+
24
+ def self.read_json_file(f)
25
+ content = File.read(f)
26
+ return content unless inject_source?
27
+ # Find the opening brace
28
+ first_brace = content.index('{')
29
+ return content if first_brace.nil?
30
+ # Inject source file information
31
+ json_injection = "\"_facterdb_filename\": #{File.basename(f).to_json}, "
32
+ json_injection += "\"_facterdb_path\": #{File.expand_path(f).to_json}, "
33
+ content.insert(first_brace + 1, json_injection)
34
+ end
35
+ private_class_method :read_json_file
36
+
18
37
  # @return [Array[String]] - list of all files found in the default facterdb facts path
19
38
  def self.default_fact_files
20
39
  return [] unless use_defaultdb?
@@ -1,5 +1,5 @@
1
1
  module FacterDB
2
2
  module Version
3
- STRING = '0.5.1'
3
+ STRING = '0.5.2'
4
4
  end
5
5
  end
@@ -5,7 +5,6 @@ describe 'FacterDB' do
5
5
  describe 'database' do
6
6
 
7
7
  before(:each) do
8
- stub_const("File::PATH_SEPARATOR", ":")
9
8
  ENV['FACTERDB_SKIP_DEFAULTDB'] = nil
10
9
  FacterDB.instance_variable_set(:@database, nil)
11
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facterdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mickaël Canévet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-06 00:00:00.000000000 Z
11
+ date: 2018-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -123,6 +123,7 @@ extensions: []
123
123
  extra_rdoc_files: []
124
124
  files:
125
125
  - ".gitignore"
126
+ - ".gitmodules"
126
127
  - ".travis.yml"
127
128
  - CHANGELOG.md
128
129
  - Gemfile
@@ -205,6 +206,7 @@ files:
205
206
  - facts/1.6/ubuntu-15.10-x86_64.facts
206
207
  - facts/1.6/ubuntu-16.04-i386.facts
207
208
  - facts/1.6/ubuntu-16.04-x86_64.facts
209
+ - facts/1.6/ubuntu-18.04-x86_64.facts
208
210
  - facts/1.7/amazon-2017-x86_64.facts
209
211
  - facts/1.7/archlinux-i386.facts
210
212
  - facts/1.7/archlinux-x86_64.facts
@@ -278,6 +280,7 @@ files:
278
280
  - facts/1.7/ubuntu-15.10-x86_64.facts
279
281
  - facts/1.7/ubuntu-16.04-i386.facts
280
282
  - facts/1.7/ubuntu-16.04-x86_64.facts
283
+ - facts/1.7/ubuntu-18.04-x86_64.facts
281
284
  - facts/2.0/amazon-2017-x86_64.facts
282
285
  - facts/2.0/archlinux-i386.facts
283
286
  - facts/2.0/archlinux-x86_64.facts
@@ -366,6 +369,7 @@ files:
366
369
  - facts/2.0/ubuntu-15.10-x86_64.facts
367
370
  - facts/2.0/ubuntu-16.04-i386.facts
368
371
  - facts/2.0/ubuntu-16.04-x86_64.facts
372
+ - facts/2.0/ubuntu-18.04-x86_64.facts
369
373
  - facts/2.1/amazon-2017-x86_64.facts
370
374
  - facts/2.1/archlinux-i386.facts
371
375
  - facts/2.1/archlinux-x86_64.facts
@@ -454,6 +458,7 @@ files:
454
458
  - facts/2.1/ubuntu-15.10-x86_64.facts
455
459
  - facts/2.1/ubuntu-16.04-i386.facts
456
460
  - facts/2.1/ubuntu-16.04-x86_64.facts
461
+ - facts/2.1/ubuntu-18.04-x86_64.facts
457
462
  - facts/2.1/windows-10-i386.facts
458
463
  - facts/2.1/windows-10-x86_64.facts
459
464
  - facts/2.1/windows-2008 r2-x86_64.facts
@@ -552,6 +557,7 @@ files:
552
557
  - facts/2.2/ubuntu-15.10-x86_64.facts
553
558
  - facts/2.2/ubuntu-16.04-i386.facts
554
559
  - facts/2.2/ubuntu-16.04-x86_64.facts
560
+ - facts/2.2/ubuntu-18.04-x86_64.facts
555
561
  - facts/2.2/windows-10-i386.facts
556
562
  - facts/2.2/windows-10-x86_64.facts
557
563
  - facts/2.2/windows-2008 r2-x86_64.facts
@@ -650,6 +656,7 @@ files:
650
656
  - facts/2.3/ubuntu-15.10-x86_64.facts
651
657
  - facts/2.3/ubuntu-16.04-i386.facts
652
658
  - facts/2.3/ubuntu-16.04-x86_64.facts
659
+ - facts/2.3/ubuntu-18.04-x86_64.facts
653
660
  - facts/2.3/windows-10-i386.facts
654
661
  - facts/2.3/windows-10-x86_64.facts
655
662
  - facts/2.3/windows-2008 r2-x86_64.facts
@@ -752,6 +759,7 @@ files:
752
759
  - facts/2.4/ubuntu-15.10-x86_64.facts
753
760
  - facts/2.4/ubuntu-16.04-i386.facts
754
761
  - facts/2.4/ubuntu-16.04-x86_64.facts
762
+ - facts/2.4/ubuntu-18.04-x86_64.facts
755
763
  - facts/2.4/windows-10-i386.facts
756
764
  - facts/2.4/windows-10-x86_64.facts
757
765
  - facts/2.4/windows-2008 r2-x86_64.facts
@@ -815,6 +823,7 @@ files:
815
823
  - facts/2.5/ubuntu-14.04-x86_64.facts
816
824
  - facts/2.5/ubuntu-16.04-i386.facts
817
825
  - facts/2.5/ubuntu-16.04-x86_64.facts
826
+ - facts/2.5/ubuntu-18.04-x86_64.facts
818
827
  - facts/2.5/windows-10-i386.facts
819
828
  - facts/2.5/windows-10-x86_64.facts
820
829
  - facts/2.5/windows-2008 r2-x86_64.facts
@@ -1273,6 +1282,8 @@ files:
1273
1282
  - facts/3.9/freebsd-10-amd64.facts
1274
1283
  - facts/3.9/freebsd-11-amd64.facts
1275
1284
  - facts/3.9/opensuse-42-x86_64.facts
1285
+ - facts/3.9/solaris-10-i386.facts
1286
+ - facts/3.9/solaris-10-x86_64.facts
1276
1287
  - facts/Gemfile
1277
1288
  - facts/Vagrantfile
1278
1289
  - facts/Windows_README.md
@@ -1289,6 +1300,11 @@ files:
1289
1300
  - facts/windows_packer/scripts/postunattend.xml
1290
1301
  - facts/windows_packer/scripts/provision.ps1
1291
1302
  - facts/windows_packer/vagrant_templates/vagrantfile-windows.template
1303
+ - hugo/archetypes/default.md
1304
+ - hugo/config.toml
1305
+ - hugo/content/.placeholder
1306
+ - images/facterdb.png
1307
+ - images/facterdb.svg
1292
1308
  - lib/facterdb.rb
1293
1309
  - lib/facterdb/bin.rb
1294
1310
  - lib/facterdb/version.rb