couch_tomato 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ class CouchMigrationGenerator < Rails::Generator::Base
2
+ attr_accessor :migration_class_name
3
+
4
+ def manifest
5
+ record do |m|
6
+ db_name = args.shift
7
+ migration_name = args.shift
8
+
9
+ dir = "couchdb/migrate/#{db_name}"
10
+ migration_file_name = "#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_#{migration_name}.rb"
11
+ @migration_class_name = migration_name.camelize
12
+
13
+ m.directory(dir)
14
+ m.template('migration.rb', File.join(dir, migration_file_name))
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ class <%= migration_class_name %> < CouchTomato::Migration
2
+ def self.up(doc)
3
+
4
+ end
5
+
6
+ def self.down(doc)
7
+
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ class CouchViewGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ db_name = args.shift
5
+ full_view_name = args.shift
6
+
7
+ design_doc = full_view_name.index('/') ? full_view_name.split('/').first : nil
8
+ view_name = full_view_name.split('/').last
9
+
10
+ # should only contain map, reduce, or be empty (only map)
11
+ bad_option = false
12
+ if args.empty?
13
+ args << 'map'
14
+ else
15
+ args.each do |arg|
16
+ if arg != 'map' && arg != 'reduce'
17
+ puts "Invalid option '#{arg}': expecting 'map' and/or 'reduce'"
18
+ bad_option = true
19
+ end
20
+ end
21
+
22
+ next if bad_option
23
+ end
24
+
25
+ dir = File.join(['couchdb', 'views', db_name, design_doc].compact)
26
+
27
+ m.directory(dir)
28
+ args.each do |method|
29
+ m.file("#{method}.js", File.join(dir, "#{view_name}-#{method}.js"), :collision => :ask)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ function(doc) {
2
+
3
+ }
@@ -0,0 +1,3 @@
1
+ function(keys, values) {
2
+
3
+ }
@@ -15,8 +15,8 @@ module CouchTomato
15
15
  docs.each do |doc|
16
16
  next if /^_design/ =~ doc['id']
17
17
  send(direction, doc['doc'])
18
- db.save_doc(doc['doc'])
19
18
  end
19
+ db.bulk_save(docs)
20
20
  end
21
21
 
22
22
  case direction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couch_tomato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Plastic Trophy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-20 00:00:00 -07:00
12
+ date: 2009-10-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -53,6 +53,11 @@ extra_rdoc_files:
53
53
  files:
54
54
  - MIT-LICENSE.txt
55
55
  - README.md
56
+ - generators/couch_migration/couch_migration_generator.rb
57
+ - generators/couch_migration/templates/migration.rb
58
+ - generators/couch_view/couch_view_generator.rb
59
+ - generators/couch_view/templates/map.js
60
+ - generators/couch_view/templates/reduce.js
56
61
  - init.rb
57
62
  - lib/core_ext/date.rb
58
63
  - lib/core_ext/duplicable.rb