jcouchbase 0.1.1
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/Gemfile +4 -0
 - data/README.md +4 -0
 - data/Rakefile +131 -0
 - data/jcouchbase.gemspec +40 -0
 - data/lib/jcouchbase/jars/commons-codec-1.5.jar +0 -0
 - data/lib/jcouchbase/jars/commons-codec-1.6.jar +0 -0
 - data/lib/jcouchbase/jars/commons-logging-1.1.1.jar +0 -0
 - data/lib/jcouchbase/jars/couchbase-client-1.0.2.jar +0 -0
 - data/lib/jcouchbase/jars/fluent-hc-4.2.1.jar +0 -0
 - data/lib/jcouchbase/jars/httpclient-4.2.1.jar +0 -0
 - data/lib/jcouchbase/jars/httpclient-cache-4.2.1.jar +0 -0
 - data/lib/jcouchbase/jars/httpcore-4.2.1.jar +0 -0
 - data/lib/jcouchbase/jars/httpcore-ab-4.2.1.jar +0 -0
 - data/lib/jcouchbase/jars/httpcore-nio-4.2.1.jar +0 -0
 - data/lib/jcouchbase/jars/httpmime-4.2.1.jar +0 -0
 - data/lib/jcouchbase/jars/jettison-1.1.jar +0 -0
 - data/lib/jcouchbase/jars/netty-3.2.0.Final.jar +0 -0
 - data/lib/jcouchbase/jars/spymemcached-2.8.0.jar +0 -0
 - data/lib/jcouchbase/jcouchbase.rb +112 -0
 - data/lib/jcouchbase/version.rb +3 -0
 - data/lib/jcouchbase.rb +26 -0
 - metadata +82 -0
 
    
        data/Gemfile
    ADDED
    
    
    
        data/README.md
    ADDED
    
    
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,131 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'date'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rspec/core/rake_task'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #############################################################################
         
     | 
| 
      
 5 
     | 
    
         
            +
            #
         
     | 
| 
      
 6 
     | 
    
         
            +
            # Helper functions
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            #############################################################################
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            def name
         
     | 
| 
      
 11 
     | 
    
         
            +
              @name ||= Dir['*.gemspec'].first.split('.').first
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            def version
         
     | 
| 
      
 15 
     | 
    
         
            +
              line = File.read("lib/#{name}/version.rb")[/^\s*VERSION\s*=\s*.*/]
         
     | 
| 
      
 16 
     | 
    
         
            +
              line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            def date
         
     | 
| 
      
 20 
     | 
    
         
            +
              Date.today.to_s
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            def rubyforge_project
         
     | 
| 
      
 24 
     | 
    
         
            +
              name
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            def gemspec_file
         
     | 
| 
      
 28 
     | 
    
         
            +
              "#{name}.gemspec"
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            def gem_file
         
     | 
| 
      
 32 
     | 
    
         
            +
              "#{name}-#{version}.gem"
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            def replace_header(head, header_name)
         
     | 
| 
      
 36 
     | 
    
         
            +
              head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
         
     | 
| 
      
 37 
     | 
    
         
            +
            end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            def jruby?
         
     | 
| 
      
 40 
     | 
    
         
            +
              RUBY_PLATFORM.to_s == 'java'
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            #############################################################################
         
     | 
| 
      
 44 
     | 
    
         
            +
            #
         
     | 
| 
      
 45 
     | 
    
         
            +
            # Custom tasks
         
     | 
| 
      
 46 
     | 
    
         
            +
            #
         
     | 
| 
      
 47 
     | 
    
         
            +
            #############################################################################
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            default_rspec_opts = %w[--colour --format Fuubar]
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            desc "Run all examples"
         
     | 
| 
      
 52 
     | 
    
         
            +
            RSpec::Core::RakeTask.new(:spec) do |t|
         
     | 
| 
      
 53 
     | 
    
         
            +
              t.rspec_opts = default_rspec_opts
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            #############################################################################
         
     | 
| 
      
 57 
     | 
    
         
            +
            #
         
     | 
| 
      
 58 
     | 
    
         
            +
            # Packaging tasks
         
     | 
| 
      
 59 
     | 
    
         
            +
            #
         
     | 
| 
      
 60 
     | 
    
         
            +
            #############################################################################
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
         
     | 
| 
      
 63 
     | 
    
         
            +
            task :release => :build do
         
     | 
