jchris-couchrest 0.2.2 → 0.7.99

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/README +39 -0
  2. data/Rakefile +3 -54
  3. data/lib/couchrest.rb +39 -161
  4. data/lib/database.rb +83 -0
  5. data/script/couchdir +58 -0
  6. data/script/couchview +158 -0
  7. data/spec/couchrest_spec.rb +86 -0
  8. data/spec/database_spec.rb +407 -0
  9. metadata +15 -138
  10. data/LICENSE +0 -176
  11. data/README.md +0 -93
  12. data/THANKS.md +0 -18
  13. data/examples/model/example.rb +0 -144
  14. data/examples/word_count/markov +0 -38
  15. data/examples/word_count/views/books/chunked-map.js +0 -3
  16. data/examples/word_count/views/books/united-map.js +0 -1
  17. data/examples/word_count/views/markov/chain-map.js +0 -6
  18. data/examples/word_count/views/markov/chain-reduce.js +0 -7
  19. data/examples/word_count/views/word_count/count-map.js +0 -6
  20. data/examples/word_count/views/word_count/count-reduce.js +0 -3
  21. data/examples/word_count/word_count.rb +0 -46
  22. data/examples/word_count/word_count_query.rb +0 -40
  23. data/examples/word_count/word_count_views.rb +0 -26
  24. data/lib/couchrest/commands/generate.rb +0 -71
  25. data/lib/couchrest/commands/push.rb +0 -103
  26. data/lib/couchrest/core/database.rb +0 -318
  27. data/lib/couchrest/core/design.rb +0 -89
  28. data/lib/couchrest/core/document.rb +0 -96
  29. data/lib/couchrest/core/response.rb +0 -16
  30. data/lib/couchrest/core/server.rb +0 -88
  31. data/lib/couchrest/core/view.rb +0 -4
  32. data/lib/couchrest/helper/pager.rb +0 -103
  33. data/lib/couchrest/helper/streamer.rb +0 -44
  34. data/lib/couchrest/helper/upgrade.rb +0 -51
  35. data/lib/couchrest/mixins.rb +0 -4
  36. data/lib/couchrest/mixins/attachments.rb +0 -31
  37. data/lib/couchrest/mixins/callbacks.rb +0 -483
  38. data/lib/couchrest/mixins/design_doc.rb +0 -64
  39. data/lib/couchrest/mixins/document_queries.rb +0 -48
  40. data/lib/couchrest/mixins/extended_attachments.rb +0 -68
  41. data/lib/couchrest/mixins/extended_document_mixins.rb +0 -6
  42. data/lib/couchrest/mixins/properties.rb +0 -125
  43. data/lib/couchrest/mixins/validation.rb +0 -234
  44. data/lib/couchrest/mixins/views.rb +0 -168
  45. data/lib/couchrest/monkeypatches.rb +0 -119
  46. data/lib/couchrest/more/casted_model.rb +0 -28
  47. data/lib/couchrest/more/extended_document.rb +0 -217
  48. data/lib/couchrest/more/property.rb +0 -40
  49. data/lib/couchrest/support/blank.rb +0 -42
  50. data/lib/couchrest/support/class.rb +0 -191
  51. data/lib/couchrest/validation/auto_validate.rb +0 -163
  52. data/lib/couchrest/validation/contextual_validators.rb +0 -78
  53. data/lib/couchrest/validation/validation_errors.rb +0 -118
  54. data/lib/couchrest/validation/validators/absent_field_validator.rb +0 -74
  55. data/lib/couchrest/validation/validators/confirmation_validator.rb +0 -99
  56. data/lib/couchrest/validation/validators/format_validator.rb +0 -117
  57. data/lib/couchrest/validation/validators/formats/email.rb +0 -66
  58. data/lib/couchrest/validation/validators/formats/url.rb +0 -43
  59. data/lib/couchrest/validation/validators/generic_validator.rb +0 -120
  60. data/lib/couchrest/validation/validators/length_validator.rb +0 -134
  61. data/lib/couchrest/validation/validators/method_validator.rb +0 -89
  62. data/lib/couchrest/validation/validators/numeric_validator.rb +0 -104
  63. data/lib/couchrest/validation/validators/required_field_validator.rb +0 -109
  64. data/spec/couchrest/core/couchrest_spec.rb +0 -201
  65. data/spec/couchrest/core/database_spec.rb +0 -745
  66. data/spec/couchrest/core/design_spec.rb +0 -131
  67. data/spec/couchrest/core/document_spec.rb +0 -311
  68. data/spec/couchrest/core/server_spec.rb +0 -35
  69. data/spec/couchrest/helpers/pager_spec.rb +0 -122
  70. data/spec/couchrest/helpers/streamer_spec.rb +0 -23
  71. data/spec/couchrest/more/casted_extended_doc_spec.rb +0 -40
  72. data/spec/couchrest/more/casted_model_spec.rb +0 -98
  73. data/spec/couchrest/more/extended_doc_attachment_spec.rb +0 -130
  74. data/spec/couchrest/more/extended_doc_spec.rb +0 -509
  75. data/spec/couchrest/more/extended_doc_view_spec.rb +0 -207
  76. data/spec/couchrest/more/property_spec.rb +0 -130
  77. data/spec/couchrest/support/class_spec.rb +0 -59
  78. data/spec/fixtures/attachments/README +0 -3
  79. data/spec/fixtures/attachments/couchdb.png +0 -0
  80. data/spec/fixtures/attachments/test.html +0 -11
  81. data/spec/fixtures/more/article.rb +0 -34
  82. data/spec/fixtures/more/card.rb +0 -20
  83. data/spec/fixtures/more/course.rb +0 -14
  84. data/spec/fixtures/more/event.rb +0 -6
  85. data/spec/fixtures/more/invoice.rb +0 -17
  86. data/spec/fixtures/more/person.rb +0 -8
  87. data/spec/fixtures/more/question.rb +0 -6
  88. data/spec/fixtures/more/service.rb +0 -12
  89. data/spec/fixtures/views/lib.js +0 -3
  90. data/spec/fixtures/views/test_view/lib.js +0 -3
  91. data/spec/fixtures/views/test_view/only-map.js +0 -4
  92. data/spec/fixtures/views/test_view/test-map.js +0 -3
  93. data/spec/fixtures/views/test_view/test-reduce.js +0 -3
  94. data/spec/spec.opts +0 -6
  95. data/spec/spec_helper.rb +0 -26
  96. data/utils/remap.rb +0 -27
  97. data/utils/subset.rb +0 -30
