rowdb 0.1.2 → 0.1.3

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: f4f0a6574146b856137a147b38f1206a5f9881f3b11cef23fa541fbc00b77e41
4
- data.tar.gz: 3e94c7830dd13dea3f7efdd64218ab1d6124a83077970547d0159411d33d101a
3
+ metadata.gz: dabd84303018d21818c1930fe77d0612cd50a84699507c1913f5b21ba74d7713
4
+ data.tar.gz: '038bba35d11a83ec5214fa8ef9c44c9538a604809981955c24504697590329a0'
5
5
  SHA512:
6
- metadata.gz: 122ea5b0d1c86f97d1245acf76ea5ddaaf9c088c01e7ed99c5efb14262cf449a69f587d09301e24e457e686807ea7a0ac90328f591491c38ca6c3b3f8e78146e
7
- data.tar.gz: bf657e8e3f1fd007af9f4841d1845d23fd5575d761ef2744139a95eb76f7608b1ecf236567792fc9c6c56c62a3f6a2f6c6bcaa736977c134705e461d04932587
6
+ metadata.gz: b057c1358d2b4d96ed52b15ad5375563aa869b16a2ebe5d894ca10e78e718f35f581ff559b5b5b01681ec6bcbfd511e82bc9b7a2cc60bf2c4ac8bb6bccbb1e7a
7
+ data.tar.gz: eb0699415e0f7d1a398f393f88efbcadb1165b4e225677ac36a2616280da273aeebb5031de1d3d33a393bec76dcf0b7ae78c909b1ef7c075122268d35022e9c0
@@ -1,10 +1,11 @@
1
+ require 'oj'
1
2
  require_relative 'Adapter.rb'
2
3
 
3
4
  class FileSystem < Adapter
4
5
 
5
6
  def read()
6
7
 
7
- p Oj.load_file(@source)
8
+ Oj.load_file(@source)
8
9
 
9
10
  end
10
11
 
@@ -1,31 +1,49 @@
1
- require 'oj'
1
+ require 'rudash'
2
2
  require_relative 'adapters/FileSystem.rb'
3
3
 
4
4
  class Rowdb
5
5
 
6
- def initialize(adapter = :file_system, filepath)
7
- p filepath
8
- p Dir.pwd
9
- p __FILE__
10
- p __dir__
11
- @adapter = self.send(adapter, filepath)
6
+ def initialize(adapter = :file_system, file_path)
7
+ @adapter = self.send(adapter, normalize_path(file_path))
8
+ @data = @adapter.read()
12
9
  end
13
10
 
14
11
  def defaults(hash)
15
-
16
12
  json = Oj.dump(hash)
17
13
  @adapter.write(json)
18
-
19
14
  end
20
15
 
21
- def get(item)
16
+ def get(path)
17
+ R_.get(@adapter.source, path)
18
+ end
22
19
 
20
+ def set(path, value)
21
+ @data = R_.set(@data, path, value)
23
22
  end
24
23
 
25
24
  private
26
25
 
27
- def file_system(filepath)
28
- FileSystem.new(filepath)
26
+ def file_system(file_path)
27
+ FileSystem.new(file_path)
28
+ end
29
+
30
+ ##
31
+ # Normalize path.
32
+ #
33
+ # @param file_path - An absolute or relative path.
34
+ # @return An absolute path.
35
+ ##
36
+ def normalize_path(file_path)
37
+
38
+ # Absolute path.
39
+ if file_path.start_with? '/'
40
+ return file_path
41
+ # Relative path.
42
+ else
43
+ # Get directory the script executed from.
44
+ return File.join(Dir.pwd, '/' + file_path)
45
+ end
46
+
29
47
  end
30
48
 
31
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rowdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maedi Prichard