| 
      
 64 
     | 
    
         
            +
              unless `git branch` =~ /^\* master$/
         
     | 
| 
      
 65 
     | 
    
         
            +
                puts "You must be on the master branch to release!"
         
     | 
| 
      
 66 
     | 
    
         
            +
                exit!
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
              sh "git commit --allow-empty -a -m 'Release #{version}'"
         
     | 
| 
      
 69 
     | 
    
         
            +
              sh "git tag v#{version}"
         
     | 
| 
      
 70 
     | 
    
         
            +
              sh "git push origin master"
         
     | 
| 
      
 71 
     | 
    
         
            +
              sh "git push origin v#{version}"
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
              command = "gem push pkg/#{name}-#{version}.gem"
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
              if jruby?
         
     | 
| 
      
 76 
     | 
    
         
            +
                puts "--------------------------------------------------------------------------------------"
         
     | 
| 
      
 77 
     | 
    
         
            +
                puts "can't push to rubygems using jruby at the moment, so switch to mri and run: #{command}"
         
     | 
| 
      
 78 
     | 
    
         
            +
                puts "--------------------------------------------------------------------------------------"
         
     | 
| 
      
 79 
     | 
    
         
            +
              else
         
     | 
| 
      
 80 
     | 
    
         
            +
                sh command
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
            end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
            desc "Build #{gem_file} into the pkg directory"
         
     | 
| 
      
 85 
     | 
    
         
            +
            task :build => :gemspec do
         
     | 
| 
      
 86 
     | 
    
         
            +
              sh "mkdir -p pkg"
         
     | 
| 
      
 87 
     | 
    
         
            +
              sh "gem build #{gemspec_file}"
         
     | 
| 
      
 88 
     | 
    
         
            +
              sh "mv #{gem_file} pkg"
         
     | 
| 
      
 89 
     | 
    
         
            +
            end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            desc "Generate #{gemspec_file}"
         
     | 
| 
      
 92 
     | 
    
         
            +
            task :gemspec => :validate do
         
     | 
| 
      
 93 
     | 
    
         
            +
              # read spec file and split out manifest section
         
     | 
| 
      
 94 
     | 
    
         
            +
              spec = File.read(gemspec_file)
         
     | 
| 
      
 95 
     | 
    
         
            +
              head, manifest, tail = spec.split("  # = MANIFEST =\n")
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
              # replace name version and date
         
     | 
| 
      
 98 
     | 
    
         
            +
              replace_header(head, :name)
         
     | 
| 
      
 99 
     | 
    
         
            +
              replace_header(head, :version)
         
     | 
| 
      
 100 
     | 
    
         
            +
              replace_header(head, :date)
         
     | 
| 
      
 101 
     | 
    
         
            +
              #comment this out if your rubyforge_project has a different name
         
     | 
| 
      
 102 
     | 
    
         
            +
              #replace_header(head, :rubyforge_project)
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
              # determine file list from git ls-files
         
     | 
| 
      
 105 
     | 
    
         
            +
              files = `git ls-files`.
         
     | 
| 
      
 106 
     | 
    
         
            +
                split("\n").
         
     | 
| 
      
 107 
     | 
    
         
            +
                sort.
         
     | 
| 
      
 108 
     | 
    
         
            +
                reject { |file| file =~ /^\./ }.
         
     | 
| 
      
 109 
     | 
    
         
            +
                reject { |file| file =~ /^(rdoc|pkg)/ }.
         
     | 
| 
      
 110 
     | 
    
         
            +
                map { |file| "    #{file}" }.
         
     | 
| 
      
 111 
     | 
    
         
            +
                join("\n")
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
              # piece file back together and write
         
     | 
| 
      
 114 
     | 
    
         
            +
              manifest = "  s.files = %w[\n#{files}\n  ]\n"
         
     | 
| 
      
 115 
     | 
    
         
            +
              spec = [head, manifest, tail].join("  # = MANIFEST =\n")
         
     | 
| 
      
 116 
     | 
    
         
            +
              File.open(gemspec_file, 'w') { |io| io.write(spec) }
         
     | 
| 
      
 117 
     | 
    
         
            +
              puts "Updated #{gemspec_file}"
         
     | 
| 
      
 118 
     | 
    
         
            +
            end
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            desc "Validate #{gemspec_file}"
         
     | 
| 
      
 121 
     | 
    
         
            +
            task :validate do
         
     | 
