jackfs 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1adb2ee202121672a4c032527c8b110bc22816bf
4
+ data.tar.gz: 489f57250cfd03e51e8652fb0e721d884cbc7152
5
+ SHA512:
6
+ metadata.gz: 5b66beb56388bd7e149ad15fa5b5dc42e3b731b60963fca05de3688fb6d74e2c7d96716d5aafa764136651487b89b37c1b568b9991aa1da64c0e5c37d0ae36c3
7
+ data.tar.gz: 06bb0db9aa6ba017ca6d4d76e90a05d5bcdc8fc70c898e7fad55a6330f63d6ad350a90b0ddd9f2bdbf2171a9123230acb1495b34c1dc19a87f679398eeec35df
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ spec/tmp
data/Manifest CHANGED
@@ -5,11 +5,9 @@ Rakefile
5
5
  init.rb
6
6
  lib/jackfs/file_store.rb
7
7
  lib/jackfs/adapters/db_adapter.rb
8
- lib/jackfs/adapters/s3_adapter.rb
9
8
  lib/jackfs/adapters/file_adapter.rb
10
9
  spec/adapters/db_adapter_spec.rb
11
10
  spec/adapters/file_adapter_spec.rb
12
- spec/adapters/s3_adapter_spec.rb
13
11
 
14
12
  jackfs.gemspec
15
13
  spec/jackfs.rb
data/README.md CHANGED
@@ -3,14 +3,14 @@
3
3
  Is a rails 3 file store plugin, that allows you to create a simple file store system
4
4
  that can point to disk, s3, or database based on your configuration file.
5
5
 
6
- This allows you to implement the storage using a simple api. The plugin is
6
+ This allows you to implement the storage using a simple api. The plugin is
7
7
  adapter driven, so you can create additional adapters to use for this Jackfs
8
8
  system.
9
9
 
10
10
  ## Install
11
11
 
12
12
  rails plugin install git://github.com/jackhq/jackfs.git
13
-
13
+
14
14
  ## Configure
15
15
 
16
16
  * If File Adapter your config/filestore.yml would look like this
@@ -18,25 +18,18 @@ system.
18
18
  production:
19
19
  location: tmp
20
20
  adapter: file
21
-
22
-
21
+
22
+
23
23
  * If Db Adapter your config/filestore.yml would look like this
24
24
 
25
25
  production:
26
26
  connection: sqlite://production.db
27
27
  adapter: db
28
28
  table_name: jackfs
29
-
30
- ** It is important to note that it uses the sequel toolkit to connect to the database. The connection setting must be a valid sequel toolkit connection string.
31
29
 
32
- * If S3 Adapter your config/filestore.yml would look like this
33
-
34
- production:
35
- adapter: s3
36
- bucket: jackhq
37
- access_key: ACCESS KEY
38
- secret_key: SECRET KEY
30
+ ** It is important to note that it uses the sequel toolkit to connect to the database. The connection setting must be a valid sequel toolkit connection string.
39
31
 
32
+ S3 adapter removed in this version.
40
33
  ---
41
34
 
42
35
  # Report any problems to team@jackrussellsoftware.com
data/Rakefile CHANGED
@@ -1,2 +1,3 @@
1
1
  require 'bundler'
2
+
2
3
  Bundler::GemHelper.install_tasks
data/jackfs.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_runtime_dependency 'sequel'
23
- s.add_runtime_dependency 'aws-s3'
22
+ s.add_runtime_dependency 'sqlite3', '>= 1.0.0'
23
+ s.add_runtime_dependency 'sequel', '>= 4.0.0'
24
+ s.add_development_dependency 'rspec', '>= 3.0'
24
25
  end
@@ -5,7 +5,6 @@ rescue LoadError
5
5
  end
6
6
 
7
7
  require File.dirname(__FILE__) + '/adapters/file_adapter'
8
- require File.dirname(__FILE__) + '/adapters/s3_adapter'
9
8
  require File.dirname(__FILE__) + '/adapters/db_adapter'
10
9
 
11
10
  module Jackfs
@@ -39,7 +38,6 @@ module Jackfs
39
38
  def load_adapter
40
39
  adapter_type = YAML.load_file(File.join(@app_root,CONFIG_FILE))[@app_env.to_s]["adapter"].to_sym
41
40
  case adapter_type
42
- when :s3 then Jackfs::S3Adapter.new(@app_root, @app_env)
43
41
  when :db then Jackfs::DbAdapter.new(@app_root, @app_env)
44
42
  else Jackfs::FileAdapter.new(@app_root, @app_env)
45
43
  end
@@ -1,3 +1,3 @@
1
1
  module Jackfs
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -9,12 +9,12 @@ describe "Jackfs Db Adapter" do
9
9
  "connection" => 'sqlite://test.db',
10
10
  "table_name" => 'jackfs'
11
11
  })
12
-
12
+
13
13
  root = File.dirname(__FILE__) + '/..'
14
14
  @dba = Jackfs::DbAdapter.new(root, :test)
15
15
  end
16
16
 
17
-
17
+
18
18
  it "should save a file to a configured database name" do
19
19
  @dba.connection.should == 'sqlite://test.db'
20
20
  end
@@ -27,25 +27,25 @@ describe "Jackfs Db Adapter" do
27
27
  it "should save the file in db using the given name" do
28
28
  @dba.store(File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r'),"COOLBEANS").should eq("COOLBEANS")
29
29
  end
30
-
30
+
31
31
  it "should allow connection string with odd characters" do
32
32
  @dba.connection = "sqlite://root:abc!#%@test.db"
33
33
  @dba.uri_escape(@dba.connection).should eq("sqlite://root:abc!%23%25@test.db")
34
34
  end
35
-
35
+
36
36
  it "should throw an error when connection string is bad URI" do
37
- URI.stub!(:escape).and_raise(Exception)
37
+ URI.stub(:escape).and_raise(Exception)
38
38
  $stdout.should_receive(:puts).with('Error encountered when parsing sqlite://test.db - Exception')
39
- @dba.uri_escape(@dba.connection)
39
+ @dba.uri_escape(@dba.connection)
40
40
  end
41
41
 
42
42
  # it "should get a file from a configured from db" do
43
43
  # f = File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r')
44
44
  # @dba.store(f, "COOLBEANS")
45
45
  # orig = File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r')
46
- #
47
- # @dba.get("COOLBEANS").read.length.should == orig.read.length
46
+ #
47
+ # @dba.get("COOLBEANS").read.length.should == orig.read.length
48
48
  # end
49
-
50
-
49
+
50
+
51
51
  end
@@ -8,22 +8,22 @@ describe "Jackfs File Adapter" do
8
8
  "location" => 'tmp'
9
9
  })
10
10
  root = File.dirname(__FILE__) + '/..'
11
-
11
+
12
12
  @fa = Jackfs::FileAdapter.new(root, :test)
13
13
  end
14
-
14
+
15
15
  it "should save a file to a configured location" do
16
- Jackfs::FileAdapter.should be_true
16
+ Jackfs::FileAdapter.should be_truthy
17
17
  @fa.location.should == "tmp"
18
18
  end
19
-
19
+
20
20
  it "should save the file in the location using the given name" do
21
- @fa.store(File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r'),"COOLBEANS").should == true
21
+ @fa.store(File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r'),"COOLBEANS").should == "COOLBEANS"
22
22
  end
23
23
 
24
24
  it "should get a file from a configured location" do
25
25
  f = File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r')
26
- @fa.store(File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r'),"COOLBEANS").should == true
26
+ @fa.store(File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r'),"COOLBEANS").should == "COOLBEANS"
27
27
  orig = File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r')
28
28
  @fa.get("COOLBEANS").read.length.should == orig.read.length
29
29
  end
metadata CHANGED
@@ -1,61 +1,65 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jackfs
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Jack Russell Software
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-04-23 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: sequel
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sqlite3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
26
17
  - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
32
20
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: aws-s3
36
21
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
40
24
  - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sequel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 4.0.0
46
34
  type: :runtime
47
- version_requirements: *id002
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
48
55
  description: This is an description for the fs gem we use
49
- email:
56
+ email:
50
57
  - team@jackrussellsoftware.com
51
58
  executables: []
52
-
53
59
  extensions: []
54
-
55
60
  extra_rdoc_files: []
56
-
57
- files:
58
- - .gitignore
61
+ files:
62
+ - ".gitignore"
59
63
  - CHANGELOG
60
64
  - Gemfile
61
65
  - Manifest
@@ -66,51 +70,38 @@ files:
66
70
  - lib/jackfs.rb
67
71
  - lib/jackfs/adapters/db_adapter.rb
68
72
  - lib/jackfs/adapters/file_adapter.rb
69
- - lib/jackfs/adapters/s3_adapter.rb
70
73
  - lib/jackfs/errors.rb
71
74
  - lib/jackfs/file_store.rb
72
75
  - lib/jackfs/version.rb
73
76
  - spec/adapters/db_adapter_spec.rb
74
77
  - spec/adapters/file_adapter_spec.rb
75
- - spec/adapters/s3_adapter_spec.rb
76
78
  - spec/fixtures/test.pdf
77
79
  - spec/spec_helper.rb
78
- homepage: ""
80
+ homepage: ''
79
81
  licenses: []
80
-
82
+ metadata: {}
81
83
  post_install_message:
82
84
  rdoc_options: []
83
-
84
- require_paths:
85
+ require_paths:
85
86
  - lib
86
- required_ruby_version: !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
89
  - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
93
- - 0
94
- version: "0"
95
- required_rubygems_version: !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
98
94
  - - ">="
99
- - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
- version: "0"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
104
97
  requirements: []
105
-
106
98
  rubyforge_project: jackfs
107
- rubygems_version: 1.8.23
99
+ rubygems_version: 2.6.6
108
100
  signing_key:
109
- specification_version: 3
101
+ specification_version: 4
110
102
  summary: This is a fs gem we use
111
- test_files:
103
+ test_files:
112
104
  - spec/adapters/db_adapter_spec.rb
113
105
  - spec/adapters/file_adapter_spec.rb
114
- - spec/adapters/s3_adapter_spec.rb
115
106
  - spec/fixtures/test.pdf
116
107
  - spec/spec_helper.rb
@@ -1,72 +0,0 @@
1
- require 'fileutils'
2
-
3
- begin
4
- require 'aws/s3'
5
- rescue LoadError
6
- puts 'aws-s3 gem is required to use file store'
7
- end
8
-
9
- module Jackfs
10
- class S3Adapter
11
-
12
- TEMP_PATH = File.join('tmp','fs_cache')
13
-
14
- attr_accessor :access_key, :secret_key, :bucket, :app_root, :app_env
15
-
16
- def initialize(app_root, app_env)
17
- @app_root = app_root
18
- @app_env = app_env
19
-
20
- FileUtils.mkdir_p(full_temp_path)
21
-
22
- yml = YAML.load_file(config_file)[@app_env.to_s]
23
- @access_key = yml["access_key"]
24
- @secret_key = yml["secret_key"]
25
- @bucket = yml["bucket"]
26
-
27
- # Clean up temp files
28
- FileUtils.remove_file(File.join(full_temp_path,'/*'), true)
29
-
30
- end
31
-
32
- def store(f, name)
33
- find_or_create_bucket
34
- AWS::S3::S3Object.store(name, f, @bucket)
35
- name
36
- end
37
-
38
- def get(name)
39
- unique_name = UUIDTools::UUID.random_create.to_s
40
- # Write Body to generated tmp file
41
- open(File.join(full_temp_path, unique_name), 'wb') do |file|
42
- AWS::S3::S3Object.stream(name, @bucket) do |chunk|
43
- file.write chunk
44
- end
45
- end
46
- # Open and return Temp File
47
- open(File.join(full_temp_path,unique_name), 'rb')
48
- end
49
-
50
- def establish_connection
51
- AWS::S3::Base.establish_connection!(
52
- :access_key_id => @access_key,
53
- :secret_access_key => @secret_key
54
- )
55
- end
56
-
57
- def find_or_create_bucket
58
- establish_connection
59
- AWS::S3::Bucket.create(@bucket) unless bucket = AWS::S3::Bucket.find(@bucket)
60
- true
61
- end
62
-
63
- def full_temp_path
64
- File.join(@app_root, TEMP_PATH)
65
- end
66
-
67
- def config_file
68
- File.join(@app_root, Jackfs::FileStore::CONFIG_FILE)
69
- end
70
-
71
- end
72
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
- require File.dirname(__FILE__) + '/../spec_helper'
3
-
4
-
5
- describe "JackFS S3 Adapter" do
6
- before(:each) do
7
- root = File.dirname(__FILE__) + '/..'
8
- YAML.should_receive(:load_file).and_return("test" => {
9
- "adapter" => "s3",
10
- "bucket" => 'jackhq',
11
- "access_key" => ENV['AMAZON_ACCESS_KEY_ID'],
12
- "secret_key" => ENV['AMAZON_SECRET_ACCESS_KEY']
13
- })
14
-
15
- @s3a = Jackfs::S3Adapter.new(root, :test)
16
-
17
- end
18
-
19
- it "should save a file to a configured access key" do
20
- @s3a.access_key.should == ENV['AMAZON_ACCESS_KEY_ID']
21
- end
22
-
23
- it "should save a file to a configured secret key" do
24
- @s3a.secret_key.should == ENV['AMAZON_SECRET_ACCESS_KEY']
25
- end
26
-
27
- it "should save a file to a configured secret key" do
28
- @s3a.bucket.should == "jackhq"
29
- end
30
-
31
- it "should establish a connection to s3" do
32
- AWS::S3::Base.stub!(:establish_connection!).and_return(true)
33
- @s3a.establish_connection.should == true
34
- end
35
-
36
- it "should create a bucket if a bucket does not exist" do
37
- AWS::S3::Bucket.should_receive(:find).and_return(false)
38
- AWS::S3::Bucket.should_receive(:create).and_return(true)
39
- @s3a.find_or_create_bucket.should be_true
40
-
41
- end
42
-
43
- it "should find a bucket if a bucket does exist" do
44
- AWS::S3::Bucket.should_receive(:find).and_return(true)
45
- @s3a.find_or_create_bucket.should be_true
46
- end
47
-
48
- it "should save the file in s3 using the given name" do
49
- @s3a.should_receive(:find_or_create_bucket).and_return(true)
50
- AWS::S3::S3Object.should_receive(:store).and_return(true)
51
- @s3a.store(File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r'),"COOLBEANS").should == true
52
- end
53
-
54
- it "should get a file from a configured from s3" do
55
- f = File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r')
56
- #AWS::S3::S3Object.should_receive(:stream).and_return(f)
57
- @s3a.store(File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r'),"COOLBEANS").should == true
58
- @s3a.get("COOLBEANS").read.length.should == f.read.length
59
- end
60
-
61
- end