@@ -1,20 +0,0 @@
1
- class Card < CouchRest::ExtendedDocument
2
- # Include the validation module to get access to the validation methods
3
- include CouchRest::Validation
4
- # set the auto_validation before defining the properties
5
- auto_validate!
6
-
7
- # Set the default database to use
8
- use_database TEST_SERVER.default_database
9
-
10
- # Official Schema
11
- property :first_name
12
- property :last_name, :alias => :family_name
13
- property :read_only_value, :read_only => true
14
-
15
- timestamps!
16
-
17
- # Validation
18
- validates_present :first_name
19
-
20
- end
@@ -1,14 +0,0 @@
1
- require File.join(FIXTURE_PATH, 'more', 'question')
2
- require File.join(FIXTURE_PATH, 'more', 'person')
3
-
4
- class Course < CouchRest::ExtendedDocument
5
- use_database TEST_SERVER.default_database
6
-
7
- property :title
8
- property :questions, :cast_as => ['Question']
9
- property :professor, :cast_as => 'Person'
10
- property :final_test_at, :cast_as => 'Time'
11
-
12
- view_by :title
13
- view_by :dept, :ducktype => true
14
- end
@@ -1,6 +0,0 @@
1
- class Event < CouchRest::ExtendedDocument
2
- use_database TEST_SERVER.default_database
3
-
4
- property :subject
5
- property :occurs_at, :cast_as => 'Time', :send => 'parse'
6
- end
@@ -1,17 +0,0 @@
1
- class Invoice < CouchRest::ExtendedDocument
2
- # Include the validation module to get access to the validation methods
3
- include CouchRest::Validation
4
-
5
- # Set the default database to use
6
- use_database TEST_SERVER.default_database
7
-
8
- # Official Schema
9
- property :client_name
10
- property :employee_name
11
- property :location
12
-
13
- # Validation
14
- validates_present :client_name, :employee_name
15
- validates_present :location, :message => "Hey stupid!, you forgot the location"
16
-
17
- end
@@ -1,8 +0,0 @@
1
- class Person < Hash
2
- include ::CouchRest::CastedModel
3
- property :name
4
-
5
- def last_name
6
- name.last
7
- end
8
- end
@@ -1,6 +0,0 @@
1
- class Question < Hash
2
- include ::CouchRest::CastedModel
3
-
4
- property :q
5
- property :a
6
- end
@@ -1,12 +0,0 @@
1
- class Service < CouchRest::ExtendedDocument
2
- # Include the validation module to get access to the validation methods
3
- include CouchRest::Validation
4
- auto_validate!
5
- # Set the default database to use
6
- use_database TEST_SERVER.default_database
7
-
8
- # Official Schema
9
- property :name, :length => 4...20
10
- property :price, :type => Integer
11
-
12
- end
@@ -1,3 +0,0 @@
1
- function globalLib() {
2
- return "fixture";
3
- };
@@ -1,3 +0,0 @@
1
- function justThisView() {
2
- return "fixture";
3
- };
@@ -1,4 +0,0 @@
1
- function(doc) {
2
- //include-lib
3
- emit(null, null);
4
- };
@@ -1,3 +0,0 @@
1
- function(doc) {
2
- emit(null, null);
3
- };
@@ -1,3 +0,0 @@
1
- function(ks,vs,co) {
2
- return vs.length;
3
- };
data/spec/spec.opts DELETED
@@ -1,6 +0,0 @@
1
- --colour
2
- --format
3
- progress
4
- --loadby
5
- mtime
6
- --reverse
data/spec/spec_helper.rb DELETED
@@ -1,26 +0,0 @@
1
- require "rubygems"
2
- require "spec" # Satisfies Autotest and anyone else not using the Rake tasks
3
-
4
- require File.join(File.dirname(__FILE__), '..','lib','couchrest')
5
- # check the following file to see how to use the spec'd features.
6
-
7
- unless defined?(FIXTURE_PATH)
8
- FIXTURE_PATH = File.join(File.dirname(__FILE__), '/fixtures')
9
- SCRATCH_PATH = File.join(File.dirname(__FILE__), '/tmp')
10
-
11
- COUCHHOST = "http://127.0.0.1:5984"
12
- TESTDB = 'couchrest-test'
13
- TEST_SERVER = CouchRest.new
14
- TEST_SERVER.default_database = TESTDB
15
- end
16
-
17
- class Basic < CouchRest::ExtendedDocument
18
- use_database TEST_SERVER.default_database
19
- end
20
-
21
- def reset_test_db!
22
- cr = TEST_SERVER
23
- db = cr.database(TESTDB)
24
- db.recreate! rescue nil
25
- db
26
- end
data/utils/remap.rb DELETED
@@ -1,27 +0,0 @@
1
- require 'rubygems'
2
- require 'couchrest'
3
-
4
- # set the source db and map view
5
- source = CouchRest.new("http://127.0.0.1:5984").database('source-db')
6
- source_view = 'mydesign/view-map'
7
-
8
- # set the target db
9
- target = CouchRest.new("http://127.0.0.1:5984").database('target-db')
10
-
11
-
12
- pager = CouchRest::Pager.new(source)
13
-
14
- # pager will yield once per uniq key in the source view
15
-
16
- pager.key_reduce(source_view, 10000) do |key, values|
17
- # create a doc from the key and the values
18
- example_doc = {
19
- :key => key,
20
- :values => values.uniq
21
- }
22
-
23
- target.save(example_doc)
24
-
25
- # keep us up to date with progress
26
- puts k if (rand > 0.9)
27
- end
data/utils/subset.rb DELETED
@@ -1,30 +0,0 @@
1
- require 'rubygems'
2
- require 'couchrest'
3
-
4
- # subset.rb replicates a percentage of a database to a fresh database.
5
- # use it to create a smaller dataset on which to prototype views.
6
-
7
- # specify the source database
8
- source = CouchRest.new("http://127.0.0.1:5984").database('source-db')
9
-
10
- # specify the target database
11
- target = CouchRest.new("http://127.0.0.1:5984").database('target-db')
12
-
13
- # pager efficiently yields all view rows
14
- pager = CouchRest::Pager.new(source)
15
-
16
- pager.all_docs(1000) do |rows|
17
- docs = rows.collect do |r|
18
- # the percentage of docs to clone
19
- next if rand > 0.1
20
- doc = source.get(r['id'])
21
- doc.delete('_rev')
22
- doc
23
- end.compact
24
- puts docs.length
25
- next if docs.empty?
26
-
27
- puts docs.first['_id']
28
- target.bulk_save(docs)
29
- end
30
-