relaxo 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZmJjYzZmZTEwYTAwNzczMjhlNmI5YzdmZWIxNTViOTMwZmZkZmY4Ng==
5
+ data.tar.gz: !binary |-
6
+ MzA2ZDlmY2U0MzI0NGFkMGExYmRmNjkyY2ZkZjAzMjQzNzliMGJiYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ODBmMzE1YzAwNjM3MmUzZjJiNDRlZjNkMTM0NjNjZjM1YTYxZjUxMmQwMGY0
10
+ Njk2NTllYWZlM2RjZmU0YmU2ZWYxNWNjNGZmNjE0YjU1ZWQwZjM2NWMzMjdl
11
+ NDJhZWE5MzVkZmJkMjMxZjI5YzNhYTk3ZjI5YmZlOGNkYzVkMmY=
12
+ data.tar.gz: !binary |-
13
+ ZDU3MmI3MTc3NTY3Nzk2NmQ4Njk2Y2IyNTBmNWExY2ZjYTljN2U2NGE1NjNm
14
+ ZTM2YTI0MWM5N2MwNTFmMTYzYzQ3Y2IyYWYxZTM4YWVhZTA4ZDA5MDFhMzNk
15
+ MmNkYzA2Yzk1ZGJlZWRhNTkwY2ZhNWM3ZDI4ZTc2ZDY3ODNiZWU=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - jruby-18mode # JRuby in 1.8 mode
7
+ - jruby-19mode # JRuby in 1.9 mode
8
+ - rbx-18mode
9
+ - rbx-19mode
10
+ services:
11
+ - couchdb
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in relaxo.gemspec
4
+ gemspec
5
+
6
+ platforms :jruby do
7
+ gem 'jruby-openssl'
8
+ end
data/README.md CHANGED
@@ -1,26 +1,24 @@
1
- Relaxo
2
- ======
3
-
4
- * Author: Samuel G. D. Williams (<http://www.oriontransfer.co.nz>)
5
- * Copyright (C) 2012 Samuel G. D. Williams.
6
- * Released under the MIT license.
1
+ # Relaxo
7
2
 
8
3
  Relaxo provides a set of tools and interfaces for interacting with CouchDB. It aims to be as simple and efficient as possible while still improving the usability of various CouchDB features.
9
4
 
10
- Installation
11
- ------------
5
+ [![Build Status](https://secure.travis-ci.org/ioquatix/relaxo.png)](http://travis-ci.org/ioquatix/relaxo)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'relaxo'
12
12
 
13
- Install the ruby gem as follows:
13
+ And then execute:
14
14
 
15
- sudo gem install relaxo
15
+ $ bundle
16
16
 
17
- To build and install the gem from source:
17
+ Or install it yourself as:
18
18
 
19
- cd build/
20
- sudo GEM=gem1.9 rake1.9 install_gem
19
+ $ gem install relaxo
21
20
 
22
- Basic Usage
23
- -----------
21
+ ## Usage
24
22
 
25
23
  Connect to a local database and manipulate some documents.
26
24
 
@@ -35,7 +33,7 @@ Connect to a local database and manipulate some documents.
35
33
  doc2[:foo] = 'bar'
36
34
  database.save(doc2)
37
35
 
38
- ### Bulk Changes/Sessions ###
36
+ ### Transactions/Bulk Save
39
37
 
40
38
  Sessions support a very similar interface to the main database class and can for many cases be used interchangeably, but with added efficiency.
41
39
 
@@ -57,18 +55,32 @@ Sessions support a very similar interface to the main database class and can for
57
55
  # {:name=>"Chicken-san", "_id"=>"...", "_rev"=>"..."}
58
56
  #]
59
57
 
60
- All documents will allocated uuids appropriately and at the end of the session block they will be updated (saved or deleted)
61
- using CouchDB `_bulk_save`.
58
+ All documents will allocated UUIDs appropriately and at the end of the session block they will be updated (saved or deleted) using CouchDB `_bulk_save`. The Transactions interface doesn't support any kind of interaction with the server and thus views won't be updated until after the transaction is complete.
62
59
 
63
60
  To abort the session, either raise an exception or call `session.abort!` which is equivalent to `throw :abort`.
64
61
 
65
- ### Loading Data ###
62
+ ### Loading Data
66
63
 
67
64
  Relaxo includes a command line script to import documents into a CouchDB database:
68
65
 
69
- relaxo http://localhost:5984/test design.yaml sample.yaml
66
+ % relaxo --help
67
+ Usage: relaxo [options] [server-url] [files]
68
+ This script can be used to import data to CouchDB.
69
+
70
+ Document creation:
71
+ --existing [mode] Control whether to 'update (new document attributes takes priority), 'merge' (existing document attributes takes priority) or replace (old document attributes discarded) existing documents.
72
+ --format [type] Control the input format. 'yaml' files are imported as a single document or array of documents. 'csv' files are imported as records using the first row as attribute keys.
73
+ --[no-]transaction Controls whether data is saved using the batch save operation. Not suitable for huge amounts of data.
74
+
75
+ Help and Copyright information:
76
+ --copy Display copyright and warranty information
77
+ -h, --help Show this help message.
78
+
79
+ This command loads the documents stored in `design.yaml` and `sample.yaml` into the database at `http://localhost:5984/test`.
70
80
 
71
- Where `design.yaml` and `sample.yaml` contain lists of valid documents, e.g.:
81
+ % relaxo http://localhost:5984/test design.yaml sample.yaml
82
+
83
+ ...where `design.yaml` and `sample.yaml` contain lists of valid documents, e.g.:
72
84
 
73
85
  # design.yaml
74
86
  - _id: "_design/services"
@@ -82,10 +94,23 @@ Where `design.yaml` and `sample.yaml` contain lists of valid documents, e.g.:
82
94
  }
83
95
  }
84
96
 
85
- License
86
- -------
97
+ If you specify `--format=csv`, the input files will be parsed as standard CSV. The document schema is inferred from the zeroth (header) row and all subsequent rows will be converted to individual documents. All fields will be saved as text.
98
+
99
+ If your requirements are more complex, consider writing a custom script either to import directly using the `relaxo` gem or convert your data to YAML and import that as above.
100
+
101
+ ## Contributing
102
+
103
+ 1. Fork it
104
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
105
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
106
+ 4. Push to the branch (`git push origin my-new-feature`)
107
+ 5. Create new Pull Request
108
+
109
+ ## License
110
+
111
+ Released under the MIT license.
87
112
 
88
- Copyright (c) 2010, 2011 Samuel G. D. Williams. <http://www.oriontransfer.co.nz>
113
+ Copyright, 2012, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
89
114
 
90
115
  Permission is hereby granted, free of charge, to any person obtaining a copy
91
116
  of this software and associated documentation files (the "Software"), to deal
data/bin/relaxo CHANGED
@@ -55,7 +55,7 @@ ARGV.options do |o|
55
55
  o.separator "Help and Copyright information:"
56
56
 
57
57
  o.on_tail("--copy", "Display copyright and warranty information") do
58
- $stderr.puts "#{script_name} v#{Relaxo::VERSION::STRING}. Copyright (c) 2012 Samuel Williams."
58
+ $stderr.puts "#{script_name} v#{Relaxo::VERSION}. Copyright (c) 2012 Samuel Williams."
59
59
  $stderr.puts "This software is released under the MIT license and comes with ABSOLUTELY NO WARRANTY."
60
60
  exit
61
61
  end
@@ -66,19 +66,31 @@ ARGV.options do |o|
66
66
  end
67
67
  end.parse!
68
68
 
69
- $url = ARGV.shift
70
- $stderr.puts "Connecting to #{$url}..."
71
- $database = Relaxo.connect($url)
69
+ url = ARGV.shift
72
70
 
73
- $format = Formats.method(OPTIONS[:format])
71
+ $stderr.puts "Connecting to #{url}..."
72
+ database = Relaxo.connect(url)
74
73
 
75
- $stats = {
74
+ begin
75
+ info = database.info
76
+
77
+ $stderr.puts "Connected to #{info['db_name']} which contains #{info['doc_count']} document(s)."
78
+ rescue StandardError => error
79
+ $stderr.puts "Could not fetch info from database server!"
80
+
81
+ throw
82
+ end
83
+
84
+
85
+ format = Formats.method(OPTIONS[:format])
86
+
87
+ @stats = {
76
88
  :saved => 0,
77
89
  :errors => 0,
78
90
  :total => 0
79
91
  }
80
92
 
81
- def process_document(database)
93
+ def process_document(database, document)
82
94
  begin
83
95
  existing_document = nil
84
96
 
@@ -106,25 +118,25 @@ def process_document(database)
106
118
  end
107
119
 
108
120
  $stderr.puts "Saving #{document.inspect}"
109
- $result = database.save(document)
121
+ result = database.save(document)
110
122
 
111
- $stats[:saved] += 1
123
+ @stats[:saved] += 1
112
124
  rescue RestClient::BadRequest => ex
113
125
  $stderr.puts ex.inspect
114
126
 
115
- $stats[:errors] += 1
127
+ @stats[:errors] += 1
116
128
  end
117
129
 
118
- $stats[:total] += 1
130
+ @stats[:total] += 1
119
131
  end
120
132
 
121
133
  begin
122
- $format.call(ARGF) do |document|
123
- process_document(document)
134
+ format.call(ARGF) do |document|
135
+ process_document(database, document)
124
136
  end
125
137
  ensure
126
- $stderr.puts "#{$stats[:saved]} document(s) saved out of #{$stats[:total]}."
127
- if $stats[:errors] > 0
128
- $stderr.puts "#{$stats[:errors]} errors occurred!"
138
+ $stderr.puts "#{@stats[:saved]} document(s) saved out of #{@stats[:total]}."
139
+ if @stats[:errors] > 0
140
+ $stderr.puts "#{@stats[:errors]} errors occurred!"
129
141
  end
130
142
  end
data/bin/relaxo-admin ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'relaxo'
4
+ require 'relaxo/version'
5
+ require 'optparse'
6
+ require 'digest/sha1'
7
+
8
+ $url = ARGV.shift unless ARGV[0] =~ /^-/
9
+ $connection = Relaxo::Connection.new($url)
10
+
11
+ OPTIONS = {
12
+ :roles => [],
13
+ :password => nil
14
+ }
15
+
16
+ ARGV.options do |o|
17
+ script_name = File.basename($0)
18
+
19
+ o.banner = "Usage: #{script_name} [server-url] [options]"
20
+ o.define_head "This script can be used to import data to CouchDB."
21
+
22
+ o.on("--password password", "Specify the password for a new user") do |password|
23
+ OPTIONS[:password] = password
24
+ end
25
+
26
+ o.on("--roles reader,writer", Array, "Specify the roles for a new user") do |roles|
27
+ OPTIONS[:roles] = roles
28
+ end
29
+
30
+ o.on("--create-user name", "Create a new (non-admin) user") do |name|
31
+ password = OPTIONS[:password]
32
+
33
+ salt = Digest::SHA1.hexdigest(rand.to_s + name + Time.now.to_s + password)
34
+
35
+ user = {
36
+ Relaxo::ID => "org.couchdb.user:#{name}",
37
+ :type => "user",
38
+ :name => name,
39
+ :roles => OPTIONS[:roles],
40
+ :salt => salt,
41
+ :password_sha => Digest::SHA1.hexdigest(password + salt)
42
+ }
43
+
44
+ database = Relaxo::Database.new($connection, "_users")
45
+ puts database.save(user).inspect
46
+ end
47
+
48
+ o.separator ""
49
+ o.separator "Help and Copyright information:"
50
+
51
+ o.on_tail("--copy", "Display copyright and warranty information") do
52
+ $stderr.puts "#{script_name} v#{Relaxo::VERSION}. Copyright (c) 2012 Samuel Williams."
53
+ $stderr.puts "This software is released under the MIT license and comes with ABSOLUTELY NO WARRANTY."
54
+ exit
55
+ end
56
+
57
+ o.on_tail("-h", "--help", "Show this help message.") do
58
+ $stderr.puts o
59
+ exit
60
+ end
61
+ end.parse!
data/build/master.rb ADDED
@@ -0,0 +1,22 @@
1
+
2
+ Dir.chdir("../") do
3
+ require './lib/relaxo/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "relaxo"
7
+ s.version = Relaxo::VERSION::STRING
8
+ s.author = "Samuel Williams"
9
+ s.email = "samuel@oriontransfer.org"
10
+ s.homepage = "http://www.codeotaku.com/projects/relaxo"
11
+ s.platform = Gem::Platform::RUBY
12
+ s.summary = "Relaxo is a helper for loading and working with CouchDB."
13
+ s.files = FileList["{bin,lib,test}/**/*"] + ["rakefile.rb", "Gemfile", "README.md"]
14
+
15
+ s.executables << 'relaxo'
16
+
17
+ s.add_dependency("json", "~> 1.7.3")
18
+ s.add_dependency("rest-client", "~> 1.6.7")
19
+
20
+ s.has_rdoc = "yard"
21
+ end
22
+ end
data/build/rakefile.rb ADDED
@@ -0,0 +1,39 @@
1
+
2
+ # Automatic Gem Build Script v3.0
3
+
4
+ require 'fileutils'
5
+ require 'rubygems'
6
+
7
+ MasterGemspec = "master.rb"
8
+
9
+ GEM = ENV['GEM'] || "gem"
10
+
11
+ desc 'Build a gemspec file'
12
+ task :build_gemspec do
13
+ $spec = Gem::Specification.load(MasterGemspec)
14
+
15
+ $versioned_gem = "#{$spec.name}-#{$spec.version}.gem"
16
+ $versioned_gemspec = "#{$spec.name}-#{$spec.version}.gemspec"
17
+ $base_gemspec = "#{$spec.name}.gemspec"
18
+
19
+ puts "Building #{$versioned_gemspec}..."
20
+
21
+ File.open($versioned_gemspec, "w") do |f|
22
+ f.write($spec.to_ruby)
23
+ end
24
+
25
+ puts "Copying file to ../#{$base_gemspec}"
26
+ FileUtils.cp($versioned_gemspec, "../#{$base_gemspec}")
27
+ end
28
+
29
+ task :build_gem => [:build_gemspec] do
30
+ Dir.chdir("../") do
31
+ system("#{GEM} build #{$base_gemspec}")
32
+ end
33
+ end
34
+
35
+ task :install_gem => [:build_gem] do
36
+ Dir.chdir("../") do
37
+ system("#{GEM} install --local #{$versioned_gem}")
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "relaxo"
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Samuel Williams"]
9
+ s.date = "2012-07-09"
10
+ s.email = "samuel.williams@oriontransfer.co.nz"
11
+ s.executables = ["relaxo"]
12
+ s.files = ["bin/relaxo", "lib/relaxo", "lib/relaxo/version.rb", "lib/relaxo.rb", "README.md"]
13
+ s.homepage = "http://www.oriontransfer.co.nz/gems/relaxo"
14
+ s.require_paths = ["lib"]
15
+ s.rubygems_version = "1.8.23"
16
+ s.summary = "Relaxo is a helper for loading and working with CouchDB."
17
+
18
+ if s.respond_to? :specification_version then
19
+ s.specification_version = 3
20
+
21
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
22
+ s.add_runtime_dependency(%q<couchrest>, [">= 0"])
23
+ else
24
+ s.add_dependency(%q<couchrest>, [">= 0"])
25
+ end
26
+ else
27
+ s.add_dependency(%q<couchrest>, [">= 0"])
28
+ end
29
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "relaxo"
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Samuel Williams"]
9
+ s.date = "2012-07-10"
10
+ s.email = "samuel.williams@oriontransfer.co.nz"
11
+ s.executables = ["relaxo"]
12
+ s.files = ["bin/relaxo", "lib/relaxo", "lib/relaxo/client.rb", "lib/relaxo/database.rb", "lib/relaxo/model.rb", "lib/relaxo/properties.rb", "lib/relaxo/recordset.rb", "lib/relaxo/server.rb", "lib/relaxo/version.rb", "lib/relaxo.rb", "README.md"]
13
+ s.homepage = "http://www.oriontransfer.co.nz/gems/relaxo"
14
+ s.require_paths = ["lib"]
15
+ s.rubygems_version = "1.8.23"
16
+ s.summary = "Relaxo is a helper for loading and working with CouchDB."
17
+
18
+ if s.respond_to? :specification_version then
19
+ s.specification_version = 3
20
+
21
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
22
+ s.add_runtime_dependency(%q<couchrest>, [">= 0"])
23
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
24
+ else
25
+ s.add_dependency(%q<couchrest>, [">= 0"])
26
+ s.add_dependency(%q<rest-client>, [">= 0"])
27
+ end
28
+ else
29
+ s.add_dependency(%q<couchrest>, [">= 0"])
30
+ s.add_dependency(%q<rest-client>, [">= 0"])
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "relaxo"
5
+ s.version = "0.2.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Samuel Williams"]
9
+ s.date = "2012-07-11"
10
+ s.email = "samuel.williams@oriontransfer.co.nz"
11
+ s.executables = ["relaxo"]
12
+ s.files = ["bin/relaxo", "lib/relaxo", "lib/relaxo/client.rb", "lib/relaxo/database.rb", "lib/relaxo/model.rb", "lib/relaxo/properties", "lib/relaxo/properties/money.rb", "lib/relaxo/properties.rb", "lib/relaxo/recordset.rb", "lib/relaxo/server.rb", "lib/relaxo/version.rb", "lib/relaxo.rb", "README.md"]
13
+ s.homepage = "http://www.oriontransfer.co.nz/gems/relaxo"
14
+ s.require_paths = ["lib"]
15
+ s.rubygems_version = "1.8.23"
16
+ s.summary = "Relaxo is a helper for loading and working with CouchDB."
17
+
18
+ if s.respond_to? :specification_version then
19
+ s.specification_version = 3
20
+
21
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
22
+ s.add_runtime_dependency(%q<couchrest>, [">= 0"])
23
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
24
+ else
25
+ s.add_dependency(%q<couchrest>, [">= 0"])
26
+ s.add_dependency(%q<rest-client>, [">= 0"])
27
+ end
28
+ else
29
+ s.add_dependency(%q<couchrest>, [">= 0"])
30
+ s.add_dependency(%q<rest-client>, [">= 0"])
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "relaxo"
5
+ s.version = "0.3.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Samuel Williams"]
9
+ s.date = "2012-07-11"
10
+ s.email = "samuel.williams@oriontransfer.co.nz"
11
+ s.executables = ["relaxo"]
12
+ s.files = ["bin/relaxo", "lib/relaxo", "lib/relaxo/client.rb", "lib/relaxo/database.rb", "lib/relaxo/server.rb", "lib/relaxo/session.rb", "lib/relaxo/version.rb", "lib/relaxo.rb", "README.md"]
13
+ s.homepage = "http://www.oriontransfer.co.nz/gems/relaxo"
14
+ s.require_paths = ["lib"]
15
+ s.rubygems_version = "1.8.23"
16
+ s.summary = "Relaxo is a helper for loading and working with CouchDB."
17
+
18
+ if s.respond_to? :specification_version then
19
+ s.specification_version = 3
20
+
21
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
22
+ s.add_runtime_dependency(%q<json>, ["~> 1.7.3"])
23
+ s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.7"])
24
+ else
25
+ s.add_dependency(%q<json>, ["~> 1.7.3"])
26
+ s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
27
+ end
28
+ else
29
+ s.add_dependency(%q<json>, ["~> 1.7.3"])
30
+ s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "relaxo"
5
+ s.version = "0.3.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Samuel Williams"]
9
+ s.date = "2012-07-23"
10
+ s.email = "samuel.williams@oriontransfer.co.nz"
11
+ s.executables = ["relaxo"]
12
+ s.files = ["bin/relaxo", "lib/relaxo", "lib/relaxo/client.rb", "lib/relaxo/connection.rb", "lib/relaxo/database.rb", "lib/relaxo/session.rb", "lib/relaxo/version.rb", "lib/relaxo.rb", "test/database_test.rb", "README.md"]
13
+ s.homepage = "http://www.oriontransfer.co.nz/gems/relaxo"
14
+ s.require_paths = ["lib"]
15
+ s.rubygems_version = "1.8.23"
16
+ s.summary = "Relaxo is a helper for loading and working with CouchDB."
17
+
18
+ if s.respond_to? :specification_version then
19
+ s.specification_version = 3
20
+
21
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
22
+ s.add_runtime_dependency(%q<json>, ["~> 1.7.3"])
23
+ s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.7"])
24
+ else
25
+ s.add_dependency(%q<json>, ["~> 1.7.3"])
26
+ s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
27
+ end
28
+ else
29
+ s.add_dependency(%q<json>, ["~> 1.7.3"])
30
+ s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "relaxo"
5
+ s.version = "0.4.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Samuel Williams"]
9
+ s.date = "2012-10-14"
10
+ s.email = "samuel.williams@oriontransfer.co.nz"
11
+ s.executables = ["relaxo"]
12
+ s.files = ["bin/relaxo", "lib/relaxo", "lib/relaxo/attachments.rb", "lib/relaxo/base64-1.8.rb", "lib/relaxo/client.rb", "lib/relaxo/connection.rb", "lib/relaxo/database.rb", "lib/relaxo/json.rb", "lib/relaxo/transaction.rb", "lib/relaxo/version.rb", "lib/relaxo.rb", "test/README.md", "test/attachments_test.rb", "test/connection_test.rb", "test/database_test.rb", "test/helper.rb", "test/transaction_test.rb", "README.md"]
13
+ s.homepage = "http://www.oriontransfer.co.nz/gems/relaxo"
14
+ s.require_paths = ["lib"]
15
+ s.rubygems_version = "1.8.23"
16
+ s.summary = "Relaxo is a helper for loading and working with CouchDB."
17
+
18
+ if s.respond_to? :specification_version then
19
+ s.specification_version = 3
20
+
21
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
22
+ s.add_runtime_dependency(%q<json>, ["~> 1.7.3"])
23
+ s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.7"])
24
+ else
25
+ s.add_dependency(%q<json>, ["~> 1.7.3"])
26
+ s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
27
+ end
28
+ else
29
+ s.add_dependency(%q<json>, ["~> 1.7.3"])
30
+ s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
31
+ end
32
+ end
@@ -21,12 +21,6 @@
21
21
  require 'relaxo/client'
22
22
  require 'relaxo/connection'
23
23
 
24
- if RUBY_VERSION < "1.9"
25
- require 'relaxo/base64-1.8'
26
- else
27
- require 'base64'
28
- end
29
-
30
24
  module Relaxo
31
25
  ID = '_id'
32
26
  REV = '_rev'
@@ -19,11 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Relaxo
22
- module VERSION
23
- MAJOR = 0
24
- MINOR = 4
25
- TINY = 0
26
-
27
- STRING = [MAJOR, MINOR, TINY].join('.')
28
- end
22
+ VERSION = "0.4.2"
29
23
  end
data/lib/relaxo.rb CHANGED
@@ -27,6 +27,11 @@ module Relaxo
27
27
  if url =~ /^(https?:\/\/.+?)\/(.+)$/
28
28
  host = $1
29
29
  name = $2
30
+
31
+ # Ensure that we use the default port if none has been specified:
32
+ unless host =~ /:\d+$/
33
+ host = host + ":5984"
34
+ end
30
35
  else
31
36
  name = url
32
37
  end
data/rakefile.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ end
7
+
8
+ desc "Run tests"
9
+ task :default => :test
data/relaxo.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'relaxo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "relaxo"
8
+ spec.version = Relaxo::VERSION
9
+ spec.authors = ["Samuel Williams"]
10
+ spec.email = ["samuel.williams@oriontransfer.co.nz"]
11
+ spec.description = <<-EOF
12
+ Relaxo provides a set of tools and interfaces for interacting with CouchDB.
13
+ It aims to be as simple and efficient as possible while still improving the
14
+ usability of various CouchDB features.
15
+ EOF
16
+ spec.summary = %q{Relaxo is a helper for loading and working with CouchDB.}
17
+ spec.homepage = ""
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files`.split($/)
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+
28
+ spec.add_dependency "json", "~> 1.7.3"
29
+ spec.add_dependency "rest-client"
30
+ end
@@ -27,6 +27,10 @@ class DatabaseTest < Test::Unit::TestCase
27
27
  }
28
28
  }
29
29
 
30
- puts @database.save(document).inspect
30
+ result = @database.save(document)
31
+ assert result['ok']
32
+
33
+ document = @database.get(document[Relaxo::ID])
34
+ assert_equal 1, document[Relaxo::ATTACHMENTS].size
31
35
  end
32
36
  end
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,60 +1,97 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: relaxo
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 4
8
- - 0
9
- version: 0.4.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.2
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Samuel Williams
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2012-10-14 00:00:00 +13:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: json
11
+ date: 2013-04-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
22
35
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
25
45
  - - ~>
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 7
30
- - 3
46
+ - !ruby/object:Gem::Version
31
47
  version: 1.7.3
32
48
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: rest-client
36
49
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
39
52
  - - ~>
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 6
44
- - 7
45
- version: 1.6.7
53
+ - !ruby/object:Gem::Version
54
+ version: 1.7.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  type: :runtime
47
- version_requirements: *id002
48
- description:
49
- email: samuel.williams@oriontransfer.co.nz
50
- executables:
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: ! "\t\tRelaxo provides a set of tools and interfaces for interacting
70
+ with CouchDB.\n\t\tIt aims to be as simple and efficient as possible while still
71
+ improving the\n\t\tusability of various CouchDB features.\n"
72
+ email:
73
+ - samuel.williams@oriontransfer.co.nz
74
+ executables:
51
75
  - relaxo
76
+ - relaxo-admin
52
77
  extensions: []
53
-
54
78
  extra_rdoc_files: []
55
-
56
- files:
79
+ files:
80
+ - .gitignore
81
+ - .travis.yml
82
+ - Gemfile
83
+ - README.md
57
84
  - bin/relaxo
85
+ - bin/relaxo-admin
86
+ - build/master.rb
87
+ - build/rakefile.rb
88
+ - build/relaxo-0.1.0.gemspec
89
+ - build/relaxo-0.1.1.gemspec
90
+ - build/relaxo-0.2.0.gemspec
91
+ - build/relaxo-0.3.0.gemspec
92
+ - build/relaxo-0.3.1.gemspec
93
+ - build/relaxo-0.4.0.gemspec
94
+ - lib/relaxo.rb
58
95
  - lib/relaxo/attachments.rb
59
96
  - lib/relaxo/base64-1.8.rb
60
97
  - lib/relaxo/client.rb
@@ -63,43 +100,42 @@ files:
63
100
  - lib/relaxo/json.rb
64
101
  - lib/relaxo/transaction.rb
65
102
  - lib/relaxo/version.rb
66
- - lib/relaxo.rb
103
+ - rakefile.rb
104
+ - relaxo.gemspec
67
105
  - test/README.md
68
- - test/attachments_test.rb
69
- - test/connection_test.rb
70
- - test/database_test.rb
71
106
  - test/helper.rb
72
- - test/transaction_test.rb
73
- - README.md
74
- has_rdoc: true
75
- homepage: http://www.oriontransfer.co.nz/gems/relaxo
76
- licenses: []
77
-
107
+ - test/test_attachments.rb
108
+ - test/test_connection.rb
109
+ - test/test_database.rb
110
+ - test/test_transactions.rb
111
+ homepage: ''
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
78
115
  post_install_message:
79
116
  rdoc_options: []
80
-
81
- require_paths:
117
+ require_paths:
82
118
  - lib
83
- required_ruby_version: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- segments:
88
- - 0
89
- version: "0"
90
- required_rubygems_version: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- segments:
95
- - 0
96
- version: "0"
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
97
129
  requirements: []
98
-
99
130
  rubyforge_project:
100
- rubygems_version: 1.3.6
131
+ rubygems_version: 2.0.2
101
132
  signing_key:
102
- specification_version: 3
133
+ specification_version: 4
103
134
  summary: Relaxo is a helper for loading and working with CouchDB.
104
- test_files: []
105
-
135
+ test_files:
136
+ - test/README.md
137
+ - test/helper.rb
138
+ - test/test_attachments.rb
139
+ - test/test_connection.rb
140
+ - test/test_database.rb
141
+ - test/test_transactions.rb