| 
      
 122 
     | 
    
         
            +
              libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
         
     | 
| 
      
 123 
     | 
    
         
            +
              unless libfiles.empty?
         
     | 
| 
      
 124 
     | 
    
         
            +
                puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
         
     | 
| 
      
 125 
     | 
    
         
            +
                exit!
         
     | 
| 
      
 126 
     | 
    
         
            +
              end
         
     | 
| 
      
 127 
     | 
    
         
            +
              unless Dir['VERSION*'].empty?
         
     | 
| 
      
 128 
     | 
    
         
            +
                puts "A `VERSION` file at root level violates Gem best practices."
         
     | 
| 
      
 129 
     | 
    
         
            +
                exit!
         
     | 
| 
      
 130 
     | 
    
         
            +
              end
         
     | 
| 
      
 131 
     | 
    
         
            +
            end
         
     | 
    
        data/jcouchbase.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 2 
     | 
    
         
            +
              s.name              = 'jcouchbase'
         
     | 
| 
      
 3 
     | 
    
         
            +
              s.version           = '0.1.1'
         
     | 
| 
      
 4 
     | 
    
         
            +
              s.date              = '2012-08-28'
         
     | 
| 
      
 5 
     | 
    
         
            +
              s.platform          = Gem::Platform::RUBY
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.authors           = ["Jeremy J Brenner"]
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.email             = ["jeremyjbrenner@gmail.com"]
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.summary           = "Thin ruby wrapper around Couchbase Java Driver; for JRuby only"
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.description       = %q{Thin jruby wrapper around Couchbase Java Driver}
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.homepage          = 'http://github.com/jeremy-brenner/jcouchbase'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              # = MANIFEST =
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.files = %w[
         
     | 
| 
      
 14 
     | 
    
         
            +
                Gemfile
         
     | 
| 
      
 15 
     | 
    
         
            +
                README.md
         
     | 
| 
      
 16 
     | 
    
         
            +
                Rakefile
         
     | 
| 
      
 17 
     | 
    
         
            +
                jcouchbase.gemspec
         
     | 
| 
      
 18 
     | 
    
         
            +
                lib/jcouchbase.rb
         
     | 
| 
      
 19 
     | 
    
         
            +
                lib/jcouchbase/jars/commons-codec-1.5.jar
         
     | 
| 
      
 20 
     | 
    
         
            +
                lib/jcouchbase/jars/commons-codec-1.6.jar
         
     | 
| 
      
 21 
     | 
    
         
            +
                lib/jcouchbase/jars/commons-logging-1.1.1.jar
         
     | 
| 
      
 22 
     | 
    
         
            +
                lib/jcouchbase/jars/couchbase-client-1.0.2.jar
         
     | 
| 
      
 23 
     | 
    
         
            +
                lib/jcouchbase/jars/fluent-hc-4.2.1.jar
         
     | 
| 
      
 24 
     | 
    
         
            +
                lib/jcouchbase/jars/httpclient-4.2.1.jar
         
     | 
| 
      
 25 
     | 
    
         
            +
                lib/jcouchbase/jars/httpclient-cache-4.2.1.jar
         
     | 
| 
      
 26 
     | 
    
         
            +
                lib/jcouchbase/jars/httpcore-4.2.1.jar
         
     | 
| 
      
 27 
     | 
    
         
            +
                lib/jcouchbase/jars/httpcore-ab-4.2.1.jar
         
     | 
| 
      
 28 
     | 
    
         
            +
                lib/jcouchbase/jars/httpcore-nio-4.2.1.jar
         
     | 
| 
      
 29 
     | 
    
         
            +
                lib/jcouchbase/jars/httpmime-4.2.1.jar
         
     | 
| 
      
 30 
     | 
    
         
            +
                lib/jcouchbase/jars/jettison-1.1.jar
         
     | 
| 
      
 31 
     | 
    
         
            +
                lib/jcouchbase/jars/netty-3.2.0.Final.jar
         
     | 
| 
      
 32 
     | 
    
         
            +
                lib/jcouchbase/jars/spymemcached-2.8.0.jar
         
     | 
| 
      
 33 
     | 
    
         
            +
                lib/jcouchbase/jcouchbase.rb
         
     | 
| 
      
 34 
     | 
    
         
            +
                lib/jcouchbase/version.rb
         
     | 
| 
      
 35 
     | 
    
         
            +
              ]
         
     | 
