couchpop 0.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/LICENSE +20 -0
- data/README.md +30 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/bin/couchpop +10 -0
- data/lib/couchpop.rb +40 -0
- data/spec/spec_helper.rb +0 -0
- metadata +88 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Paul Campbell
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# CouchPop #
|
2
|
+
|
3
|
+
Pushes the contents of a directory to CouchDB.
|
4
|
+
|
5
|
+
## Installation ##
|
6
|
+
|
7
|
+
gem install couchpop
|
8
|
+
|
9
|
+
## Usage ##
|
10
|
+
|
11
|
+
In your project directory, run:
|
12
|
+
|
13
|
+
couchpop
|
14
|
+
|
15
|
+
This uploads the contents of the current directory to `localhost:5984/dbname/appname`
|
16
|
+
|
17
|
+
`dbname` and `appname` are set by default to the current directory name.
|
18
|
+
|
19
|
+
You can specify them as arguments:
|
20
|
+
|
21
|
+
couchpop my_database my_app
|
22
|
+
|
23
|
+
## Requirements. ##
|
24
|
+
|
25
|
+
CouchDB needs to be installed and running.
|
26
|
+
|
27
|
+
This app shells out to curl, so you need to have curl installed.
|
28
|
+
|
29
|
+
Made by Paul Campbell, @paulca
|
30
|
+
with help from Chris Williams
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "couchpop"
|
8
|
+
gem.version = File.read('VERSION')
|
9
|
+
gem.summary = %Q{Push the contents of a directory to a CouchDB document}
|
10
|
+
gem.description = %Q{Couchpop uploads a directory to CouchDB}
|
11
|
+
gem.email = "paul@rslw.com"
|
12
|
+
gem.homepage = "http://github.com/paulca/couchpop"
|
13
|
+
gem.authors = ["Paul Campbell"]
|
14
|
+
gem.add_dependency "couchrest", "1.0.1"
|
15
|
+
gem.files = FileList["[A-Z]*", "lib/**/*", "app/**/*"]
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/test_*.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
task :test => :check_dependencies
|
31
|
+
|
32
|
+
task :default => :test
|
33
|
+
|
34
|
+
require 'rake/rdoctask'
|
35
|
+
Rake::RDocTask.new do |rdoc|
|
36
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
37
|
+
|
38
|
+
rdoc.rdoc_dir = 'rdoc'
|
39
|
+
rdoc.title = "couchpop #{version}"
|
40
|
+
rdoc.rdoc_files.include('README*')
|
41
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
42
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1
|
data/bin/couchpop
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'couchpop'
|
6
|
+
|
7
|
+
this_dirname = File.basename(File.expand_path('.'))
|
8
|
+
database_name = $ARGV[0] || this_dirname
|
9
|
+
app_name = $ARGV[1] || this_dirname
|
10
|
+
Couchpop.new(database_name, app_name).rock!
|
data/lib/couchpop.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'couchrest'
|
2
|
+
class Couchpop
|
3
|
+
|
4
|
+
attr_accessor :database_name, :app_name
|
5
|
+
|
6
|
+
def initialize(database_name, app_name)
|
7
|
+
self.database_name = database_name
|
8
|
+
self.app_name = app_name
|
9
|
+
end
|
10
|
+
|
11
|
+
def server
|
12
|
+
@server ||= CouchRest.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def database
|
16
|
+
|
17
|
+
@database ||= begin
|
18
|
+
server.database!(database_name).delete!
|
19
|
+
server.database!(database_name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def rock!
|
24
|
+
|
25
|
+
server.database!(app_name)
|
26
|
+
doc = CouchRest::Document.new({'_id' => app_name})
|
27
|
+
doc.database = database
|
28
|
+
|
29
|
+
database.save_doc(doc)
|
30
|
+
|
31
|
+
|
32
|
+
Dir['**/*.*'].each do |path|
|
33
|
+
doc = database.get(app_name)
|
34
|
+
mimetype = `file -Ib #{path}`.gsub(/\n/,"")
|
35
|
+
puts "#{path}"
|
36
|
+
`curl -s -X PUT http://localhost:5984/#{database_name}/#{app_name}/#{path}?rev=#{doc['_rev']} --data-binary @#{path} -H "Content-Type: #{mimetype}"`
|
37
|
+
end
|
38
|
+
puts "Success. App pushed to http://localhost:5984/#{database_name}/#{app_name}"
|
39
|
+
end
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: couchpop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Paul Campbell
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-09-26 00:00:00 +02:00
|
18
|
+
default_executable: couchpop
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: couchrest
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 21
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
- 1
|
33
|
+
version: 1.0.1
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
description: Couchpop uploads a directory to CouchDB
|
37
|
+
email: paul@rslw.com
|
38
|
+
executables:
|
39
|
+
- couchpop
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- LICENSE
|
44
|
+
- README.md
|
45
|
+
files:
|
46
|
+
- LICENSE
|
47
|
+
- README.md
|
48
|
+
- Rakefile
|
49
|
+
- VERSION
|
50
|
+
- lib/couchpop.rb
|
51
|
+
- spec/spec_helper.rb
|
52
|
+
- bin/couchpop
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://github.com/paulca/couchpop
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options:
|
59
|
+
- --charset=UTF-8
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.3.7
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Push the contents of a directory to a CouchDB document
|
87
|
+
test_files:
|
88
|
+
- spec/spec_helper.rb
|