neo4jrb-paperclip 0.0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 938e84da26cccfcda597a8ef02c46903e056da3a
4
+ data.tar.gz: 83d59d9d5ce6bf7f29dda2e6a4cd8c00afaebdf5
5
+ SHA512:
6
+ metadata.gz: 04562bf3c8f400e23d974ae55174798cd6a21edf7cb1065e5f06da6737c01ec511909bfcf045f6b8b3293ac5a3e3f3be37812bad7504162a61dfa49f8009df22
7
+ data.tar.gz: 6cdb56749bfc3d5969e63498f2b098279fa74ddd66e75da6ff3d3de570d992c52e38b345f5819a3789469946536e8d190f6098c4e2cdb168cfadbd7792890e6c
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2
+ of this software and associated documentation files (the "Software"), to deal
3
+ in the Software without restriction, including without limitation the rights
4
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ copies of the Software, and to permit persons to whom the Software is
6
+ furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in
9
+ all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17
+ THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ Neo4jrb::Paperclip - Making Paperclip play nice with Neo4j.rb 3.0
2
+ ================================================================
3
+
4
+ This gem is based on [mongoid-paperclip 0.0.4](https://github.com/meskyanichi/mongoid-paperclip). It is a fork of Leo Lou's original gem, updated for Neo4j.rb 3.0. It is platform-independent and compatible with Paperclip 4.2.0.
5
+
6
+ As the title suggests: `Neo4jrb::Paperclip` makes it easy to hook up [Paperclip](https://github.com/thoughtbot/paperclip) with [Neo4j.rb](https://github.com/andreasronge/neo4j).
7
+
8
+ This is actually easier and faster to set up than when using Paperclip and the ActiveRecord ORM.
9
+ This example assumes you are using **Ruby on Rails 4** and **Bundler**.
10
+
11
+
12
+ Setting it up
13
+ -------------
14
+
15
+ Simply define the `neo4jrb-paperclip` gem inside your `Gemfile`, pulling from subvertallchris/neo4jrb-paperclip. Additionally, you can define the `aws-sdk` gem if you want to upload your files to Amazon S3. *You do not need to explicitly define the `paperclip` gem itself, since this is handled by `neo4jrb-paperclip`.*
16
+
17
+ **Rails.root/Gemfile - Just define the following:**
18
+
19
+ gem "neo4jrb-paperclip", github: 'subvertallchris/neo4jrb-paperclip', require: "neo4jrb_paperclip"
20
+ gem "aws-s3"
21
+
22
+ Next let's assume we have a User model and we want to allow our users to upload an avatar.
23
+
24
+ **Rails.root/app/models/user.rb - include the Neo4jrb::Paperclip module and invoke the provided class method**
25
+
26
+ class User
27
+ include Neo4j::ActiveNode
28
+ include Neo4jrb::Paperclip
29
+
30
+ has_neo4jrb_attached_file :avatar
31
+ validates_attachment_content_type :avatar, content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"]
32
+ end
33
+
34
+
35
+ That's it
36
+ --------
37
+
38
+ More or less. See [Paperclip's documentation](https://github.com/thoughtbot/paperclip/wiki) for additional instructions.
39
+ Invoking the `has_neo4jrb_attached_file` method will automatically define the necessary `:avatar` fields for you in the background.
40
+
41
+ Known issues
42
+ ------------
43
+
44
+ File size returns 0 - [paperclip issue](https://github.com/thoughtbot/paperclip/issues/100)
45
+
46
+ Related Links
47
+ ------------
48
+
49
+ * [mongoid-paperclip](https://github.com/meskyanichi/mongoid-paperclip)
50
+ * [Neo4j.rb](https://github.com/andreasronge/neo4j)
51
+ * [Paperclip](https://github.com/thoughtbot/paperclip)
@@ -0,0 +1,110 @@
1
+ # encoding: utf-8
2
+
3
+ begin
4
+ require "paperclip"
5
+ rescue LoadError
6
+ puts "Neo4jrb::Paperclip requires that you install the Paperclip gem."
7
+ exit
8
+ end
9
+
10
+ ##
11
+ # TODO
12
+ # Fix this
13
+ module Paperclip
14
+ class << self
15
+ # def logger
16
+ # Neo4j::Config[:logger]
17
+ # end
18
+ end
19
+ end
20
+
21
+
22
+ ##
23
+ # The Neo4jrb::Paperclip extension
24
+ # Makes Paperclip play nice with the Neo4j Models
25
+ #
26
+ # Example:
27
+ #
28
+ # class User
29
+ # include Neo4j::ActiveNode
30
+ # include Neo4jrb::Paperclip
31
+ #
32
+ # has_neo4jrb_attached_file :avatar
33
+ # validates_attachment_content_type :avatar, content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"]
34
+ # end
35
+ #
36
+ # The above example is all you need to do. This will load the Paperclip library into the User model
37
+ # and add the "has_neo4jrb_attached_file" class method. Provide this method with the same values as you would
38
+ # when using "vanilla Paperclip". The first parameter is a symbol [:field] and the second parameter is a hash of options [options = {}].
39
+ # Note that the validation must come after the call to :has_neo4jrb_attached_file.
40
+ #
41
+ # Unlike Paperclip for ActiveRecord, since MongoDB does not use "schema" or "migrations", Neo4jrb::Paperclip automatically adds the neccesary "fields"
42
+ # to your Model (MongoDB collection) when you invoke the "#has_neo4jrb_attached_file" method. When you invoke "has_neo4jrb_attached_file :avatar" it will
43
+ # automatially add the following fields:
44
+ #
45
+ # field :avatar_file_name, :type => String
46
+ # field :avatar_content_type, :type => String
47
+ # field :avatar_file_size, :type => Fixnum
48
+ # field :avatar_updated_at, :type => DateTime
49
+ #
50
+ module Neo4jrb
51
+ module Paperclip
52
+ extend ActiveSupport::Concern
53
+ include ::Paperclip::Validators
54
+
55
+ module ClassMethods
56
+
57
+ ##
58
+ # Adds after_commit
59
+ def after_commit(*args, &block)
60
+ options = args.pop if args.last.is_a? Hash
61
+ if options
62
+ case options[:on]
63
+ when :create
64
+ after_create(*args, &block)
65
+ when :update
66
+ after_update(*args, &block)
67
+ when :destroy
68
+ after_destroy(*args, &block)
69
+ else
70
+ after_save(*args, &block)
71
+ end
72
+ else
73
+ after_save(*args, &block)
74
+ end
75
+ end
76
+
77
+ ##
78
+ # Adds Neo4jrb::Paperclip's "#has_neo4jrb_attached_file" class method to the model
79
+ # which includes Paperclip and Paperclip::Glue in to the model. Additionally
80
+ # it'll also add the required fields for Paperclip since MongoDB is schemaless and doesn't
81
+ # have migrations.
82
+ def has_neo4jrb_attached_file(field, options = {})
83
+
84
+ ##
85
+ # Include Paperclip and Paperclip::Glue for compatibility
86
+ include ::Paperclip
87
+ include ::Paperclip::Glue
88
+
89
+ ##
90
+ # Invoke Paperclip's #has_attached_file method and passes in the
91
+ # arguments specified by the user that invoked Neo4jrb::Paperclip#has_neo4jrb_attached_file
92
+ has_attached_file(field, options)
93
+
94
+ ##
95
+ # Define the necessary collection fields in Neo4jrb for Paperclip
96
+ property :"#{field}_file_name", type: String
97
+ property :"#{field}_content_type", type: String
98
+ property :"#{field}_file_size", type: Integer
99
+ property :"#{field}_updated_at", type: DateTime
100
+ end
101
+
102
+ ##
103
+ # This method is deprecated
104
+ def has_attached_file(field, options = {})
105
+ raise "Neo4jrb::Paperclip#has_attached_file is deprecated, " +
106
+ "Use 'has_neo4jrb_attached_file' instead"
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |gem|
4
+
5
+ gem.name = 'neo4jrb-paperclip'
6
+ gem.version = '0.0.2.2'
7
+ gem.authors = 'Leo Lou, Chris Grigg'
8
+ gem.email = 'louyuhong@gmail.com, chris@subvertallmedia.com'
9
+ gem.homepage = 'https://github.com/subvertallchris/neo4jrb-paperclip'
10
+ gem.summary = 'Neo4jrb::Paperclip enables you to use Paperclip with Neo4j.rb'
11
+ gem.description = 'Neo4jrb::Paperclip enables you to use Paperclip with Neo4j.rb'
12
+ gem.license = 'MIT'
13
+
14
+ gem.files = %x[git ls-files].split("\n")
15
+ gem.test_files = %x[git ls-files -- {spec}/*].split("\n")
16
+ gem.require_path = 'lib'
17
+
18
+ gem.add_dependency 'neo4j', ['~> 3.0.0.alpha.8']
19
+ gem.add_dependency 'paperclip', ['~> 4.0']
20
+
21
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: neo4jrb-paperclip
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Leo Lou, Chris Grigg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: neo4j
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0.alpha.8
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0.alpha.8
27
+ - !ruby/object:Gem::Dependency
28
+ name: paperclip
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ description: Neo4jrb::Paperclip enables you to use Paperclip with Neo4j.rb
42
+ email: louyuhong@gmail.com, chris@subvertallmedia.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - Gemfile
48
+ - LICENSE
49
+ - README.md
50
+ - lib/neo4jrb_paperclip.rb
51
+ - neo4jrb-paperclip.gemspec
52
+ homepage: https://github.com/subvertallchris/neo4jrb-paperclip
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.2.2
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Neo4jrb::Paperclip enables you to use Paperclip with Neo4j.rb
76
+ test_files: []
77
+ has_rdoc: