fast 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +5 -1
- data/README.md +122 -0
- data/fast.gemspec +2 -1
- data/lib/fast.rb +1 -0
- data/lib/fast/dir.rb +73 -35
- data/lib/fast/exceptions.rb +3 -0
- data/lib/fast/fast.rb +3 -0
- data/lib/fast/file.rb +16 -37
- data/lib/fast/filesystemobject.rb +69 -0
- data/lib/fast/version.rb +1 -1
- data/lib/patterns/adapter/fast/dir.rb +19 -0
- data/lib/sub-setter/fast/dir.rb +8 -0
- data/spec/fast/dir_spec.rb +152 -94
- data/spec/fast/file_spec.rb +72 -80
- data/spec/fast/filesystemobject_spec.rb +309 -0
- data/spec/patterns/adapter/fast/dir_spec.rb +16 -0
- data/spec/sub-setter/fast/dir_spec.rb +20 -0
- metadata +47 -10
- data/README.rdoc +0 -81
data/README.rdoc
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
= Fast
|
2
|
-
|
3
|
-
Tired of having a hard time working with files? Take a look at Fast...
|
4
|
-
|
5
|
-
require "fast"
|
6
|
-
|
7
|
-
lib_dir = dir! :lib
|
8
|
-
|
9
|
-
lib_dir["demo.txt"] = "I love creating files from a Hash-like API"
|
10
|
-
|
11
|
-
lib_dir.list # => ['demo.txt']
|
12
|
-
|
13
|
-
file! "lib/empty.txt"
|
14
|
-
|
15
|
-
lib_dir.files.each do |path|
|
16
|
-
puts path
|
17
|
-
end # => demo.txt
|
18
|
-
# empty.txt
|
19
|
-
|
20
|
-
lib_dir.destroy
|
21
|
-
|
22
|
-
dir? :lib # => false
|
23
|
-
|
24
|
-
...and wait a few weeks because this is not stable yet ;)
|
25
|
-
|
26
|
-
Fast is a DSL for file and dir handling focused in intuitivity and semantics. Is pure Ruby (1.8.7+) with no dependencies, except for Metafun for the DSL.
|
27
|
-
|
28
|
-
== Installation
|
29
|
-
|
30
|
-
gem install fast
|
31
|
-
|
32
|
-
== Usage
|
33
|
-
|
34
|
-
Fast declares two sets of methods in its DSL:
|
35
|
-
|
36
|
-
=== Dir methods
|
37
|
-
|
38
|
-
dir :lib # The same as => Fast::Dir.new "lib"
|
39
|
-
dir.delete! "demo" # The same as => Fast::Dir.new.delete! "demo"
|
40
|
-
|
41
|
-
dir! :new_dir # The same as => Fast::Dir.new.create! :new_dir
|
42
|
-
dir? :new_dir # The same as => Fast::Dir.new.exist? :new_dir
|
43
|
-
|
44
|
-
=== File methods
|
45
|
-
|
46
|
-
file "demo.txt" # The same as => Fast::File.new "demo.txt"
|
47
|
-
file.copy "demo.txt", "new.txt" # The same as =>
|
48
|
-
# Fast::File.new.copy "demo.txt", "new.txt"
|
49
|
-
|
50
|
-
file! "demo.txt" # The same as => Fast::File.new.create! "demo.txt"
|
51
|
-
file? "demo.txt" # The same as => Fast::File.new.exist? "demo.txt"
|
52
|
-
|
53
|
-
== Philosophy
|
54
|
-
|
55
|
-
*Fast* embraces a more straightforward view of files as strings of data and directories as arrays of files/directories. Why?
|
56
|
-
|
57
|
-
* It is more realistic in everyday usage
|
58
|
-
* It makes them more object-like (and thus, more friendly to OOP)
|
59
|
-
* Is more semantic
|
60
|
-
* Files as IOs are still accessible through the harder-to-use native Ruby API
|
61
|
-
|
62
|
-
<tt>Fast::Dir</tt> is a subclass of <tt>Array</tt>, usable as a hash, and <tt>Fast::File</tt> if a subclass of String.
|
63
|
-
|
64
|
-
== Quick notes
|
65
|
-
* URGENT: Make fast depend of the last version of <tt>metafun</tt>
|
66
|
-
* Deliberate whether is a good idea to make Fast::Dir and Fast::File Multitons.
|
67
|
-
* Read bytes as binary ASCII-8BIT always and then try to perform an heuristic conversion, if there is any reasonable way to do it. Otherwise, leave it to the user. Google: "ruby string encode utf-8 ascii" for some good readings.
|
68
|
-
* File lists as returned by Fast::Dir#list and Fast::Dir#dirs will be filtered after the list is retrieved by a set of filtering methods of the returned list, which should be an instance of Fast::Dir.
|
69
|
-
* An instance of Fast::Dir should be possible to be created from a Array.
|
70
|
-
* The path can be setted indirectly by any method of Fast::File instances, and the same works for Dir. This is fine because allows for very quick calls, but once an instance gets a path setted it should be fixed and raise an exception in case some other method call is trying to change it.
|
71
|
-
|
72
|
-
== Remote future
|
73
|
-
* Make Fast a REST client (well, use <tt>rest-client</tt>) in order to transparently use files and directories from a compliant REST server.
|
74
|
-
* Include REST methods: Dir#post, File#get, File#head, etc
|
75
|
-
* Allow Files to behave as Dirs with the right method calls
|
76
|
-
|
77
|
-
== License
|
78
|
-
|
79
|
-
GPL License. Why other?
|
80
|
-
|
81
|
-
@ Xavier Via
|