document_file 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -8,6 +8,10 @@ http://github.com/mojombo/jekyll). They consist of a preambel written in YAML
8
8
  (also called YAML front matter), and some content in the format you prefer,
9
9
  e.g. Textile. Example:
10
10
 
11
+ documents/
12
+ |-foo.textile
13
+ |-bar.textile
14
+
11
15
  !!!document starts in the following line.
12
16
  ---
13
17
  id: 1
@@ -22,10 +26,9 @@ I like the flowers.
22
26
  Can be abstracted like this:
23
27
 
24
28
  class MyDocument < DocumentFile::Base
29
+ self.documents_dir = './documents'
25
30
  end
26
31
 
27
- MyDocument.documents_dir = './documents'
28
-
29
32
  # You now have dynamic finders:
30
33
  doc = MyDocument.find_by_title("The shizzle!") # => returns the document
31
34
  doc = MyDocument.find_by_number_of_foos(42) # => returns the document
@@ -32,7 +32,7 @@ module DocumentFile
32
32
  def self.reload!
33
33
  if File.directory?(@@documents_dir)
34
34
  file_paths = Dir.glob("#{@@documents_dir}/*.*")
35
- @@documents = file_paths.map { |file_path| self.new File.join(Dir.getwd, file_path) }
35
+ @@documents = file_paths.map { |file_path| self.new file_path }
36
36
  else
37
37
  []
38
38
  end
@@ -99,7 +99,7 @@ module DocumentFile
99
99
 
100
100
  def self.method_missing(method_name, *args)
101
101
  self.all unless @@documents
102
- super
102
+ respond_to?(method_name) ? self.send(method_name, *args) : super
103
103
  end
104
104
  end
105
105
  end
@@ -1,3 +1,3 @@
1
1
  module DocumentFile
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ralph von der Heyden