couchup 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.markdown CHANGED
@@ -3,6 +3,117 @@ Couchup
3
3
 
4
4
  This is a command line interface to CouchDb.
5
5
 
6
- I plan to gemify it, but currently you should just bundle install and run bin/couchup
7
6
 
8
- The irb command line opens up and you can type help to list the commands.
7
+ Installaton
8
+ ===========
9
+
10
+ gem install couchup
11
+
12
+ Tested on Ruby 1.9, 1.8.7, REE and Rubunius. (Does not work on jruby for reasons i have not debugged)
13
+
14
+ Usage
15
+ ======
16
+
17
+ Couchup is a command line utility piggybacking on the irb. So you can do all the ruby stuff in it.
18
+ Type help on command line to list the stuff you can do with couchup.
19
+
20
+
21
+ $ couchup
22
+ > help
23
+
24
+
25
+ You see a bunch of commands that you can use.
26
+ Remember this is just an IRB, so the command syntax is a little verbose.
27
+
28
+ create :database, :riders (Note the commas and symbols)
29
+
30
+ Also symbols and strings can be used interchangebly, So the above is the same as
31
+
32
+ create "database", "riders"
33
+
34
+ Some Common Things to do with couchup
35
+ =====================================
36
+
37
+ Basics
38
+ --------
39
+
40
+ Connects to the couch server at foo.bar.com on the default port of 5984
41
+
42
+ > connect "foo.bar.com"
43
+
44
+ Connects to local couch on localhost at 5984
45
+
46
+ > connect
47
+
48
+ To use a specific database switch with.
49
+
50
+ > use :riders
51
+
52
+ Most Couchup commands need you to be on a specific database.
53
+
54
+
55
+ # Getting documents
56
+ --------------------
57
+
58
+ Get all documents from the current database.
59
+
60
+ > get
61
+
62
+ gets docucment by the given ID.
63
+
64
+ > get "id"
65
+
66
+
67
+ and because it is all in ruby you can do stuff like
68
+
69
+ get("123")[:history].first[:name]
70
+
71
+
72
+ #Running views
73
+ --------------
74
+
75
+ There are 2 different commands.
76
+ map Will just run the map function
77
+ view : will run both the map and reduce.
78
+ They have very similar semantics, except for where noted.
79
+
80
+ > map "Rider/all"
81
+
82
+ Found 1 item(s)
83
+
84
+ {"id"=>"78ea2a07be87b6fa0e4afed5d81f3729", "key"=>"78ea2a07be87b6fa0e4afed5d81f3729", "value"=>1, "doc"=>{"_id"=>"78ea2a07be87b6fa0e4afed5d81f3729", "_rev"=>"2-fb5e1207a12f996e287fa23986ac7077", "number"=>"101", "start_time"=>"2011-02-17T18:18:58+05:30", "end_time"=>"2011-02-17T18:20:24+05:30", "type"=>"rider", "couchrest-type"=>"Rider"}}
85
+
86
+ > map "Rider/all", "78ea2a07be87b6fa0e4afed5d81f3729"
87
+
88
+ will return only only the document matching the above key.
89
+
90
+
91
+ The following will query the view with a post to get all the matching keys.
92
+
93
+ map "Rider/all", ["78ea2a07be87b6fa0e4afed5d81f3729", "ee23399aad3f8685e64f455504000d49"]
94
+
95
+ The following will query the view with a startkey and endkey semantics.
96
+
97
+ map "Rider/all", :startkey=> "78ea2a07be87b6fa0e4afed5d81f3729", :endkey=> "ee23399aad3f8685e64f455504000d49"
98
+
99
+
100
+ The same rules apply for *view* command as well, and additionally it takes the group_level parameter as well.
101
+
102
+ view "Rider/all", :startkey=> "78ea2a07be87b6fa0e4afed5d81f3729", :endkey=> "ee23399aad3f8685e64f455504000d49"
103
+
104
+
105
+ # Creating and modifying views.
106
+ -------------------------------
107
+
108
+ It is important to set the EDITOR variable before running couchup, because we use the EDITOR to pop up an edit window
109
+
110
+ > create :view, "Rider/test"
111
+
112
+ Will pop a textmate/emacs/vi window with some templates. If the view exists it will show the existing code. So you can modify it.
113
+
114
+
115
+ To cancel creation of the view, just empty the contents of the file and save.
116
+
117
+
118
+
119
+
@@ -5,7 +5,8 @@ module Couchup
5
5
  commands = param.nil? ? Commands.constants : [param.camelize]
6
6
  commands.each do |stuff|
7
7
  k = Commands.const_get(stuff)
8
- print stuff.underscore; print "\t\t"
8
+ print stuff.underscore
9
+ print (stuff.underscore.size > 10) ? "\t" : "\t\t"
9
10
  puts k.respond_to?(:describe) ? k.describe : "No Help"
10
11
  end
11
12
  end
@@ -25,8 +25,9 @@ module Couchup
25
25
  end
26
26
  response = Couchup.database.view(name, view_params)
27
27
  rows = response["rows"]
28
- puts "Found #{rows.size} items"
28
+ puts "Found #{rows.size} item(s)"
29
29
  rows.each{|r| puts r.inspect}
30
+ nil
30
31
  end
31
32
  end
32
33
  end
@@ -1,3 +1,3 @@
1
1
  module Couchup
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: couchup
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.9
5
+ version: 0.0.10
6
6
  platform: ruby
7
7
  authors:
8
8
  - V Sreekanth