manveru-makura 2009.03.01 → 2009.03.28

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/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/gempackagetask'
4
+ require 'time'
5
+ require 'date'
6
+
7
+ PROJECT_SPECS = Dir['spec/**/*.rb']
8
+ PROJECT_MODULE = 'Makura'
9
+
10
+ GEMSPEC = Gem::Specification.new{|s|
11
+ s.name = 'makura'
12
+ s.author = "Michael 'manveru' Fellinger"
13
+ s.summary = "Ruby wrapper around the CouchDB REST API."
14
+ s.description = "Ruby wrapper around the CouchDB REST API."
15
+ s.email = 'm.fellinger@gmail.com'
16
+ s.homepage = 'http://github.com/manveru/makura'
17
+ s.platform = Gem::Platform::RUBY
18
+ s.version = (ENV['PROJECT_VERSION'] || Date.today.strftime("%Y.%m.%d"))
19
+ s.files = `git ls-files`.split("\n").sort
20
+ s.has_rdoc = true
21
+ s.require_path = 'lib'
22
+ s.executables = ['makura']
23
+ s.bindir = "bin"
24
+
25
+ s.add_runtime_dependency('rest-client', '>= 0.8.1')
26
+ }
27
+
28
+ Dir['tasks/*.rake'].each{|f| import(f) }
29
+
30
+ task :default => [:bacon]
31
+
32
+ CLEAN.include('')
data/example/blog.rb CHANGED
@@ -13,9 +13,6 @@ class Post
13
13
 
14
14
  layout :all
15
15
 
16
- validates(:title){ presence and length :within => (3..100) }
17
- validates(:text){ presence }
18
-
19
16
  save # submit design docs to CouchDB
20
17
  end
21
18
 
data/lib/makura.rb CHANGED
@@ -10,7 +10,6 @@ require 'rest_client'
10
10
  require 'json'
11
11
 
12
12
  module Makura
13
- VERSION = '2008.01.15'
14
13
  ROOT = File.expand_path(File.dirname(__FILE__))
15
14
  end
16
15
 
@@ -18,6 +17,7 @@ unless $LOAD_PATH.any?{|lp| File.expand_path(lp) == Makura::ROOT }
18
17
  $LOAD_PATH.unshift(Makura::ROOT)
19
18
  end
20
19
 
20
+ require 'makura/version'
21
21
  require 'makura/error'
22
22
  require 'makura/http_methods'
23
23
  require 'makura/server'
@@ -144,7 +144,7 @@ module Makura
144
144
  end
145
145
 
146
146
  def view(layout, params = {})
147
- get("_view/#{layout}", params)
147
+ get("_design/#{layout}", params)
148
148
  end
149
149
 
150
150
  def save(doc)
@@ -210,7 +210,7 @@ module Makura
210
210
  end
211
211
 
212
212
  def inspect
213
- "#<Makura::Database '#{@server.uri(name)}'>"
213
+ "#<Makura::Database '#{@server.uri(name || '/')}'>"
214
214
  end
215
215
  end
216
216
  end
data/lib/makura/model.rb CHANGED
@@ -84,13 +84,8 @@ module Makura
84
84
  ["#<#{self.class} ", @_hash, ">"].each{|e| e.pretty_print(o) }
85
85
  end
86
86
 
87
- def saved?
88
- self['_rev']
89
- end
90
-
91
87
  def save
92
88
  return if not valid? if respond_to?(:valid)
93
- return if saved?
94
89
  save!
95
90
  end
96
91
 
@@ -321,7 +316,7 @@ module Makura
321
316
 
322
317
  def multi_fetch(name, opts = {})
323
318
  keys = opts.delete(:keys) || opts.delete('keys')
324
- opts.merge!(:payload => {'keys' => keys.to_a})
319
+ opts.merge!(:payload => {'keys' => Array(keys)})
325
320
  hash = database.post("_view/#{self}/#{name}", opts)
326
321
  convert_raw(hash['rows'])
327
322
  end
@@ -345,7 +340,7 @@ module Makura
345
340
 
346
341
  def view(name, opts = {})
347
342
  flat = opts.delete(:flat)
348
- hash = database.view("#{self}/#{name}", opts)
343
+ hash = database.view("#{self}/_view/#{name}", opts)
349
344
 
350
345
  convert_raw(hash['rows'], flat)
351
346
  end
@@ -0,0 +1,3 @@
1
+ module Makura
2
+ VERSION = "2009.03.28"
3
+ end
data/makura.gemspec CHANGED
@@ -1,42 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  Gem::Specification.new do |s|
2
- s.name = "makura"
3
- s.version = "2009.03.01"
4
+ s.name = %q{makura}
5
+ s.version = "2009.03.28"
4
6
 
5
- s.summary = "Ruby wrapper around the CouchDB REST API."
6
- s.description = "Ruby wrapper around the CouchDB REST API."
7
- s.platform = "ruby"
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Michael 'manveru' Fellinger"]
9
+ s.date = %q{2009-03-28}
10
+ s.default_executable = %q{makura}
11
+ s.description = %q{Ruby wrapper around the CouchDB REST API.}
12
+ s.email = %q{m.fellinger@gmail.com}
13
+ s.executables = ["makura"]
14
+ s.files = ["COPYING", "README.md", "Rakefile", "bin/makura", "example/blog.rb", "example/couch/map/author_all.js", "example/couch/map/author_posts.js", "example/couch/map/post_all.js", "example/couch/map/post_comments.js", "example/couch/reduce/sum_length.js", "lib/makura.rb", "lib/makura/database.rb", "lib/makura/design.rb", "lib/makura/error.rb", "lib/makura/http_methods.rb", "lib/makura/layout.rb", "lib/makura/model.rb", "lib/makura/plugin/localize.rb", "lib/makura/plugin/pager.rb", "lib/makura/server.rb", "lib/makura/uuid_cache.rb", "lib/makura/version.rb", "makura.gemspec", "tasks/bacon.rake", "tasks/changelog.rake", "tasks/gem.rake", "tasks/gem_installer.rake", "tasks/grancher.rake", "tasks/install_dependencies.rake", "tasks/manifest.rake", "tasks/rcov.rake", "tasks/release.rake", "tasks/reversion.rake"]
8
15
  s.has_rdoc = true