| 
      
 36 
     | 
    
         
            +
              # = MANIFEST =
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              s.add_dependency 'require_all',                 '~> 1.2'
         
     | 
| 
      
 39 
     | 
    
         
            +
              
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         @@ -0,0 +1,112 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Copyright (C) 2012 Jeremy Brenner
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
      
 4 
     | 
    
         
            +
            # you may not use this file except in coSmpliance with the License.
         
     | 
| 
      
 5 
     | 
    
         
            +
            # You may obtain a copy of the License at
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            #     http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
      
 8 
     | 
    
         
            +
            #
         
     | 
| 
      
 9 
     | 
    
         
            +
            # Unless required by applicable law or agreed to in writing, software
         
     | 
| 
      
 10 
     | 
    
         
            +
            # distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 
      
 11 
     | 
    
         
            +
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         
     | 
| 
      
 12 
     | 
    
         
            +
            # See the License for the specific language governing permissions and
         
     | 
| 
      
 13 
     | 
    
         
            +
            # limitations under the License.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            class Couchbase
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              include_class java.io.IOException
         
     | 
| 
      
 18 
     | 
    
         
            +
              include_class java.net.SocketAddress
         
     | 
| 
      
 19 
     | 
    
         
            +
              include_class java.net.URI
         
     | 
| 
      
 20 
     | 
    
         
            +
              include_class java.net.URISyntaxException
         
     | 
| 
      
 21 
     | 
    
         
            +
              include_class java.util.ArrayList
         
     | 
| 
      
 22 
     | 
    
         
            +
              include_class java.util.LinkedList
         
     | 
| 
      
 23 
     | 
    
         
            +
              include_class java.util.List
         
     | 
| 
      
 24 
     | 
    
         
            +
              include_class java.util.concurrent.Future
         
     | 
| 
      
 25 
     | 
    
         
            +
              include_class java.util.concurrent.TimeUnit
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              include_class javax.naming.ConfigurationException
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              include_class Java::net.spy.memcached.CASMutation
         
     | 
| 
      
 30 
     | 
    
         
            +
              include_class Java::net.spy.memcached.CASMutator
         
     | 
| 
      
 31 
     | 
    
         
            +
              include_class Java::net.spy.memcached.CASResponse
         
     | 
| 
      
 32 
     | 
    
         
            +
              include_class Java::net.spy.memcached.CASValue
         
     | 
| 
      
 33 
     | 
    
         
            +
              include_class Java::net.spy.memcached.CachedData
         
     | 
| 
      
 34 
     | 
    
         
            +
              include_class Java::net.spy.memcached.ConnectionObserver
         
     | 
| 
      
 35 
     | 
    
         
            +
              include_class Java::net.spy.memcached.transcoders.SerializingTranscoder
         
     | 
| 
      
 36 
     | 
    
         
            +
              include_class Java::net.spy.memcached.transcoders.Transcoder
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              include_class Java::org.apache.http.HttpEntity
         
     | 
| 
      
 39 
     | 
    
         
            +
              include_class Java::org.apache.http.HttpEntityEnclosingRequest
         
     | 
| 
      
 40 
     | 
    
         
            +
              include_class Java::org.apache.http.HttpHost
         
     | 
| 
      
 41 
     | 
    
         
            +
              include_class Java::org.apache.http.HttpRequest
         
     | 
| 
      
 42 
     | 
    
         
            +
              include_class Java::org.apache.http.HttpResponse
         
     | 
| 
      
 43 
     | 
    
         
            +
              include_class Java::org.apache.http.HttpStatus
         
     | 
| 
      
 44 
     | 
    
         
            +
              include_class Java::org.apache.http.ProtocolVersion
         
     | 
| 
      
 45 
     | 
    
         
            +
              include_class Java::org.apache.http.client.ClientProtocolException
         
     | 
| 
      
 46 
     | 
    
         
            +
              include_class Java::org.apache.http.client.HttpClient
         
     | 
| 
      
 47 
     | 
    
         
            +
              include_class Java::org.apache.http.entity.ByteArrayEntity
         
     | 
| 
      
 48 
     | 
    
         
            +
              include_class Java::org.apache.http.impl.cookie.DateUtils
         
     | 
| 
      
 49 
     | 
    
         
            +
              include_class Java::org.apache.http.message.BasicHttpEntityEnclosingRequest
         
     | 
| 
      
 50 
     | 
    
         
            +
              include_class Java::org.apache.http.message.BasicHttpRequest
         
     | 
| 
      
 51 
     | 
    
         
            +
              include_class Java::org.apache.http.message.BasicHttpResponse
         
     | 
| 
      
 52 
     | 
    
         
            +
              include_class Java::org.apache.http.protocol.HttpContext
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              include_class com.couchbase.client.CouchbaseClient
         
     | 
| 
      
 55 
     | 
    
         
            +
              include_class com.couchbase.client.CouchbaseConnectionFactory
         
     | 
| 
      
 56 
     | 
    
         
            +
              Observer = java.util.Observer
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
              def initialize(pool_uris, bucket, password='')
         
     | 
| 
      
 59 
     | 
    
         
            +
                @urilist = ArrayList.new
         
     | 
| 
      
 60 
     | 
    
         
            +
                pool_uris = [ pool_uris ] if pool_uris.is_a? String
         
     | 
| 
      
 61 
     | 
    
         
            +
                pool_uris.each { |uri| @urilist << URI.new(uri) }
         
     | 
| 
      
 62 
     | 
    
         
            +
                @bucket = bucket
         
     | 
| 
      
 63 
     | 
    
         
            +
                @password = password
         
     | 
| 
      
 64 
     | 
    
         
            +
                self.connect
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              def connect
         
     | 
| 
      
 68 
     | 
    
         
            +
                @connection_factory = CouchbaseConnectionFactory.new( @urilist, @bucket.to_java_string, @password.to_java_string )
         
     | 
| 
      
 69 
     | 
    
         
            +
                @client = CouchbaseClient.new(@connection_factory)
         
     | 
| 
      
 70 
     | 
    
         
            +
                self
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
              def javify(o)
         
     | 
| 
      
 74 
     | 
    
         
            +
                if( o.is_a? Hash )
         
     | 
| 
      
 75 
     | 
    
         
            +
                  o.each { |k,v| o[k] = self.javify(v) }
         
     | 
| 
      
 76 
     | 
    
         
            +
                  return java.util.HashMap.new( o )
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
                if( o.is_a? Array )
         
     | 
| 
      
 79 
     | 
    
         
            +
                   o.each_index { |i| o[i] = self.javify( o[i] ) }
         
     | 
| 
      
 80 
     | 
    
         
            +
                   return java.util.ArrayList.new( o )
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
                return o
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              def rubify(o)
         
     | 
| 
      
 86 
     | 
    
         
            +
                if( o.is_a? Java::JavaUtil::HashMap )
         
     | 
| 
      
 87 
     | 
    
         
            +
                  h = {}
         
     | 
| 
      
 88 
     | 
    
         
            +
                  o.each { |k,v| h[k] = self.rubify(v) }
         
     | 
| 
      
 89 
     | 
    
         
            +
                  return h
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
                if( o.is_a? Java::JavaUtil::ArrayList )
         
     | 
| 
      
 92 
     | 
    
         
            +
                   a = []
         
     | 
| 
      
 93 
     | 
    
         
            +
                   o.each { |v| a << self.rubify(v) }
         
     | 
| 
      
 94 
     | 
    
         
            +
                   return a
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
                return o
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              %w( shutdown add append delete asyncCAS asyncDecr asyncGetAndTouch asyncGet asyncGetBulk asyncGet asyncGets asyncIncr cas decr delete getAndTouch getBulk get gets getStats incr prepend replace set touch ).each do |meth|
         
     | 
| 
      
 100 
     | 
    
         
            +
                define_method(meth) do |*args|
         
     | 
| 
      
 101 
     | 
    
         
            +
                  self.rubify( @client.send( meth.to_sym, *args.map { |a| self.javify(a) } ) )
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
              end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
              def []= ( key, value )
         
     | 
| 
      
 106 
     | 
    
         
            +
                self.set( key, 0, value )
         
     | 
| 
      
 107 
     | 
    
         
            +
              end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
              def [] ( key )
         
     | 
| 
      
 110 
     | 
    
         
            +
                self.get( key )
         
     | 
| 
      
 111 
     | 
    
         
            +
              end
         
     | 
| 
      
 112 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/jcouchbase.rb
    ADDED
    
    | 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Copyright (C) 2012 Jeremy Brenner
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
      
 4 
     | 
    
         
            +
            # you may not use this file except in coSmpliance with the License.
         
     | 
| 
      
 5 
     | 
    
         
            +
            # You may obtain a copy of the License at
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            #     http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
      
 8 
     | 
    
         
            +
            #
         
     | 
| 
      
 9 
     | 
    
         
            +
            # Unless required by applicable law or agreed to in writing, software
         
     | 
| 
      
 10 
     | 
    
         
            +
            # distributed under the License is distributed on an "AS IS" BASIS,
         
     | 
| 
      
 11 
     | 
    
         
            +
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         
     | 
| 
      
 12 
     | 
    
         
            +
            # See the License for the specific language governing permissions and
         
     | 
| 
      
 13 
     | 
    
         
            +
            # limitations under the License.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            unless RUBY_PLATFORM =~ /java/
         
     | 
| 
      
 16 
     | 
    
         
            +
              error "This gem is only compatible with a java-based ruby environment like JRuby."
         
     | 
| 
      
 17 
     | 
    
         
            +
              exit 255
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            require 'java'
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            require 'require_all'
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            require_rel 'jcouchbase/jars/*.jar'
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            require_rel 'jcouchbase/**/*.rb'
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,82 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: jcouchbase
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.1
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Jeremy J Brenner
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-08-28 00:00:00.000000000 Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 15 
     | 
    
         
            +
              name: require_all
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: '1.2'
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 25 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 26 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: '1.2'
         
     | 
| 
      
 30 
     | 
    
         
            +
            description: Thin jruby wrapper around Couchbase Java Driver
         
     | 
| 
      
 31 
     | 
    
         
            +
            email:
         
     | 
| 
      
 32 
     | 
    
         
            +
            - jeremyjbrenner@gmail.com
         
     | 
| 
      
 33 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 34 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 35 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 36 
     | 
    
         
            +
            files:
         
     | 
| 
      
 37 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 38 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 39 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 40 
     | 
    
         
            +
            - jcouchbase.gemspec
         
     | 
| 
      
 41 
     | 
    
         
            +
            - lib/jcouchbase.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/jcouchbase/jars/commons-codec-1.5.jar
         
     | 
| 
      
 43 
     | 
    
         
            +
            - lib/jcouchbase/jars/commons-codec-1.6.jar
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/jcouchbase/jars/commons-logging-1.1.1.jar
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/jcouchbase/jars/couchbase-client-1.0.2.jar
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib/jcouchbase/jars/fluent-hc-4.2.1.jar
         
     | 
| 
      
 47 
     | 
    
         
            +
            - lib/jcouchbase/jars/httpclient-4.2.1.jar
         
     | 
| 
      
 48 
     | 
    
         
            +
            - lib/jcouchbase/jars/httpclient-cache-4.2.1.jar
         
     | 
| 
      
 49 
     | 
    
         
            +
            - lib/jcouchbase/jars/httpcore-4.2.1.jar
         
     | 
| 
      
 50 
     | 
    
         
            +
            - lib/jcouchbase/jars/httpcore-ab-4.2.1.jar
         
     | 
| 
      
 51 
     | 
    
         
            +
            - lib/jcouchbase/jars/httpcore-nio-4.2.1.jar
         
     | 
| 
      
 52 
     | 
    
         
            +
            - lib/jcouchbase/jars/httpmime-4.2.1.jar
         
     | 
| 
      
 53 
     | 
    
         
            +
            - lib/jcouchbase/jars/jettison-1.1.jar
         
     | 
| 
      
 54 
     | 
    
         
            +
            - lib/jcouchbase/jars/netty-3.2.0.Final.jar
         
     | 
| 
      
 55 
     | 
    
         
            +
            - lib/jcouchbase/jars/spymemcached-2.8.0.jar
         
     | 
| 
      
 56 
     | 
    
         
            +
            - lib/jcouchbase/jcouchbase.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
            - lib/jcouchbase/version.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            homepage: http://github.com/jeremy-brenner/jcouchbase
         
     | 
| 
      
 59 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 60 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 61 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 62 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 63 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 64 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 66 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 67 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 68 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 69 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 70 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 71 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 72 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 74 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 76 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 77 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 78 
     | 
    
         
            +
            rubygems_version: 1.8.24
         
     | 
| 
      
 79 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 80 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 81 
     | 
    
         
            +
            summary: Thin ruby wrapper around Couchbase Java Driver; for JRuby only
         
     | 
| 
      
 82 
     | 
    
         
            +
            test_files: []
         
     |