makura 2009.05.27

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/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
data/tasks/git.rake ADDED
@@ -0,0 +1,46 @@
1
+ namespace :git do
2
+ task :anon do
3
+ sh 'git config remote.origin.url git://github.com/manveru/ramaze'
4
+ puts "You're now accessing ramaze anonymous"
5
+ end
6
+
7
+ task :committer do
8
+ sh 'git config remote.origin.url git@github.com:manveru/ramaze'
9
+ puts "You're now accessing ramaze as committer"
10
+ end
11
+
12
+ desc 'Update from repository'
13
+ task :update do
14
+ puts "Putting your changes on stash"
15
+ sh 'git stash'
16
+
17
+ branch = `git branch`[/^\*\s+(.*)/, 1]
18
+ puts "Current branch is #{branch}"
19
+
20
+ if switch = branch != 'master'
21
+ puts "Switching to master branch"
22
+ sh 'git checkout master'
23
+ end
24
+
25
+ if switch
26
+ puts "Switching to #{branch} branch"
27
+ sh "git checkout '#{branch}'"
28
+ end
29
+
30
+ sh 'git stash apply'
31
+ end
32
+
33
+ desc 'Create patch files to send'
34
+ task :send do
35
+ sh 'git format-patch ^HEAD'
36
+ end
37
+
38
+ desc "show some stats about patches"
39
+ task :patchflow do
40
+ patches = `git rev-list HEAD | wc -l`.to_i
41
+ puts "currently we have #{patches} patches"
42
+ init = Time.parse("Sat Oct 14 04:22:49 JST 2006")
43
+ days = (Time.now - init) / (3600 * 24)
44
+ puts "%d days since init, avg %4.2f patches per day" % [days, patches/days]
45
+ end
46
+ 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,4 @@
1
+ desc 'update manifest'
2
+ task :manifest do
3
+ File.open('MANIFEST', 'w+'){|io| io.puts(*GEMSPEC.files) }
4
+ end
@@ -0,0 +1,32 @@
1
+ namespace :metric do
2
+ desc 'committed changes per file according to git'
3
+ task 'changes' do
4
+ $stdout.sync = true
5
+ out = lambda{|changes, rb| puts("%4d %s" % [changes, rb]) }
6
+ changes = {}
7
+
8
+ print 'counting changes '
9
+
10
+ Dir.glob 'lib/**/*.rb' do |rb|
11
+ count = `git log --pretty=oneline '#{rb}'`.count("\n")
12
+ print '.'
13
+ # out[changes, rb]
14
+ changes[rb] = count
15
+ end
16
+ puts ' done.'
17
+
18
+ sorted = changes.sort_by{|r,c| c }.reverse
19
+
20
+ top = sorted.first(20)
21
+ unless top.empty?
22
+ puts "Top 20:"
23
+ top.each{|(r,c)| out[c,r] }
24
+ end
25
+
26
+ bottom = sorted.last(20) - top
27
+ unless bottom.empty?
28
+ puts "Bottom 20:"
29
+ bottom.each{|(r,c)| out[c,r] }
30
+ end
31
+ end
32
+ end
data/tasks/rcov.rake ADDED
@@ -0,0 +1,23 @@
1
+ desc 'code coverage'
2
+ task :rcov => :clean do
3
+ specs = PROJECT_SPECS
4
+
5
+ ignore = %w[ gem rack bacon innate hpricot nagoro/lib/nagoro ]
6
+
7
+ if RUBY_VERSION >= '1.8.7'
8
+ ignore << 'begin_with' << 'end_with'
9
+ end
10
+ if RUBY_VERSION < '1.9'
11
+ ignore << 'fiber'
12
+ end
13
+
14
+ ignored = ignore.join(',')
15
+
16
+ cmd = "rcov --aggregate coverage.data --sort coverage -t --%s -x '#{ignored}' %s"
17
+
18
+ while spec = specs.shift
19
+ puts '', "Gather coverage for #{spec} ..."
20
+ html = specs.empty? ? 'html' : 'no-html'
21
+ sh(cmd % [html, spec])
22
+ end
23
+ end
@@ -0,0 +1,69 @@
1
+ namespace :release do
2
+ task :all => [:release_github, :release_rubyforge]
3
+
4
+ desc 'Display instructions to release on github'
5
+ task :github => [:reversion, :gemspec] do
6
+ name, version = GEMSPEC.name, GEMSPEC.version
7
+
8
+ puts <<INSTRUCTIONS
9
+ First add the relevant files:
10
+
11
+ git add MANIFEST CHANGELOG #{name}.gemspec lib/#{name}/version.rb
12
+
13
+ Then commit them, tag the commit, and push:
14
+
15
+ git commit -m 'Version #{version}'
16
+ git tag -a -m '#{version}' '#{version}'
17
+ git push
18
+
19
+ INSTRUCTIONS
20
+
21
+ end
22
+
23
+ # TODO: Not tested
24
+ desc 'Display instructions to release on rubyforge'
25
+ task :rubyforge => [:reversion, :gemspec, :package] do
26
+ name, version = GEMSPEC.name, GEMSPEC.version
27
+
28
+ puts <<INSTRUCTIONS
29
+ To publish to rubyforge do following:
30
+
31
+ rubyforge login
32
+ rubyforge add_release #{name} #{name} #{version} pkg/#{name}-#{version}.gem
33
+
34
+ After you have done these steps, see:
35
+
36
+ rake release:rubyforge_archives
37
+
38
+ INSTRUCTIONS
39
+ end
40
+
41
+ desc 'Display instructions to add archives after release:rubyforge'
42
+ task :rubyforge_archives do
43
+ release_id = latest_release_id
44
+
45
+ puts "Adding archives for distro packagers is:", ""
46
+
47
+ Dir["pkg/#{name}-#{version}.{gz,zip}"].each do |file|
48
+ puts "rubyforge add_file #{name} #{name} #{release_id} '#{file}'"
49
+ end
50
+
51
+ puts
52
+ end
53
+ end
54
+
55
+ # Use URI and proper XPATH, something along these lines:
56
+ #
57
+ # a = doc.at('a[@href=~"release_id"]')[:href]
58
+ # release_id = URI(a).query[/release_id=(\w+)/, 1]
59
+ def latest_release_id
60
+ require 'open-uri'
61
+ require 'hpricot'
62
+
63
+ url = "http://rubyforge.org/frs/?group_id=#{PROJECT_RUBYFORGE_GROUP_ID}"
64
+ doc = Hpricot(open(url))
65
+ a = (doc/:a).find{|a| a[:href] =~ /release_id/}
66
+
67
+ version = a.inner_html
68
+ release_id = Hash[*a[:href].split('?').last.split('=').flatten]['release_id']
69
+ 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
data/tasks/todo.rake ADDED
@@ -0,0 +1,27 @@
1
+ desc "show a todolist from all the TODO tags in the source"
2
+ task :todo do
3
+ Dir.glob '{lib,spec}/**/*.rb' do |file|
4
+ lastline = todo = comment = long_comment = false
5
+
6
+ File.readlines(file).each_with_index do |line, lineno|
7
+ lineno += 1
8
+ comment = line =~ /^\s*?#.*?$/
9
+ long_comment = line =~ /^=begin/
10
+ long_comment = line =~ /^=end/
11
+ todo = true if line =~ /TODO/ and (long_comment or comment)
12
+ todo = false if line.gsub('#', '').strip.empty?
13
+ todo = false unless comment or long_comment
14
+ if todo
15
+ unless lastline and lastline + 1 == lineno
16
+ puts
17
+ puts "vim #{file} +#{lineno}"
18
+ end
19
+
20
+ l = line.strip.gsub(/^#\s*/, '')
21
+ print ' ' unless l =~ /^-/
22
+ puts l
23
+ lastline = lineno
24
+ end
25
+ end
26
+ end
27
+ end
data/tasks/traits.rake ADDED
@@ -0,0 +1,21 @@
1
+ desc 'listing of available traits per class/module'
2
+ task 'traits' do
3
+ nodes = Hash.new{|h,k| h[k] = []}
4
+ Dir['lib/**/*.rb'].each do |file|
5
+ content = File.read(file)
6
+ traits = content.grep(/^\s*trait\s*:/)
7
+ traits.each do |trait|
8
+ space = content[0..content.index(trait)].scan(/^\s*(?:class|module)\s+(.*)$/)
9
+ space = space.flatten.join('::')
10
+ nodes[space] << trait.strip
11
+ end
12
+ end
13
+
14
+ nodes.each do |space, traits|
15
+ puts space
16
+ traits.each do |trait|
17
+ print ' ', trait, "\n"
18
+ end
19
+ puts
20
+ end
21
+ end
data/tasks/yard.rake ADDED
@@ -0,0 +1,4 @@
1
+ desc 'Generate YARD documentation'
2
+ task :yard => :clean do
3
+ sh("yardoc -o ydoc -r #{PROJECT_README}")
4
+ end
data/tasks/ycov.rake ADDED
@@ -0,0 +1,22 @@
1
+ begin
2
+ require 'yard'
3
+
4
+ task :ycov => ['.yardoc'] do
5
+ YARD::Registry.load_yardoc
6
+ code_objects = YARD::Registry.paths.map{|path| YARD::Registry.at(path) }
7
+ without_doc, with_doc = code_objects.partition{|obj| obj.docstring.empty? }
8
+
9
+ documented = with_doc.size
10
+ undocumented = without_doc.size
11
+ total = documented + undocumented
12
+ percentage = (documented / 0.01) / total
13
+
14
+ puts "Documentation coverage is %d/%d (%3.1f%%)" % [documented, total, percentage]
15
+ end
16
+
17
+ file '.yardoc' => FileList['lib/**/*.rb'] do
18
+ files = ['lib/**/*.rb']
19
+ options = ['--no-output', '--private']
20
+ YARD::CLI::Yardoc.run(*(options + files))
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: makura
3
+ version: !ruby/object:Gem::Version
4
+ version: 2009.05.27
5
+ platform: ruby
6
+ authors:
7
+ - Michael 'manveru' Fellinger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-27 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rest-client
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.8.1
24
+ version:
25
+ description:
26
+ email: m.fellinger@gmail.com
27
+ executables:
28
+ - makura
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - CHANGELOG
35
+ - COPYING
36
+ - MANIFEST
37
+ - README.md
38
+ - Rakefile
39
+ - bin/makura
40
+ - example/blog.rb
41
+ - example/couch/map/author_all.js
42
+ - example/couch/map/author_posts.js
43
+ - example/couch/map/post_all.js
44
+ - example/couch/map/post_comments.js
45
+ - example/couch/reduce/sum_length.js
46
+ - lib/makura.rb
47
+ - lib/makura/database.rb
48
+ - lib/makura/design.rb
49
+ - lib/makura/error.rb
50
+ - lib/makura/http_methods.rb
51
+ - lib/makura/layout.rb
52
+ - lib/makura/model.rb
53
+ - lib/makura/plugin/localize.rb
54
+ - lib/makura/plugin/pager.rb
55
+ - lib/makura/server.rb
56
+ - lib/makura/uuid_cache.rb
57
+ - lib/makura/version.rb
58
+ - makura.gemspec
59
+ - tasks/authors.rake
60
+ - tasks/bacon.rake
61
+ - tasks/changelog.rake
62
+ - tasks/copyright.rake
63
+ - tasks/gem.rake
64
+ - tasks/gem_installer.rake
65
+ - tasks/git.rake
66
+ - tasks/grancher.rake
67
+ - tasks/manifest.rake
68
+ - tasks/metric_changes.rake
69
+ - tasks/rcov.rake
70
+ - tasks/release.rake
71
+ - tasks/reversion.rake
72
+ - tasks/todo.rake
73
+ - tasks/traits.rake
74
+ - tasks/yard.rake
75
+ - tasks/ycov.rake
76
+ has_rdoc: true
77
+ homepage: http://github.com/manveru/makura
78
+ licenses: []
79
+
80
+ post_install_message:
81
+ rdoc_options: []
82
+
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ version:
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ version:
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 1.3.3
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Ruby wrapper around the CouchDB REST API.
104
+ test_files: []
105
+