vfs 0.4.4 → 0.4.5

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/Rakefile CHANGED
@@ -7,5 +7,10 @@ project(
7
7
  # version: '0.4.0',
8
8
 
9
9
  author: "Alexey Petrushin",
10
- homepage: "http://github.com/alexeypetrushin/vfs"
11
- )
10
+ homepage: "http://alexeypetrushin.github.com/vfs"
11
+ )
12
+
13
+ desc "Generate documentation"
14
+ task :docs do
15
+ %x(cd docs && rocco -o site *.rb)
16
+ end
@@ -124,6 +124,11 @@ module Vfs
124
124
  driver.eql?(other.driver) and path.eql?(other.path)
125
125
  end
126
126
 
127
+ def delete *args
128
+ raise "use :destroy!"
129
+ end
130
+ alias_method :remove, :delete
131
+
127
132
  protected
128
133
  def destroy_entry first = :file, second = :dir
129
134
  driver.open do
@@ -53,6 +53,7 @@ module Vfs
53
53
  options = args.first || {}
54
54
  else
55
55
  data, options = *args
56
+ data ||= ""
56
57
  options ||= {}
57
58
  end
58
59
  raise "can't do :override and :append at the same time!" if options[:override] and options[:append]
@@ -144,7 +145,7 @@ module Vfs
144
145
  def size; get :size end
145
146
 
146
147
  def basename
147
- ::File.basename(name, File.extname(name))
148
+ ::File.basename(name, ::File.extname(name))
148
149
  end
149
150
 
150
151
  def extension
data/readme.md CHANGED
@@ -1,104 +1,22 @@
1
- Virtual File System provides **clean, simple and unified API over different storages** (Local File System, AWS S3, SFTP, Hadoop DFS, LDAP, Document Oriented DBs, In-Memory, ...).
2
- It is possible to provide such unified API because although those storages have different API the core concept are almost the same.
1
+ **Documentation:** http://alexeypetrushin.github.com/vfs
3
2
 
4
- Currently, there are following implementations available: Local FS, SFTP, S3.
3
+ Virtual File System provides **clean, simple and unified API over different storages** (Local File System, AWS S3, SFTP, ...).
5
4
 
6
- ## Goals
5
+ - very simple and intuitive API.
6
+ - same API for different storages.
7
+ - work simultaneously with multiple storages.
8
+ - small codebase, easy to learn and extend.
9
+ - driver implementation is very simple, it is easy to create new drivers.
7
10
 
8
- - **handy, simple and clean** API.
9
- - same API for different storages (Local FS, SSH, Hadoop, or any other , ...).
10
- - should work **simultaneously with different storages**.
11
- - small codebase, easy to extend and understand.
12
- - driver implementation should be simple, is should be easy to create new drivers.
11
+ Such unified API is possible because although the API of storages are different the core concept are almost the same.
13
12
 
14
- ## Example:
13
+ Install Vfs with Rubygems:
15
14
 
16
- The script below runs on local file system, to see this script running on S3 and SFTP please take a look at the examples folder, there are also samples for S3 backup and deployment over SSH/SFTP.
15
+ gem install vfs
17
16
 
18
- ``` ruby
19
- require 'vfs'
17
+ Once installed, You can proceed with the [basic example][basics], there's also [S3 version][s3_basics] and [SFTP version][ssh_basics] (also [S3 backup][s3_backup] and [SSH/SFTP deployment][ssh_deployment] examples availiable).
20
18
 
21
- # Preparing temporary dir for sample and cleaning it before starting.
22
- sandbox = '/tmp/vfs_sandbox'.to_dir.destroy
23
-
24
- # Let's create simple Hello World project.
25
- project = sandbox['hello_world'] # Our Hello World project.
26
-
27
- project['readme.txt'].write 'My shiny App' # Writing readme file, note that parent dirs
28
- # where created automatically.
29
-
30
- # File operations.
31
- readme = project['readme.txt']
32
-
33
- # Checking that it's all ok with our readme.
34
- p readme.name # => readme.txt
35
- p readme.path # => /.../readme.txt
36
- p readme.exist? # => true
37
- p readme.file? # => true
38
- p readme.dir? # => false
39
- p readme.size # => 12
40
- p readme.created_at # => 2011-09-09 13:20:43 +0400
41
- p readme.updated_at # => 2011-09-09 13:20:43 +0400
42
-
43
- # Reading.
44
- p readme.read # => "My shiny App"
45
- readme.read{|chunk| p chunk} # => "My shiny App"
46
-
47
- # Writing.
48
- readme.append "2 + 2 = 4"
49
- p readme.size # => 21
50
-
51
- readme.write "My shiny App v2" # Writing new version of readme.
52
- p readme.read # => "My shiny App v2"
53
-
54
- readme.write{|s| s.write "My shiny App v3"} # Writing another new version of readme.
55
- p readme.read # => "My shiny App v3"
56
-
57
- # Copying & Moving.
58
- readme.copy_to project['docs/readme.txt'] # Copying to ./docs folder.
59
- p project['docs/readme.txt'].exist? # => true
60
- p readme.exist? # => true
61
-
62
- readme.move_to project['docs/readme.txt'] # Moving to ./docs folder.
63
- p project['docs/readme.txt'].exist? # => true
64
- p readme.exist? # => false
65
-
66
-
67
- # Dir operations.
68
- project.file('Rakefile').create # Creating empty Rakefile.
69
-
70
- # Checking our project exists and not empty.
71
- p project.exist? # => true
72
- p project.empty? # => false
73
-
74
- # Listing dir content.
75
- p project.entries # => [/.../docs, .../Rakefile]
76
- p project.files # => [/.../Rakefile]
77
- p project.dirs # => [/.../docs]
78
- project.entries do |entry| # => ["docs", false]
79
- p [entry.name, entry.file?] # => ["Rakefile", true]
80
- end
81
- p project.include?('Rakefile') # => true
82
-
83
- # Copying & Moving, let's create another project by cloning our hello_world.
84
- project.copy_to sandbox['another_project']
85
- p sandbox['another_project'].entries # => [/.../docs, .../Rakefile]
86
-
87
- # Cleaning sandbox.
88
- sandbox.destroy
89
- ```
90
-
91
- API is the same for all storage types (Local, S3, SFTP, ...). Also API are the same for transfers (copy_to, move_to, ...) between any storage types.
92
- So, for example backup from S3 looks exactly the same as if files are located on the local folder.
93
-
94
- ## Installation
95
-
96
- ``` bash
97
- $ gem install vfs
98
-
99
- # For S3 and SFTP support install also vos
100
- $ gem install vos
101
- ```
19
+ You can report bugs and discuss features on the [issues page][issues].
102
20
 
103
21
  ## Integration with [Vos][vos] (Virtual Operating System)
104
22
 
@@ -123,4 +41,11 @@ Copyright (c) Alexey Petrushin http://petrush.in, released under the MIT license
123
41
 
124
42
  [vos]: http://github.com/alexeypetrushin/vos
125
43
  [cluster_management]: http://github.com/alexeypetrushin/cluster_management
126
- [my_cluster]: http://github.com/alexeypetrushin/my_cluster
44
+ [my_cluster]: http://github.com/alexeypetrushin/my_cluster
45
+
46
+ [basics]: http://alexeypetrushin.github.com/vfs/basics.html
47
+ [s3_basics]: http://alexeypetrushin.github.com/vfs/s3_basics.html
48
+ [s3_backup]: http://alexeypetrushin.github.com/vfs/s3_backup.html
49
+ [ssh_basics]: http://alexeypetrushin.github.com/vfs/ssh_basics.html
50
+ [ssh_deployment]: http://alexeypetrushin.github.com/vfs/ssh_deployment.html
51
+ [issues]: https://github.com/alexeypetrushin/vfs/issues
data/spec/file_spec.rb CHANGED
@@ -64,6 +64,11 @@ describe 'File' do
64
64
  @path.read.should == 'something'
65
65
  end
66
66
 
67
+ it 'should write empty file' do
68
+ @path.write
69
+ @path.read.should == ''
70
+ end
71
+
67
72
  it 'should override existing file' do
68
73
  @path.write 'something'
69
74
  @path.should be_file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
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: 2011-09-10 00:00:00.000000000Z
12
+ date: 2011-09-11 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -41,7 +41,7 @@ files:
41
41
  - spec/storages/local_spec/emptygit
42
42
  - spec/storages/local_spec.rb
43
43
  - spec/universal_entry_spec.rb
44
- homepage: http://github.com/alexeypetrushin/vfs
44
+ homepage: http://alexeypetrushin.github.com/vfs
45
45
  licenses: []
46
46
  post_install_message:
47
47
  rdoc_options: []