entity_storage 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -13,26 +13,26 @@ Additionally, allows users to set a list of default keys that auto-initializes b
13
13
  == SYNOPSIS:
14
14
 
15
15
  You can use the entity store like so:
16
-
17
- # Get key value.
16
+
17
+ # Get key value.
18
18
  e = EntityStore["testkey"]
19
19
  e = EntityStore.testkey
20
20
  e = EntityStore[:testkey]
21
-
21
+
22
22
  # sets key named 'happened' to a Time object of now
23
23
  EntityStore[:happened] = Time.now
24
24
  EntityStore["happened"] = Time.now
25
25
  EntityStore.happened = Time.now
26
-
26
+
27
27
  # find out it's default, even if it's been changed
28
28
  e = EntityStore.default(:testkey)
29
-
29
+
30
30
  # or
31
31
  e = EntityStore.defaults[:testkey]
32
-
32
+
33
33
  # set it back to default
34
34
  EntityStore.default!(:testkey)
35
-
35
+
36
36
  # delete an item
37
37
  EntityStore.delete(key)
38
38
 
@@ -43,41 +43,37 @@ 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 1.0.5, requires ActiveRecord 3.0.0.beta4 or greater.
46
+ As of 2.1.0, the MySQL2 gem and Ruby 1.9.3 are now supported.
47
47
 
48
- Version up to 1.0.4 requires Ruby 1.8.7 and ActiveRecord 2.2.3 or above (probably works with earlier versions, but has not been tested.)
48
+ As of 2.0.0, Rails 3.0.3 gems or above required.
49
49
 
50
+ Version up to 1.0.4 requires Ruby 1.8.7 and ActiveRecord 2.2.3 or above (probably works with earlier versions, but has not been tested.)
51
+ (earlier versions had an incorrect gem name, and are installed with 'gem install entity_storage')
50
52
  == INSTALL:
51
- To install from github:
53
+ Install the gem(s):
52
54
 
53
- Run the following if you haven't already:
54
-
55
- gem sources -a http://gems.github.com
56
-
57
- Install the gem(s):
58
-
59
- sudo gem install eatenbyagrue-entity_storage
55
+ sudo gem install entity_storage
60
56
 
61
- Or download the souce above and run, customized for version and environment:
57
+ Or download the source above and run, customized for version and environment:
62
58
 
63
- sudo gem install PATH/entity_storage.#.#.#.gem
59
+ sudo gem install PATH/entity_storage.#.#.#.gem
64
60
 
65
- Put the following at the bottom of your environment.rb file, or in an initializer.
61
+ Put the following in an initializer file named RAILS_ROOT/config/initializers/entity_storage.rb
66
62
 
67
63
  require 'entity_storage'
68
64
  DEFAULT_KEYS = { "testkey" => DateTime.parse("1-1-900"), "also test" => 2, "long ass key that I probably wouldn't use" => false }
69
- EntityStore = EntityStorage::Storage.new(DEFAULT_KEYS)
65
+ EntityStore = EntityStorage::Storage.new(DEFAULT_KEYS)
70
66
 
71
67
  On initialization, if the table "entity_storage" doesn't exist, it will be created. If you already have a table with that name, it must be in the correct format (previously created by this gem.)
72
68
 
73
- You can pass a hash full of default key/value pairs. If the application accesses one of the keys, and it doesn't already exist, it will initiliaze that key with the default value. Good for getting your app to an intial starting state.
69
+ You can pass a hash full of default key/value pairs. If the application accesses one of the keys, and it doesn't already exist, it will initiliaze that key with the default value. Good for getting your app to an initial starting state.
74
70
 
75
71
 
76
72
  == LICENSE:
77
73
 
78
74
  (The MIT License)
79
75
 
80
- Copyright (c) 2009 Joshua Siler
76
+ Copyright (c) 2009, 2010, 2011 Joshua Siler
81
77
 
82
78
  Permission is hereby granted, free of charge, to any person obtaining