9
- s.author = "Michael 'manveru' Fellinger"
10
- s.email = "m.fellinger@gmail.com"
11
- s.homepage = "http://github.com/manveru/makura"
12
- s.executables = ['makura']
13
- s.bindir = "bin"
14
- s.require_path = "lib"
16
+ s.homepage = %q{http://github.com/manveru/makura}
17
+ s.require_paths = ["lib"]
18
+ s.rubygems_version = %q{1.3.1}
19
+ s.summary = %q{Ruby wrapper around the CouchDB REST API.}
15
20
 
16
- s.add_dependency('rest-client', '>= 0.8.1')
17
- s.add_dependency('json', '>= 1.1.3')
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 2
18
24
 
19
- s.files = [
20
- "COPYING",
21
- "README.md",
22
- "bin/makura",
23
- "example/blog.rb",
24
- "example/couch/map/author_all.js",
25
- "example/couch/map/author_posts.js",
26
- "example/couch/map/post_all.js",
27
- "example/couch/map/post_comments.js",
28
- "example/couch/reduce/sum_length.js",
29
- "lib/makura.rb",
30
- "lib/makura/database.rb",
31
- "lib/makura/design.rb",
32
- "lib/makura/error.rb",
33
- "lib/makura/http_methods.rb",
34
- "lib/makura/layout.rb",
35
- "lib/makura/model.rb",
36
- "lib/makura/plugin/localize.rb",
37
- "lib/makura/plugin/pager.rb",
38
- "lib/makura/server.rb",
39
- "lib/makura/uuid_cache.rb",
40
- "makura.gemspec"
41
- ]
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<rest-client>, [">= 0.8.1"])
27
+ else
28
+ s.add_dependency(%q<rest-client>, [">= 0.8.1"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<rest-client>, [">= 0.8.1"])
32
+ end
42
33
  end
data/tasks/bacon.rake ADDED
@@ -0,0 +1,49 @@
1
+ desc 'Run all bacon specs with pretty output'
2
+ task :bacon => :install_dependencies do
3
+ require 'open3'
4
+ require 'scanf'
5
+
6
+ specs = PROJECT_SPECS
7
+
8
+ some_failed = false
9
+ total = specs.size
10
+ len = specs.map{|s| s.size }.sort.last
11
+ tt = ta = tf = te = 0
12
+
13
+ red, yellow, green = "\e[31m%s\e[0m", "\e[33m%s\e[0m", "\e[32m%s\e[0m"
14
+ left_format = "%4d/%d: %-#{len + 11}s"
15
+ spec_format = "%d specifications (%d requirements), %d failures, %d errors"
16
+
17
+ specs.each_with_index do |spec, idx|
18
+ print(left_format % [idx + 1, total, spec])
19
+
20
+ Open3.popen3(RUBY, spec) do |sin, sout, serr|
21
+ out = sout.read
22
+ err = serr.read
23
+
24
+ ran = false
25
+
26
+ out.each_line do |line|
27
+ tests, assertions, failures, errors = all = line.scanf(spec_format)
28
+ next unless all.any?
29
+ ran = true
30
+ tt += tests; ta += assertions; tf += failures; te += errors
31
+
32
+ if tests == 0 || failures + errors > 0
33
+ puts((red % spec_format) % all)
34
+ puts out
35
+ puts err
36
+ else
37
+ puts((green % "%6d passed") % tests)
38
+ end
39
+
40
+ break
41
+ end
42
+
43
+ puts(yellow % " skipped") unless ran
44
+ end
45
+ end
46
+
47
+ puts(spec_format % [tt, ta, tf, te])
48
+ exit 1 if some_failed
49
+ end
@@ -0,0 +1,18 @@
1
+ desc 'update changelog'
2
+ task :changelog do
3
+ File.open('CHANGELOG', 'w+') do |changelog|
4
+ `git log -z --abbrev-commit`.split("\0").each do |commit|
5
+ next if commit =~ /^Merge: \d*/
6
+ ref, author, time, _, title, _, message = commit.split("\n", 7)
7
+ ref = ref[/commit ([0-9a-f]+)/, 1]
8
+ author = author[/Author: (.*)/, 1].strip
9
+ time = Time.parse(time[/Date: (.*)/, 1]).utc
10
+ title.strip!
11
+
12
+ changelog.puts "[#{ref} | #{time}] #{author}"
13
+ changelog.puts '', " * #{title}"
14
+ changelog.puts '', message.rstrip if message
15
+ changelog.puts
16
+ end
17
+ end
18
+ end
data/tasks/gem.rake ADDED
@@ -0,0 +1,22 @@
1
+ require 'rake/gempackagetask'
2
+
3
+ task :gemspec => [:manifest, :changelog] do
4
+ gemspec_file = "#{GEMSPEC.name}.gemspec"
5
+ File.open(gemspec_file, 'w+'){|gs| gs.puts(GEMSPEC.to_ruby) }
6
+ end
7
+
8
+ desc "package and install from gemspec"
9
+ task :install => [:gemspec] do
10
+ sh "gem build #{GEMSPEC.name}.gemspec"
11
+ sh "gem install #{GEMSPEC.name}-#{GEMSPEC.version}.gem"
12
+ end
13
+
14
+ desc "uninstall the gem"
15
+ task :uninstall => [:clean] do
16
+ sh %{gem uninstall -x #{GEMSPEC.name}}
17
+ end
18
+
19
+ Rake::GemPackageTask.new(GEMSPEC) do |p|
20
+ p.need_tar = true
21
+ p.need_zip = true
22
+ end
@@ -0,0 +1,76 @@
1
+ task :gem_installer do
2
+ class GemInstaller
3
+ def initialize(options = {}, &block)
4
+ @gems = []
5
+ @options = options
6
+
7
+ run(&block)
8
+ end
9
+
10
+ def run(&block)
11
+ instance_eval(&block) if block_given?
12
+ end
13
+
14
+ def gem(name, version = nil, options = {})
15
+ if version.respond_to?(:merge!)
16
+ options = version
17
+ else
18
+ options[:version] = version
19
+ end
20
+
21
+ @gems << [name, options]
22
+ end
23
+
24
+ def setup_gemspec(gemspec)
25
+ gemspec.dependencies.each do |dependency|
26
+ dependency.version_requirements.as_list.each do |version|
27
+ gem(dependency.name, version)
28
+ end
29
+ end
30
+
31
+ setup
32
+ end
33
+
34
+ def setup
35
+ require 'rubygems'
36
+ require 'rubygems/dependency_installer'
37
+
38
+ @gems.each do |name, options|
39
+ setup_gem(name, options)
40
+ end
41
+ end
42
+
43
+ def setup_gem(name, options, try_install = true)
44
+ print "activating #{name} ... "
45
+ Gem.activate(name, *[options[:version]].compact)
46
+ require(options[:lib] || name)
47
+ puts "success."
48
+ rescue LoadError => error
49
+ puts error
50
+ install_gem(name, options) if try_install
51
+ setup_gem(name, options, try_install = false)
52
+ end
53
+
54
+ def install_gem(name, options)
55
+ installer = Gem::DependencyInstaller.new(options)
56
+
57
+ temp_argv(options[:extconf]) do
58
+ print "Installing #{name} ... "
59
+ installer.install(name, options[:version])
60
+ puts "done."
61
+ end
62
+ end
63
+
64
+ def temp_argv(extconf)
65
+ if extconf ||= @options[:extconf]
66
+ old_argv = ARGV.clone
67
+ ARGV.replace(extconf.split(' '))
68
+ end
69
+
70
+ yield
71
+
72
+ ensure
73
+ ARGV.replace(old_argv) if extconf
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,12 @@
1
+ begin
2
+ require 'grancher/task'
3
+
4
+ Grancher::Task.new do |g|
5
+ g.branch = 'gh-pages'
6
+ g.push_to = 'origin'
7
+ g.message = 'Updated website'
8
+ g.directory 'ydoc', 'doc'
9
+ end
10
+ rescue LoadError
11
+ # oh well :)
12
+ end
@@ -0,0 +1,6 @@
1
+ desc 'install dependencies'
2
+ task :install_dependencies => [:gem_installer] do
3
+ GemInstaller.new do
4
+ setup_gemspec(GEMSPEC)
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ desc 'update manifest'
2
+ task :manifest do
3
+ File.open('MANIFEST', 'w+'){|io| io.puts(*GEMSPEC.files) }
4
+ end
data/tasks/rcov.rake ADDED
@@ -0,0 +1,19 @@
1
+ desc 'code coverage'
2
+ task :rcov => :clean do
3
+ specs = Dir['spec/innate/**/*.rb']
4
+ specs -= Dir['spec/innate/cache/common.rb']
5
+
6
+ # we ignore adapter as this has extensive specs in rack already.
7
+ ignore = %w[ gem rack bacon innate/adapter\.rb ]
8
+ ignore << 'fiber\.rb' if RUBY_VERSION < '1.9'
9
+
10
+ ignored = ignore.join(',')
11
+
12
+ cmd = "rcov --aggregate coverage.data --sort coverage -t --%s -x '#{ignored}' %s"
13
+
14
+ while spec = specs.shift
15
+ puts '', "Gather coverage for #{spec} ..."
16
+ html = specs.empty? ? 'html' : 'no-html'
17
+ sh(cmd % [html, spec])
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ desc 'publish to github'
2
+ task :release => [:reversion, :gemspec] do
3
+ name, version = GEMSPEC.name, GEMSPEC.version
4
+
5
+ sh("git add MANIFEST CHANGELOG #{name}.gemspec lib/#{name}/version.rb")
6
+
7
+ puts "I added the relevant files, you can now run:", ''
8
+ puts "git commit -m 'Version #{version}'"
9
+ puts "git tag -a -m '#{version}' '#{version}'"
10
+ puts "git push"
11
+ puts
12
+ end
@@ -0,0 +1,8 @@
1
+ desc "update version.rb"
2
+ task :reversion do
3
+ File.open("lib/#{GEMSPEC.name}/version.rb", 'w+') do |file|
4
+ file.puts("module #{PROJECT_MODULE}")
5
+ file.puts(' VERSION = %p' % GEMSPEC.version.to_s)
6
+ file.puts('end')
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manveru-makura
3
3
  version: !ruby/object:Gem::Version
4
- version: 2009.03.01
4
+ version: 2009.03.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael 'manveru' Fellinger
@@ -9,8 +9,8 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-25 00:00:00 -08:00
13
- default_executable:
12
+ date: 2009-03-28 00:00:00 -07:00
13
+ default_executable: makura
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -22,16 +22,6 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 0.8.1
24
24
  version:
25
- - !ruby/object:Gem::Dependency
26
- name: json
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.1.3
34
- version:
35
25
  description: Ruby wrapper around the CouchDB REST API.
36
26
  email: m.fellinger@gmail.com
37
27
  executables:
@@ -43,6 +33,7 @@ extra_rdoc_files: []
43
33
  files:
44
34
  - COPYING
45
35
  - README.md
36
+ - Rakefile
46
37
  - bin/makura
47
38
  - example/blog.rb
48
39
  - example/couch/map/author_all.js
@@ -61,7 +52,18 @@ files:
61
52
  - lib/makura/plugin/pager.rb
62
53
  - lib/makura/server.rb
63
54
  - lib/makura/uuid_cache.rb
55
+ - lib/makura/version.rb
64
56
  - makura.gemspec
57
+ - tasks/bacon.rake
58
+ - tasks/changelog.rake
59
+ - tasks/gem.rake
60
+ - tasks/gem_installer.rake
61
+ - tasks/grancher.rake
62
+ - tasks/install_dependencies.rake
63
+ - tasks/manifest.rake
64
+ - tasks/rcov.rake
65
+ - tasks/release.rake
66
+ - tasks/reversion.rake
65
67
  has_rdoc: true
66
68
  homepage: http://github.com/manveru/makura
67
69
  post_install_message: