carrierwave-neo4j 0.0.1-java

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.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ db/*
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in carrierwave_neo4j.gemspec
4
+ gemspec
5
+
6
+ gem "ruby-debug"
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = CarrierWave for Neo4j
2
+
3
+ This gem adds support for Neo4j to CarrierWave, see the CarrierWave documentation for more detailed usage instructions.
4
+
5
+ == Installation Instructions
6
+
7
+ gem install carrierwave-neo4j
8
+
9
+ Use it like this:
10
+
11
+ require "carrierwave/neo4j"
12
+
13
+ Using bundler:
14
+
15
+ gem "carrierwave-neo4j", :require => "carrierwave/neo4j"
16
+
17
+ == TODO
18
+
19
+ Add support for CarrierWave validations.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "carrierwave/neo4j/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "carrierwave-neo4j"
7
+ s.version = CarrierWave::Neo4j::VERSION
8
+ s.platform = "java"
9
+ s.authors = ["Rodrigo Navarro"]
10
+ s.email = ["navarro@manapot.com.br"]
11
+ s.homepage = ""
12
+ s.summary = %q{Neo4j support for Carrierwave}
13
+ s.description = %q{Neo4j support for Carrierwave}
14
+
15
+ s.rubyforge_project = "carrierwave_neo4j"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency("neo4j", "~> 1.1")
23
+ s.add_dependency("carrierwave", "~> 0.5")
24
+ s.add_development_dependency("rspec", "~> 2.0")
25
+ end
@@ -0,0 +1,34 @@
1
+ require "carrierwave/neo4j/version"
2
+ require "neo4j"
3
+ require "carrierwave"
4
+
5
+ module CarrierWave
6
+ module Neo4j
7
+ include CarrierWave::Mount
8
+
9
+ ##
10
+ # See +CarrierWave::Mount#mount_uploader+ for documentation
11
+ #
12
+ def mount_uploader(column, uploader = nil, options = {}, &block)
13
+ property column
14
+
15
+ super
16
+
17
+ alias_method :read_uploader, :read_attribute
18
+ alias_method :write_uploader, :write_attribute
19
+
20
+ after_save :"store_#{column}!"
21
+ before_save :"write_#{column}_identifier"
22
+ after_destroy :"remove_#{column}!"
23
+
24
+ class_eval <<-RUBY, __FILE__, __LINE__+1
25
+ def _mounter(column)
26
+ @_mounters ||= {}
27
+ @_mounters[column] ||= CarrierWave::Mount::Mounter.new(self, column)
28
+ end
29
+ RUBY
30
+ end
31
+ end
32
+ end
33
+
34
+ Neo4j::Rails::Model.extend CarrierWave::Neo4j
@@ -0,0 +1,5 @@
1
+ module CarrierWave
2
+ module Neo4j
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
Binary file
@@ -0,0 +1,90 @@
1
+ require "spec_helper"
2
+
3
+ def reset_class(uploader = DefaultUploader)
4
+ class_name = "User"
5
+ Object.send(:remove_const, class_name) rescue nil
6
+ user_class = Object.const_set(class_name, Class.new(Neo4j::Rails::Model))
7
+
8
+ user_class.class_eval do
9
+ mount_uploader :image, uploader
10
+ end
11
+
12
+ user_class
13
+ end
14
+
15
+ class DefaultUploader < CarrierWave::Uploader::Base; end
16
+
17
+ describe CarrierWave::Neo4j do
18
+ let(:user_class) { reset_class }
19
+ let(:user) { user_class.new }
20
+
21
+ after do
22
+ User.destroy_all
23
+ end
24
+
25
+ describe "#image" do
26
+ let(:record) { user_class.new }
27
+ subject { record.image }
28
+
29
+ context "when nothing is assigned" do
30
+ it { should be_blank }
31
+ end
32
+
33
+ context "when an empty string is assigned" do
34
+ before do
35
+ record.image = ""
36
+ record.save
37
+ record.reload
38
+ end
39
+
40
+ it { should be_blank }
41
+ end
42
+
43
+ context "when a filename is stored" do
44
+ before do
45
+ record.image = File.open(file_path("tarja.jpg"))
46
+ record.save
47
+ record.reload
48
+ end
49
+
50
+ it { should be_an_instance_of DefaultUploader }
51
+ its(:current_path) { should == public_path("uploads/tarja.jpg") }
52
+ end
53
+ end
54
+
55
+ describe "#save" do
56
+ context "when remove_image? is true" do
57
+ let(:record) { user_class.new }
58
+
59
+ before do
60
+ Neo4j::Transaction.run do
61
+ record.image = File.open(file_path("tarja.jpg"))
62
+ record.save
63
+
64
+ record.remove_image = true
65
+ record.save # Getting NotInTransactionException here if not wrapped in a transaction block, maybe Neo4j bug?
66
+ record.reload
67
+ end
68
+ end
69
+
70
+ subject { record }
71
+
72
+ its(:image) { should be_blank }
73
+ end
74
+ end
75
+
76
+ describe "#destroy" do
77
+ let(:record) { user_class.new }
78
+
79
+ before do
80
+ record.image = File.open(file_path("tarja.jpg"))
81
+ record.save
82
+ end
83
+
84
+ it "also destroys the image" do
85
+ expect { record.destroy }.to change {
86
+ File.exist? public_path("uploads/tarja.jpg")
87
+ }.from(true).to(false)
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,16 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ require "rspec"
4
+
5
+ require "carrierwave"
6
+ require "carrierwave/neo4j"
7
+
8
+ def file_path(*paths)
9
+ File.expand_path(File.join(File.dirname(__FILE__), "fixtures", *paths))
10
+ end
11
+
12
+ def public_path(*paths)
13
+ File.expand_path(File.join(File.dirname(__FILE__), "public", *paths))
14
+ end
15
+
16
+ CarrierWave.root = public_path
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carrierwave-neo4j
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: java
7
+ authors:
8
+ - Rodrigo Navarro
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-07-02 00:00:00 -03:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: neo4j
18
+ version_requirements: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "1.1"
24
+ requirement: *id001
25
+ prerelease: false
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: carrierwave
29
+ version_requirements: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: "0.5"
35
+ requirement: *id002
36
+ prerelease: false
37
+ type: :runtime
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ version_requirements: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: "2.0"
46
+ requirement: *id003
47
+ prerelease: false
48
+ type: :development
49
+ description: Neo4j support for Carrierwave
50
+ email:
51
+ - navarro@manapot.com.br
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - .gitignore
60
+ - Gemfile
61
+ - README.rdoc
62
+ - Rakefile
63
+ - carrierwave-neo4j.gemspec
64
+ - lib/carrierwave/neo4j.rb
65
+ - lib/carrierwave/neo4j/version.rb
66
+ - spec/fixtures/tarja.jpg
67
+ - spec/neo4j_spec.rb
68
+ - spec/spec_helper.rb
69
+ has_rdoc: true
70
+ homepage: ""
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 2
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 2
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ requirements: []
97
+
98
+ rubyforge_project: carrierwave_neo4j
99
+ rubygems_version: 1.5.1
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: Neo4j support for Carrierwave
103
+ test_files: []
104
+