file_model 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,10 +1,9 @@
1
1
  require 'rake_ext'
2
2
 
3
- project(
3
+ project \
4
4
  name: "file_model",
5
5
  gem: true,
6
6
  summary: "File storage for Models",
7
7
 
8
8
  author: "Alexey Petrushin",
9
- homepage: "http://github.com/alexeypetrushin/file_model"
10
- )
9
+ homepage: "http://github.com/alexeypetrushin/file_model"
@@ -39,7 +39,7 @@ class FileModel::Adapter
39
39
  if dir.exist?
40
40
  dir.to_dir.entries do |entry|
41
41
  entry_time = entry.name.to_i
42
- entry.destroy if (entry_time > time) or (time > (entry_time + EXPIRATION_TIME))
42
+ entry.delete if (entry_time > time) or (time > (entry_time + EXPIRATION_TIME))
43
43
  end
44
44
  end
45
45
  end
@@ -20,7 +20,7 @@ module FileModel
20
20
  return false unless options[:validate] == false or valid?
21
21
 
22
22
  # deleting old files
23
- destroy validate: false
23
+ delete validate: false
24
24
 
25
25
  # saving
26
26
  self.name = build_name original.name
@@ -45,24 +45,24 @@ module FileModel
45
45
  save(options) || raise("can't save #{self} (#{errors.inspect})!")
46
46
  end
47
47
 
48
- def destroy options = {}
48
+ def delete options = {}
49
49
  return true unless name
50
50
 
51
51
  return false unless options[:validate] == false or valid?
52
52
 
53
53
  path = build_path name
54
- self.class.box[path].destroy
54
+ self.class.box[path].delete
55
55
 
56
56
  self.class.versions.each do |version_name, klass|
57
57
  path = build_path name, version_name
58
- self.class.box[path].destroy
58
+ self.class.box[path].delete
59
59
  end
60
60
 
61
61
  true
62
62
  end
63
63
 
64
- def destroy! options = {}
65
- destroy(options) || raise("can't destroy #{self} (#{errors.inspect})!")
64
+ def delete! options = {}
65
+ delete(options) || raise("can't delete #{self} (#{errors.inspect})!")
66
66
  end
67
67
 
68
68
  def url
@@ -1,7 +1,7 @@
1
1
  module FileModel::Helper
2
2
  module ClassMethods
3
3
  def mount_file attr_name, file_model_class
4
- attr_name.must_be.a Symbol
4
+ attr_name.must.be_a Symbol
5
5
  iv_name = :"@_#{attr_name}"
6
6
 
7
7
  define_method attr_name do
@@ -19,11 +19,11 @@ rspec do
19
19
  tmp = '/tmp/file_model_test'.to_dir
20
20
 
21
21
  before do
22
- tmp.destroy.create
22
+ tmp.delete.create
23
23
  FileModel.box = Vos::Box.new(Vos::Drivers::Local.new(root: tmp.path))
24
24
  end
25
25
 
26
- after{tmp.destroy}
26
+ after{tmp.delete}
27
27
  end
28
28
  end
29
29
  end
@@ -73,8 +73,8 @@ shared_examples_for 'file model crud' do
73
73
  file_model_storage['storage/images/sea/ship.jpg'].exist?.should be_false
74
74
  file_model_storage['storage/images/sea/ship2.jpg'].exist?.should be_true
75
75
 
76
- # destroying
77
- model.destroy.should be_true
76
+ # deleteing
77
+ model.delete.should be_true
78
78
  file_model_storage['storage/images/sea/ship2.jpg'].exist?.should be_false
79
79
  end
80
80
 
@@ -28,7 +28,7 @@ describe 'Model Integration' do
28
28
 
29
29
  after_save.push -> _self {self.image.save}
30
30
 
31
- after_destroy.push -> _self {self.image.destroy}
31
+ after_delete.push -> _self {self.image.delete}
32
32
  end
33
33
  end
34
34
  after(:all){remove_constants :TheModel}
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe "File Model" do
6
6
  with_file_model
7
-
7
+
8
8
  it 'should accept different formats' do
9
9
  original = FileModel::Adapter.new("#{spec_dir}/file.txt").to_file
10
10
  original.name.should == 'file.txt'
@@ -117,10 +117,10 @@ describe "File Model" do
117
117
  image.icon.file.exist?.should be_true
118
118
  image.icon.url.should == '/images/ship2.icon.jpg'
119
119
 
120
- # destroying
120
+ # deleteing
121
121
  image = ImageFile.new
122
122
  image.read 'ship2.jpg'
123
- image.destroy
123
+ image.delete
124
124
  file_model_storage['storage/images/ship2.jpg'].exist?.should be_false
125
125
  file_model_storage['storage/images/ship2.icon.jpg'].exist?.should be_false
126
126
  end
@@ -15,12 +15,12 @@ class ModelStub
15
15
  end
16
16
  end
17
17
 
18
- def destroy
18
+ def delete
19
19
  self.class.before_validate.each{|block| instance_eval &block}
20
20
 
21
21
  if errors.empty?
22
22
  # save
23
- self.class.after_destroy.each{|block| instance_eval &block}
23
+ self.class.after_delete.each{|block| instance_eval &block}
24
24
  true
25
25
  else
26
26
  false
@@ -36,8 +36,8 @@ class ModelStub
36
36
  @after_save ||= []
37
37
  end
38
38
 
39
- def after_destroy
40
- @after_destroy ||= []
39
+ def after_delete
40
+ @after_delete ||= []
41
41
  end
42
42
  end
43
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-22 00:00:00.000000000Z
12
+ date: 2011-11-18 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_ext
16
- requirement: &2833030 !ruby/object:Gem::Requirement
16
+ requirement: &2849270 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2833030
24
+ version_requirements: *2849270
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: vfs
27
- requirement: &2832790 !ruby/object:Gem::Requirement
27
+ requirement: &2849030 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2832790
35
+ version_requirements: *2849030
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: vos
38
- requirement: &2832550 !ruby/object:Gem::Requirement
38
+ requirement: &2848790 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2832550
46
+ version_requirements: *2848790
47
47
  description:
48
48
  email:
49
49
  executables: []