objectstore 0.0.1 → 1.0.0
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.
- data/lib/atech/object_store.rb +7 -1
- data/lib/atech/object_store/file.rb +8 -0
- data/schema.sql +1 -1
- metadata +3 -3
data/lib/atech/object_store.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
module Atech
|
2
2
|
module ObjectStore
|
3
|
-
VERSION = '0.0
|
3
|
+
VERSION = '1.0.0'
|
4
4
|
|
5
5
|
## Error class which all Object Store errors are inherited fro
|
6
6
|
class Error < StandardError; end
|
7
7
|
|
8
8
|
class << self
|
9
9
|
attr_accessor :backend
|
10
|
+
attr_accessor :maximum_file_size
|
11
|
+
|
12
|
+
def maximum_file_size
|
13
|
+
@maximum_file_size ||= 1024 * 1024 * 1024
|
14
|
+
end
|
15
|
+
|
10
16
|
end
|
11
17
|
|
12
18
|
end
|
@@ -11,6 +11,9 @@ module Atech
|
|
11
11
|
## Raised if a frozen file is editted
|
12
12
|
class CannotEditFrozenFile < Error; end
|
13
13
|
|
14
|
+
## Raised if the data is larger than the maximum file size
|
15
|
+
class FileDataTooBig < Error; end
|
16
|
+
|
14
17
|
## Returns a new file object for the given ID. If no file is found a FileNotFound exception will be raised
|
15
18
|
## otherwise the File object will be returned.
|
16
19
|
def self.find_by_id(id)
|
@@ -34,6 +37,11 @@ module Atech
|
|
34
37
|
## Inserts a new File into the database. Returns a new object if successfully inserted or raises an error.
|
35
38
|
## Filename & data must be provided, options options will be added automatically unless specified.
|
36
39
|
def self.add_file(filename, data = '', options = {})
|
40
|
+
|
41
|
+
if data.bytesize > Atech::ObjectStore.maximum_file_size
|
42
|
+
raise FileDataTooBig, "Data provided was #{data.bytesize} and the maximum size is #{Atech::ObjectStore.maximum_file_size}"
|
43
|
+
end
|
44
|
+
|
37
45
|
## Create a hash of properties to be for this class
|
38
46
|
options[:name] = filename
|
39
47
|
options[:size] ||= data.bytesize
|
data/schema.sql
CHANGED
@@ -30,7 +30,7 @@ CREATE TABLE `files` (
|
|
30
30
|
`created_at` datetime NOT NULL,
|
31
31
|
`updated_at` datetime NOT NULL,
|
32
32
|
PRIMARY KEY (`id`)
|
33
|
-
) ENGINE=InnoDB AUTO_INCREMENT=
|
33
|
+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
34
34
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
35
35
|
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
36
36
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: objectstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-14 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: adam@atechmedia.com
|
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
42
|
rubyforge_project:
|
43
|
-
rubygems_version: 1.8.
|
43
|
+
rubygems_version: 1.8.10
|
44
44
|
signing_key:
|
45
45
|
specification_version: 3
|
46
46
|
summary: A SQL based object store library
|