entity_storage 2.1.3 → 2.1.4
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 +7 -0
- data/History.txt +3 -0
- data/README.rdoc +3 -1
- data/lib/entity_storage.rb +9 -5
- data/test/test_entity_storage.rb +20 -3
- metadata +55 -83
- data/test/test_helper.rb +0 -4
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c22d19f1842688ea2ecbe8cce2a532923c99bced
|
4
|
+
data.tar.gz: a5d69524c725cacc5e39330419149db23b6459e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f2f673a60836d93b1a4a9119cb8a948a55b06bc48659e847a41d081ff3d19a5965817b5933da46fdb358307dfc119e07983d74a1aae9001ca5a5a3fcd39d7f2a
|
7
|
+
data.tar.gz: ba58271df0f3acb7e44c27a051e48be02dc4cf4fba2b58f6bad228c30de9532bf902d2dcfa96af53a46a09812e5370799611b94374c534c7ead5f4e38c9fc057
|
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -43,6 +43,8 @@ If you access a key that doesn't exist, and is specified in default list, will b
|
|
43
43
|
Keys can be up to 512 characters in length. Values can be practically any size, and consist of any object. Objects are marshalled back and forth between database.
|
44
44
|
|
45
45
|
== REQUIREMENTS:
|
46
|
+
As of 2.1.4, tested with Ruby 2.1.2.
|
47
|
+
|
46
48
|
As of 2.1.0, the MySQL2 gem and Ruby 1.9.3 are now supported.
|
47
49
|
|
48
50
|
As of 2.0.0, Rails 3.0.3 gems or above required.
|
@@ -73,7 +75,7 @@ You can pass a hash full of default key/value pairs. If the application accesses
|
|
73
75
|
|
74
76
|
(The MIT License)
|
75
77
|
|
76
|
-
Copyright (c) 2009
|
78
|
+
Copyright (c) 2009-2014 Joshua Siler
|
77
79
|
|
78
80
|
Permission is hereby granted, free of charge, to any person obtaining
|
79
81
|
a copy of this software and associated documentation files (the
|
data/lib/entity_storage.rb
CHANGED
@@ -112,12 +112,16 @@ module EntityStorage
|
|
112
112
|
# Sets value for a specific key. If key doesn't exist, creates with value.
|
113
113
|
def self.set_value(search_key, new_value)
|
114
114
|
e = Entity.find_by_key(search_key.to_s)
|
115
|
-
if
|
116
|
-
|
115
|
+
if new_value.nil?
|
116
|
+
Entity.where(key: e.key).delete_all
|
117
|
+
else
|
118
|
+
if e.nil?
|
119
|
+
e = new
|
120
|
+
end
|
121
|
+
e.key = search_key
|
122
|
+
e.value = new_value
|
123
|
+
e.save
|
117
124
|
end
|
118
|
-
e.key = search_key
|
119
|
-
e.value = new_value
|
120
|
-
e.save
|
121
125
|
end
|
122
126
|
|
123
127
|
# Resets a key contained in DEFAULT_KEYS global constant to it's default value
|
data/test/test_entity_storage.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require 'stringio'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
require Dir.pwd + '/lib/entity_storage'
|
5
|
+
|
6
|
+
|
2
7
|
ActiveRecord::Base.establish_connection(YAML::load(File.read(File.dirname(__FILE__) + '/../config/database.yml')))
|
3
8
|
|
4
|
-
class TestEntityStorage <
|
9
|
+
class TestEntityStorage < Minitest::Unit::TestCase
|
5
10
|
DEFAULT_KEYS = { "test" => DateTime.parse("1-1-900"), "also test" => 2, "long ass key that I probably wouldn't use" => false,
|
6
11
|
# last time the hiring manager notifications have been run
|
7
12
|
"new_applicant_last_run" => DateTime.parse("1-1-1900"),
|
@@ -16,6 +21,18 @@ class TestEntityStorage < Test::Unit::TestCase
|
|
16
21
|
#ActiveRecord::Base.connection.execute("delete from entity_storage")
|
17
22
|
end
|
18
23
|
|
24
|
+
def test_counts
|
25
|
+
# fix bug where reading null value inserts new record
|
26
|
+
#puts cnt
|
27
|
+
EntityStore["test"] = "item"
|
28
|
+
cnt = ActiveRecord::Base.connection.execute("select * from entity_storage").count
|
29
|
+
EntityStore["test"] = nil
|
30
|
+
EntityStore["test"]
|
31
|
+
#puts cnt
|
32
|
+
#puts ActiveRecord::Base.connection.execute("select * from entity_storage").count
|
33
|
+
assert cnt == ActiveRecord::Base.connection.execute("select * from entity_storage").count
|
34
|
+
end
|
35
|
+
|
19
36
|
def test_instantiation
|
20
37
|
# test nasty weird bug with underscore characters
|
21
38
|
entityStore2 = EntityStorage::Storage.new(DEFAULT_KEYS)
|
@@ -65,7 +82,7 @@ class TestEntityStorage < Test::Unit::TestCase
|
|
65
82
|
# change it to something else
|
66
83
|
EntityStore[key] = Time.now.to_s
|
67
84
|
e = EntityStore[key]
|
68
|
-
|
85
|
+
assert e != value
|
69
86
|
|
70
87
|
# find out it's default
|
71
88
|
e = EntityStore.default(key)
|
metadata
CHANGED
@@ -1,133 +1,105 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: entity_storage
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 1
|
9
|
-
- 3
|
10
|
-
version: 2.1.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.1.4
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Joshua Siler
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2011-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: rails
|
22
|
-
|
23
|
-
|
24
|
-
none: false
|
25
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
26
17
|
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 1
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 0
|
32
|
-
- 3
|
18
|
+
- !ruby/object:Gem::Version
|
33
19
|
version: 3.0.3
|
34
20
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: activerecord
|
38
21
|
prerelease: false
|
39
|
-
|
40
|
-
|
41
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
42
31
|
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 1
|
45
|
-
segments:
|
46
|
-
- 3
|
47
|
-
- 0
|
48
|
-
- 3
|
32
|
+
- !ruby/object:Gem::Version
|
49
33
|
version: 3.0.3
|
50
34
|
type: :runtime
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: hoe
|
54
35
|
prerelease: false
|
55
|
-
|
56
|
-
|
57
|
-
requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
58
38
|
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hoe
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
65
47
|
version: 2.3.3
|
66
48
|
type: :development
|
67
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.3.3
|
68
55
|
description: |-
|
69
56
|
An easy to use Key/Value store for any Ruby on Rails project. Like Memcache, only persistent. Stores config values & application wide state in the database in order to survive server restarts.
|
70
|
-
|
57
|
+
|
71
58
|
Designed to allow you to add persistent value storage to any Rails project in about 5 minutes.
|
72
|
-
|
59
|
+
|
73
60
|
Additionally, allows users to set a list of default keys that auto-initializes baseline key/value pairs in the database for easy initialization.
|
74
|
-
email:
|
61
|
+
email:
|
75
62
|
- joshua.siler@gmail.com
|
76
63
|
executables: []
|
77
|
-
|
78
64
|
extensions: []
|
79
|
-
|
80
|
-
extra_rdoc_files:
|
65
|
+
extra_rdoc_files:
|
81
66
|
- History.txt
|
82
67
|
- Manifest.txt
|
83
|
-
files:
|
68
|
+
files:
|
84
69
|
- History.txt
|
85
70
|
- Manifest.txt
|
86
71
|
- README.rdoc
|
87
72
|
- Rakefile
|
73
|
+
- config/database.yml
|
88
74
|
- lib/entity_storage.rb
|
89
75
|
- script/console
|
90
76
|
- script/destroy
|
91
77
|
- script/generate
|
92
|
-
- config/database.yml
|
93
78
|
- test/test_entity_storage.rb
|
94
|
-
- test/test_helper.rb
|
95
79
|
homepage: http://github.com/eatenbyagrue/entity_storage
|
96
80
|
licenses: []
|
97
|
-
|
81
|
+
metadata: {}
|
98
82
|
post_install_message:
|
99
|
-
rdoc_options:
|
100
|
-
- --main
|
83
|
+
rdoc_options:
|
84
|
+
- "--main"
|
101
85
|
- README.rdoc
|
102
|
-
require_paths:
|
86
|
+
require_paths:
|
103
87
|
- lib
|
104
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
|
106
|
-
requirements:
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
107
90
|
- - ">="
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
hash: 57
|
110
|
-
segments:
|
111
|
-
- 1
|
112
|
-
- 8
|
113
|
-
- 7
|
91
|
+
- !ruby/object:Gem::Version
|
114
92
|
version: 1.8.7
|
115
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
-
|
117
|
-
requirements:
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
118
95
|
- - ">="
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
|
121
|
-
segments:
|
122
|
-
- 0
|
123
|
-
version: "0"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
124
98
|
requirements: []
|
125
|
-
|
126
99
|
rubyforge_project: entity-storage
|
127
|
-
rubygems_version:
|
100
|
+
rubygems_version: 2.2.2
|
128
101
|
signing_key:
|
129
102
|
specification_version: 3
|
130
103
|
summary: An easy to use Key/Value store for any Ruby on Rails project
|
131
|
-
test_files:
|
104
|
+
test_files:
|
132
105
|
- test/test_entity_storage.rb
|
133
|
-
- test/test_helper.rb
|
data/test/test_helper.rb
DELETED