poros 0.3.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dc1a45e91216abe73208b6c54926ad645e00217ac26c1ee829afc4b75bd279a
4
- data.tar.gz: b0eae29db2cba9dfe71dc4d830bbba43c41ff2ea8cb6a6d4c89328f4ce2d450b
3
+ metadata.gz: 016c361abb81a9dfe8c7a338515754ded79a4fd70518ed23964765ec098bc5e5
4
+ data.tar.gz: 50679f5bdc6b51afb5e612aa7c93d9de67b469a05ad1baf971d694a5d157e478
5
5
  SHA512:
6
- metadata.gz: c26f6f28c9324df4cd0be12b514ee967486e3a80a6fa051b0682099b77fdaa50ae77720aa698af07dcd4c789593ddddd32e0d9cb0d926e8cd1314fc1a3a57834
7
- data.tar.gz: 3c04c87297694078d97ec8b29c98d440ce0e5c0274791899bab06ac859d5638b671b1b3b94d33b0177471367a2ec76c74fa234fb7cc2fbac3327fcd6df38c293
6
+ metadata.gz: 397fa97afdc11207acb52d695988bf8045b46dc84d37c938649625e50e8555893b03d755487615aaeb291cb0a2dc7b59ac4ca17629f3b42602f481023a01d815
7
+ data.tar.gz: 69a8f43db77401244d12ca66cb0a0d8f527309c335b0e38b6e41347764c8569942b9ffe662f96581dd1ae28b1b97d2dd73cc7b72ec5016ff97b8bf736beb5874
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  module Poros
2
4
  module ClassMethods
3
5
  attr_accessor :in_transaction, :data_changed
@@ -61,7 +63,7 @@ module Poros
61
63
  end
62
64
 
63
65
  def index_data
64
- return @index_data if @index_data
66
+ return @index_data if defined? @index_data
65
67
 
66
68
  data = File.exist?(index_file) ? YAML.load(File.read(index_file)) : {}
67
69
  # Make sure we always have every index as a key
@@ -73,6 +75,7 @@ module Poros
73
75
  end
74
76
 
75
77
  def write_index_data
78
+ return if in_transaction
76
79
  File.write(index_file, @index_data.to_yaml)
77
80
  end
78
81
 
@@ -88,20 +91,22 @@ module Poros
88
91
  @index_data[index][value] = @index_data[index][value] | [object.uuid]
89
92
  end
90
93
 
91
- write_index_data unless @in_transaction
94
+ write_index_data
92
95
  end
93
96
 
94
97
  def remove_from_index(object, perist = true)
95
98
  index_data
99
+ @data_changed = true
96
100
 
97
101
  poro_indexes.each do |index|
98
102
  @index_data[index] = {} unless @index_data.has_key?(index)
99
103
  @index_data[index].keys.each do |value|
100
104
  @index_data[index][value] ||= []
101
105
  @index_data[index][value] -= [object.uuid]
106
+ @index_data[index].delete(value) if @index_data[index][value] == []
102
107
  end
103
108
  end
104
- write_index_data if !@in_transaction && perist
109
+ write_index_data if perist
105
110
  end
106
111
 
107
112
  def rebuild_indexes
@@ -2,7 +2,7 @@ require 'poros/info'
2
2
 
3
3
  module Poros
4
4
  module InstanceMethods
5
- attr_accessor :uuid
5
+ attr_writer :uuid
6
6
  def uuid
7
7
  @uuid ||= SecureRandom.uuid
8
8
  end
data/lib/poros/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Poros
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/poros.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.description = 'Persist your objects and query them in an active record like way'
12
12
  spec.authors = ["Sean Ross Earle"]
13
13
  spec.email = ["sean.earle@oeQuacki.com"]
14
- spec.homepage = "https://github.com/HellRok/YAMLCache"
14
+ spec.homepage = "https://github.com/HellRok/Poros"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poros
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Ross Earle
@@ -73,7 +73,7 @@ files:
73
73
  - lib/poros/relations.rb
74
74
  - lib/poros/version.rb
75
75
  - poros.gemspec
76
- homepage: https://github.com/HellRok/YAMLCache
76
+ homepage: https://github.com/HellRok/Poros
77
77
  licenses:
78
78
  - MIT
79
79
  metadata: {}