pry-parsecom 0.0.5 → 0.0.6
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/README.md +87 -46
- data/lib/pry-parsecom.rb +2 -2
- data/lib/pry-parsecom/commands/show_classes.rb +5 -4
- data/lib/pry-parsecom/commands/show_credentials.rb +1 -1
- data/lib/pry-parsecom/commands/show_schema.rb +1 -1
- data/lib/pry-parsecom/commands/use_application.rb +2 -2
- data/lib/pry-parsecom/model_formatter.rb +24 -0
- data/lib/pry-parsecom/setting.rb +2 -2
- data/lib/pry-parsecom/table.rb +5 -2
- data/lib/pry-parsecom/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,9 +1,63 @@
|
|
1
1
|
# pry-parsecom
|
2
2
|
|
3
|
-
|
3
|
+
pry-parsecom is a REPL for parse.com based on pry. It allows you to manage your parse.com applications through CLI.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
|
+
### Login/Logout
|
8
|
+
|
9
|
+
First of all, you should log in parse.com. Once you log in, your account, credentials and schemas are stored in ~/.pry-console directory.
|
10
|
+
|
11
|
+
$ pry-parsecom
|
12
|
+
[1] pry(main)> login-parse
|
13
|
+
Email for parse.com: andyjpn@gmail.com
|
14
|
+
Password for parse.com:
|
15
|
+
logged in
|
16
|
+
[2] pry(main)> logout-parse
|
17
|
+
logged out
|
18
|
+
|
19
|
+
### Show your applications' information
|
20
|
+
|
21
|
+
There are three main show-something commands to see your applications' information.
|
22
|
+
|
23
|
+
- show-application command lists all names of your parse applications.
|
24
|
+
- show-classes command lists all classes defined in the using parse application.
|
25
|
+
- show-schemas command shows schemas for the given parse class.
|
26
|
+
|
27
|
+
Note that classes and schemas are cached when you call login-parse command. To update them you need to calling the command again.
|
28
|
+
|
29
|
+
### Choose an application
|
30
|
+
|
31
|
+
Before accessing your parse.com application, you have to declare which application you use by calling the use-application command.
|
32
|
+
|
33
|
+
[1] pry(main)> use-application YourApp
|
34
|
+
The current app is YourApp.
|
35
|
+
|
36
|
+
### Use parse objects
|
37
|
+
|
38
|
+
Once you choose an application, parsecom Objects for the application are automatically defined. You can use these objects to manage your parse.com application.
|
39
|
+
|
40
|
+
[1] pry(main)> use-application YourApp
|
41
|
+
The current app is YourApp.
|
42
|
+
[2] pry(main)> post = Post.find(:where => {:body => 'Hello'}).first
|
43
|
+
=> [---
|
44
|
+
__type: Post
|
45
|
+
author:
|
46
|
+
__type: Pointer
|
47
|
+
className: _User
|
48
|
+
objectId: ZybBXQEIjI
|
49
|
+
body: Hello
|
50
|
+
comments: <Ralations>
|
51
|
+
...snip...
|
52
|
+
[3] pry(main)> post.body = 'World!'
|
53
|
+
=> "World!"
|
54
|
+
[4] pry(main)> post.save!
|
55
|
+
=> true
|
56
|
+
|
57
|
+
To know more detail about the parsecom library, see http://github.com/technohippy/parsecom
|
58
|
+
|
59
|
+
### Examples
|
60
|
+
|
7
61
|
$ pry-parsecom
|
8
62
|
[1] pry(main)> help parse.com
|
9
63
|
Parse.com
|
@@ -15,37 +69,42 @@ CLI for parse.com
|
|
15
69
|
show-schema Show a parse class schema
|
16
70
|
use-application Set the current parse.com application
|
17
71
|
[2] pry(main)> show-applications
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
72
|
+
Email for parse.com: andyjpn@gmail.com
|
73
|
+
Password for parse.com:
|
74
|
+
Name | Using
|
75
|
+
================
|
76
|
+
FakeApp |
|
77
|
+
FakeApp2 |
|
78
|
+
(cached at: 2013-11-18 13:59:48 +0900)
|
24
79
|
[3] pry(main)> use-application FakeApp
|
25
80
|
The current app is FakeApp.
|
26
81
|
[4] pry(main)> show-applications
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
82
|
+
Name | Using
|
83
|
+
================
|
84
|
+
FakeApp | *
|
85
|
+
FakeApp2 |
|
86
|
+
(cached at: 2013-11-18 13:59:48 +0900)
|
31
87
|
[5] pry(main)> show-credentials
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
88
|
+
Key | Value
|
89
|
+
=========================================================
|
90
|
+
APPLICATION_ID | abcdefghijklmnopqrstuvwxyzabcdefghijklmn
|
91
|
+
REST_API_KEY | abcdefghijklmnopqrstuvwxyzabcdefghijklmn
|
92
|
+
MASTER_KEY | abcdefghij******************************
|
93
|
+
(cached at: 2013-11-18 13:59:48 +0900)
|
37
94
|
[6] pry(main)> show-classes
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
Post
|
42
|
-
|
95
|
+
Name | Class
|
96
|
+
=====================
|
97
|
+
Comment | Comment
|
98
|
+
Post | Post
|
99
|
+
_User | Parse::User
|
100
|
+
(cached at: 2013-11-18 13:59:48 +0900)
|
43
101
|
[7] pry(main)> show-schema Post
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
102
|
+
Name | Type
|
103
|
+
============================
|
104
|
+
author | pointer<_User>
|
105
|
+
body | string
|
106
|
+
comments | relation<Comment>
|
107
|
+
(cached at: 2013-11-18 13:59:48 +0900)
|
49
108
|
[8] pry(main)> Post.find :all
|
50
109
|
=> [---
|
51
110
|
__type: Post
|
@@ -55,28 +114,10 @@ CLI for parse.com
|
|
55
114
|
objectId: ZybBXQEIjI
|
56
115
|
body: Hello
|
57
116
|
comments: <Ralations>
|
58
|
-
|
59
|
-
updatedAt: '2013-11-17T13:38:30.908Z'
|
60
|
-
objectId: lNKMPYSCTw
|
61
|
-
,
|
62
|
-
---
|
63
|
-
__type: Post
|
64
|
-
author:
|
65
|
-
__type: Pointer
|
66
|
-
className: _User
|
67
|
-
objectId: ZybBXQEIjI
|
68
|
-
body: World
|
69
|
-
comments: <Ralations>
|
70
|
-
createdAt: '2013-11-17T14:33:00.134Z'
|
71
|
-
updatedAt: '2013-11-17T14:33:25.436Z'
|
72
|
-
objectId: ur2StDqAFD
|
73
|
-
]
|
117
|
+
...snip...
|
74
118
|
[9] pry(main)> logout
|
75
119
|
logged out
|
76
|
-
[10] pry(main)>
|
77
|
-
Name | Selected
|
78
|
-
===================
|
79
|
-
[11] pry(main)> exit
|
120
|
+
[10] pry(main)> exit
|
80
121
|
|
81
122
|
## Contributing
|
82
123
|
|
data/lib/pry-parsecom.rb
CHANGED
@@ -16,9 +16,9 @@ if ENV['ENABLE_PRY_PARSECOM']
|
|
16
16
|
module_function
|
17
17
|
|
18
18
|
def ask_email_and_password
|
19
|
-
print '
|
19
|
+
print 'Email for parse.com: '
|
20
20
|
email = gets
|
21
|
-
print '
|
21
|
+
print 'Password for parse.com: '
|
22
22
|
password = STDIN.noecho(&:gets)
|
23
23
|
puts
|
24
24
|
[email.strip, password.strip]
|
@@ -14,7 +14,7 @@ PryParsecom::Commands.create_command 'show-classes' do
|
|
14
14
|
|
15
15
|
def process
|
16
16
|
if 1 < args.size
|
17
|
-
output.puts
|
17
|
+
output.puts opts
|
18
18
|
return
|
19
19
|
end
|
20
20
|
|
@@ -26,9 +26,10 @@ PryParsecom::Commands.create_command 'show-classes' do
|
|
26
26
|
return
|
27
27
|
end
|
28
28
|
|
29
|
-
table = PryParsecom::Table.new %w(Name)
|
30
|
-
setting.classes.each do |
|
31
|
-
|
29
|
+
table = PryParsecom::Table.new %w(Name Class)
|
30
|
+
setting.classes.each do |parse_class|
|
31
|
+
class_name = parse_class.sub /^_/, 'Parse::'
|
32
|
+
table.add_row [parse_class, class_name]
|
32
33
|
end
|
33
34
|
output.puts table
|
34
35
|
output.puts "(cached at: #{PryParsecom::Setting.cache_time})"
|
@@ -15,7 +15,7 @@ PryParsecom::Commands.create_command 'use-application' do
|
|
15
15
|
def process
|
16
16
|
PryParsecom::Setting.setup_if_needed
|
17
17
|
unless args.size == 1
|
18
|
-
output.puts
|
18
|
+
output.puts opts
|
19
19
|
return
|
20
20
|
end
|
21
21
|
app_name = args.first.to_s
|
@@ -30,7 +30,7 @@ PryParsecom::Commands.create_command 'use-application' do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
setting = PryParsecom::Setting[app_name]
|
33
|
-
setting.
|
33
|
+
setting.apply
|
34
34
|
PryParsecom::Setting.current_app = app_name
|
35
35
|
output.puts "The current app is #{app_name}."
|
36
36
|
end
|
@@ -3,5 +3,29 @@ module Parse
|
|
3
3
|
def to_s
|
4
4
|
to_h.to_yaml
|
5
5
|
end
|
6
|
+
|
7
|
+
def inspect
|
8
|
+
to_s
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Array
|
14
|
+
#alias_method :inspect_original, :inspect
|
15
|
+
alias_method :inspect_original, :to_s
|
16
|
+
#def inspect
|
17
|
+
def to_s
|
18
|
+
if self.empty? || self.all? {|e| e === Parse::Object}
|
19
|
+
puts self.first.class.name
|
20
|
+
heads = self.first.to_h.keys
|
21
|
+
table = PryParsecom::Table.new heads
|
22
|
+
self.each do |e|
|
23
|
+
table.add_row heads.map{|h| e[h]}
|
24
|
+
end
|
25
|
+
table.to_s
|
26
|
+
else
|
27
|
+
puts :inspect_original
|
28
|
+
inspect_original
|
29
|
+
end
|
6
30
|
end
|
7
31
|
end
|
data/lib/pry-parsecom/setting.rb
CHANGED
@@ -73,7 +73,7 @@ module PryParsecom
|
|
73
73
|
end
|
74
74
|
unless settings.empty?
|
75
75
|
settings = YAML.load settings
|
76
|
-
|
76
|
+
self.current_app = settings['current_app']
|
77
77
|
end
|
78
78
|
return true
|
79
79
|
end
|
@@ -176,7 +176,7 @@ module PryParsecom
|
|
176
176
|
app_name, app_id, api_key, master_key, schemas
|
177
177
|
end
|
178
178
|
|
179
|
-
def
|
179
|
+
def apply
|
180
180
|
Parse.credentials :application_id => @app_id, :api_key => @api_key, :master_key => @master_key
|
181
181
|
Parse::Client.default.application_id = @app_id
|
182
182
|
Parse::Client.default.api_key = @api_key
|
data/lib/pry-parsecom/table.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
module PryParsecom
|
2
2
|
class Table
|
3
|
-
|
3
|
+
attr_accessor :indent
|
4
|
+
|
5
|
+
def initialize heads, indent=' ', rows=[]
|
4
6
|
@heads = heads
|
7
|
+
@indent = indent
|
5
8
|
@col_widths = Hash.new 0
|
6
9
|
@heads.each do |head|
|
7
10
|
@col_widths[head] = head.size
|
@@ -51,7 +54,7 @@ module PryParsecom
|
|
51
54
|
}.join " | "
|
52
55
|
ret += "\n"
|
53
56
|
end
|
54
|
-
ret
|
57
|
+
ret.gsub /^/, @indent
|
55
58
|
end
|
56
59
|
end
|
57
60
|
end
|
data/lib/pry-parsecom/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-parsecom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pry
|