mfs 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 204680b93d9f8916bc609dd0ab33fc8835a0dde3
4
- data.tar.gz: ee56e500fdc2eabfb25a598b28800e7240cedfbc
3
+ metadata.gz: ea0b039aa36c2924464ab857e64aadec8dcbe9de
4
+ data.tar.gz: f88b8cf769f6eda04b976a14a04e271516785ae7
5
5
  SHA512:
6
- metadata.gz: 2c8acd377e6d06c4507c514ba63b7920304e6fb31704189d89af33cbf6602d31aad244ee446371cf31c13a9cf12561b21ad4d44b09762743ebd8a854334c9c91
7
- data.tar.gz: e1259fa3de32b196c3d2783f536534bce035ff69bde8304e7c16dbdafc0e3eb69f1681be04e3e4bbfd2597e63d9bf42814448602bcf58c7158129ba43069d62b
6
+ metadata.gz: e46136f0097e80a7f83785d6ad90d3e6dd660d2e26f0b4bad27d9b7a1ec2713338bf3c5dfdfed2d7ae21b3a1ae565bd71e1f921c6fbaa20e9c2aa979d553b9f9
7
+ data.tar.gz: cfda348f83660a8c0859e2a5e53624765fc365b801c211ee1b86304a1803f37ffa5948711bc071e5b47db1b3806c00ebbe4b2c8d33b380010fead2472dbf5842
@@ -2,3 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 1.9.3
5
+ services: mongodb
data/README.md CHANGED
@@ -1,19 +1,49 @@
1
1
  Mongo File Store
2
2
  ================
3
3
 
4
- Mongo File Store is a library for adding small files from the filesystem to MongoDB.
4
+ Mongo File Store is a library for adding small files from the filesystem to MongoDB using Mongoid.
5
5
 
6
6
  Status
7
7
  ------
8
8
  [![Code Climate](https://codeclimate.com/github/SoftwareWithFriends/mfs.png)](https://codeclimate.com/github/SoftwareWithFriends/mfs)
9
9
  [![Build Status](https://api.travis-ci.org/SoftwareWithFriends/mfs.png?branch=master)](https://travis-ci.org/SoftwareWithFriends/mfs)
10
10
 
11
+ Install
12
+ -------
13
+ ```
14
+ gem install mfs
15
+ ```
16
+
11
17
  Purpose
12
18
  -------
13
19
  * Shared Set of Files
14
20
  * Attach Metadata to Files
15
21
  * Retrieve Files based on metadata
16
22
 
23
+ Usage
24
+ -----
25
+ ```ruby
26
+ require 'mfs'
27
+ entry = Mfs::Loader.load_file('path/to/file')
28
+ entry.filepath
29
+ entry.filename
30
+ entry.created_at
31
+ entry.data
32
+
33
+ # Set arbitrary Meta-data fields
34
+ Mfs::Loader.load_file('path/to/file',test_field: true)
35
+ entry = Mfs::Entry.where(test_field: true).first
36
+
37
+ # Load all files in a directory structure
38
+ entries = Mfs::Loader.load_directory('path/to/files')
39
+
40
+ # Load all files and set meta-data
41
+ entries = Mfs::Loader.load_directory('path/to/files') do |filename|
42
+ {has_a: filename.include('a')}
43
+ end
44
+
45
+ ```
46
+
17
47
  Limitations
18
48
  -----------
19
49
  * No File Hierarchy
data/lib/mfs.rb CHANGED
@@ -8,7 +8,6 @@ require "mfs/entry"
8
8
 
9
9
 
10
10
  module Mfs
11
- ROOT_DIR = "#{__dir__}/.."
12
- ENV["MONGOID_ENV"] ||= 'development'
13
- Mongoid.load!("#{ROOT_DIR}/config/mongoid.yml")
11
+ ROOT_DIR = "#{File.dirname(File.realpath(__FILE__))}/.."
12
+
14
13
  end
@@ -1,3 +1,3 @@
1
1
  module Mfs
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ module Mfs
4
+ describe "Integration" do
5
+ before do
6
+ Loader.load_directory('spec/fixtures/files') do |filename|
7
+ {even: (filename[-1].to_i % 2 == 0) ? true : false}
8
+ end
9
+ end
10
+
11
+ describe "find even entries" do
12
+ before do
13
+ @entries = Entry.where(even: true)
14
+ end
15
+ subject { @entries }
16
+ its(:count) { should eq 5 }
17
+
18
+ end
19
+
20
+ describe "find odd entries" do
21
+ before do
22
+ @entries = Entry.where(even: false)
23
+ end
24
+ subject { @entries }
25
+ its(:count) { should eq 6 }
26
+ end
27
+ end
28
+ end
@@ -20,6 +20,6 @@ RSpec.configure do |config|
20
20
  end
21
21
  end
22
22
 
23
+ require 'mfs'
23
24
  ENV["MONGOID_ENV"] = 'test'
24
-
25
- require 'mfs'
25
+ Mongoid.load!("#{Mfs::ROOT_DIR}/config/mongoid.yml")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Johson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-11 00:00:00.000000000 Z
12
+ date: 2013-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
@@ -100,6 +100,7 @@ files:
100
100
  - spec/fixtures/files/file8
101
101
  - spec/fixtures/files/file9
102
102
  - spec/fixtures/files/sub/file11
103
+ - spec/integration_spec.rb
103
104
  - spec/loader_spec.rb
104
105
  - spec/mfs_spec.rb
105
106
  - spec/spec_helper.rb
@@ -140,6 +141,7 @@ test_files:
140
141
  - spec/fixtures/files/file8
141
142
  - spec/fixtures/files/file9
142
143
  - spec/fixtures/files/sub/file11
144
+ - spec/integration_spec.rb
143
145
  - spec/loader_spec.rb
144
146
  - spec/mfs_spec.rb
145
147
  - spec/spec_helper.rb