83
79
  a copy of this software and associated documentation files (the
@@ -96,4 +92,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
96
92
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
97
93
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
98
94
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
99
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
95
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -17,8 +17,8 @@ $hoe = Hoe.spec 'entity-storage' do
17
17
  self.extra_deps = [['activerecord','>= 3.0.3']]
18
18
  end
19
19
 
20
- require 'newgem/tasks'
21
- Dir['tasks/**/*.rake'].each { |t| load t }
20
+ #require 'newgem/tasks'
21
+ #Dir['tasks/**/*.rake'].each { |t| load t }
22
22
 
23
23
  # TODO - want other tests/tasks run by default? Add them to the list
24
24
  # remove_task :default
data/config/database.yml CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
- adapter: mysql
2
+ adapter: mysql2
3
3
  database: entity_test
4
4
  username: root
5
- password: bnjstyle
5
+ password: sillier2
6
6
  host: localhost
7
7
 
8
8
 
@@ -9,18 +9,26 @@ require 'active_record'
9
9
 
10
10
 
11
11
  module EntityStorage
12
- VERSION = '2.0.0'
12
+ VERSION = '2.1.0'
13
13
 
14
14
  class Storage
15
15
  attr_accessor :defaults
16
16
 
17
17
  # Checks for the existence of the necessary Entities table... if not here, creates it.
18
18
  def initialize(defaults={})
19
- unless ActiveRecord::Base.connection.table_exists?('entity_storage')
19
+ if !ActiveRecord::Base.connection.table_exists?('entity_storage')
20
+ puts "Creating entity table..."
20
21
  AddEntitiesTable.create
21
- end
22
+ end
22
23
 
23
24
  self.defaults = defaults
25
+
26
+ # this will need to be updated for future version changes
27
+ if self['ENTITY_STORAGE_MASTER_VERSION'].nil? || self['ENTITY_STORAGE_MASTER_VERSION']!='2.1.0'
28
+ self['ENTITY_STORAGE_MASTER_VERSION']='2.1.0'
29
+ puts "Migrating to new 2.1.0 binary format..."
30
+ ActiveRecord::Base.connection.execute("alter table entity_storage modify value blob")
31
+ end
24
32
  end
25
33
 
26
34
  # Read a value.
@@ -51,7 +59,7 @@ module EntityStorage
51
59
 
52
60
  # Allows EntityStorage[:whatever] to be accessed via EntityStorage.whatever.
53
61
  def method_missing(*args)
54
- if args.length == 1
62
+ if args.length == 1
55
63
  self[args[0]]
56
64
  elsif args.length == 2 and args[0].to_s =~ /^(.*)=$/
57
65
  self[$1.intern] = args[1]
@@ -68,7 +76,8 @@ module EntityStorage
68
76
  def self.create
69
77
  create_table "entity_storage", :force => true do |t|
70
78
  t.string "key", :limit => 512, :null => false
71
- t.text "value"
79
+ #t.text "value"
80
+ t.binary "value"
72
81
  t.datetime "created_at"
73
82
  t.datetime "updated_at"
74
83
  end
@@ -78,11 +87,8 @@ module EntityStorage
78
87
  add_index "entity_storage", ["updated_at"], :name => "updated_at"
79
88
  end
80
89
 
81
- #def self.down
82
- # drop_table :entities
83
- #end
84
90
  end
85
-
91
+
86
92
 
87
93
  class Entity < ActiveRecord::Base
88
94
  set_table_name "entity_storage"
@@ -13,7 +13,7 @@ class TestEntityStorage < Test::Unit::TestCase
13
13
  EntityStore = EntityStorage::Storage.new(DEFAULT_KEYS)
14
14
 
15
15
  def setup
16
- ActiveRecord::Base.connection.execute("delete from entity_storage")
16
+ #ActiveRecord::Base.connection.execute("delete from entity_storage")
17
17
  end
18
18
 
19
19
  def test_instantiation
@@ -24,6 +24,7 @@ class TestEntityStorage < Test::Unit::TestCase
24
24
 
25
25
  # tests value setting and getting functionality, along with default creation
26
26
  def test_defaultkeys
27
+ ActiveRecord::Base.connection.execute("delete from entity_storage")
27
28
  DEFAULT_KEYS.each { |key,value|
28
29
  EntityStore.delete(key)
29
30
 
@@ -34,7 +35,7 @@ class TestEntityStorage < Test::Unit::TestCase
34
35
  EntityStore.delete(key)
35
36
 
36
37
  # set and try method missing access
37
- if key[/\w/] == key
38
+ if key[/\w/] == key
38
39
  eval("e = EntityStore."+key)
39
40
  assert_equal e, value
40
41
  end
@@ -58,7 +59,7 @@ class TestEntityStorage < Test::Unit::TestCase
58
59
 
59
60
  # set it to something else using method missing
60
61
  if key[/\w/] == key
61
- eval("e = EntityStore."+key +" = Time.now.to_s")
62
+ eval("e = EntityStore." + key + " = Time.now.to_s")
62
63
  assert_equal e, value
63
64
  end
64
65
  }
metadata CHANGED
@@ -1,87 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: entity_storage
3
- version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 0
9
- - 0
10
- version: 2.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Joshua Siler
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-12-10 00:00:00 -08:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-10-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rails
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &71589300 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 1
30
- segments:
31
- - 3
32
- - 0
33
- - 3
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 3.0.3
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: activerecord
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *71589300
25
+ - !ruby/object:Gem::Dependency
26
+ name: activerecord
27
+ requirement: &71588720 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 1
46
- segments:
47
- - 3
48
- - 0
49
- - 3
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
50
32
  version: 3.0.3
51
33
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: hoe
55
34
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *71588720
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ requirement: &71588360 !ruby/object:Gem::Requirement
57
39
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 5
62
- segments:
63
- - 2
64
- - 3
65
- - 3
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
66
43
  version: 2.3.3
67
44
  type: :development
68
- version_requirements: *id003
69
- description: |-
70
- An easy to use Key/Value store for any Ruby on Rails project. Like Memcache, only persistent. Stores config values &amp; application wide state in the database in order to survive server restarts.
71
-
72
- Designed to allow you to add persistent value storage to any Rails project in about 5 minutes.
73
-
74
- Additionally, allows users to set a list of default keys that auto-initializes baseline key/value pairs in the database for easy initialization.
75
- email:
45
+ prerelease: false
46
+ version_requirements: *71588360
47
+ description: ! 'An easy to use Key/Value store for any Ruby on Rails project. Like
48
+ Memcache, only persistent. Stores config values &amp; application wide state in
49
+ the database in order to survive server restarts.
50
+
51
+
52
+ Designed to allow you to add persistent value storage to any Rails project in about
53
+ 5 minutes.
54
+
55
+
56
+ Additionally, allows users to set a list of default keys that auto-initializes baseline
57
+ key/value pairs in the database for easy initialization.'
58
+ email:
76
59
  - joshua.siler@gmail.com
77
60
  executables: []
78
-
79
61
  extensions: []
80
-
81
- extra_rdoc_files:
62
+ extra_rdoc_files:
82
63
  - History.txt
83
64
  - Manifest.txt
84
- files:
65
+ files:
85
66
  - History.txt
86
67
  - Manifest.txt
87
68
  - README.rdoc
@@ -93,43 +74,32 @@ files:
93
74
  - config/database.yml
94
75
  - test/test_entity_storage.rb
95
76
  - test/test_helper.rb
96
- has_rdoc: true
97
77
  homepage: http://github.com/eatenbyagrue/entity_storage
98
78
  licenses: []
99
-
100
79
  post_install_message:
101
- rdoc_options:
80
+ rdoc_options:
102
81
  - --main
103
82
  - README.rdoc
104
- require_paths:
83
+ require_paths:
105
84
  - lib
106
- required_ruby_version: !ruby/object:Gem::Requirement
85
+ required_ruby_version: !ruby/object:Gem::Requirement
107
86
  none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- hash: 57
112
- segments:
113
- - 1
114
- - 8
115
- - 7
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
116
90
  version: 1.8.7
117
- required_rubygems_version: !ruby/object:Gem::Requirement
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
92
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- hash: 3
123
- segments:
124
- - 0
125
- version: "0"
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
126
97
  requirements: []
127
-
128
98
  rubyforge_project: entity-storage
129
- rubygems_version: 1.3.7
99
+ rubygems_version: 1.8.10
130
100
  signing_key:
131
101
  specification_version: 3
132
102
  summary: An easy to use Key/Value store for any Ruby on Rails project
133
- test_files:
103
+ test_files:
134
104
  - test/test_entity_storage.rb
135
105
  - test/test_helper.rb