Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
technohippy committed Nov 15, 2013
0 parents commit ee74abd
Show file tree
Hide file tree
Showing 15 changed files with 451 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
*.swp
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in pry-parsecom.gemspec
gemspec
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2013 Ando Yasushi

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Pry::Parsecom

TODO: Write a gem description

## Installation

Add this line to your application's Gemfile:

gem 'pry-parsecom'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pry-parsecom

## Usage

TODO: Write usage instructions here

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "bundler/gem_tasks"
10 changes: 10 additions & 0 deletions bin/pry-parsecom
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby

begin
require 'parse/console'
rescue LoadError
require 'rubygems'
require 'parse/console'
end

Parse::Console.start
26 changes: 26 additions & 0 deletions lib/pry-parsecom.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'pry'
require 'pry-parsecom/version'

unless ENV['DISABLE_PRY_PARSECOM']
require 'io/console'
require 'parsecom'
require 'mechanize'
require 'json'
require 'yaml'
require 'pry-parsecom/setting'
require 'pry-parsecom/commands'
# require 'pry-parsecom/model_formatter'

module Parsecom
module_function

def ask_email_and_password
print 'Input parse.com email: '
email = gets
print 'Input parse.com password: '
password = STDIN.noecho(&:gets)
puts
[email.strip, password.strip]
end
end
end
11 changes: 11 additions & 0 deletions lib/pry-parsecom/commands.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# encoding: UTF-8

PryParsecom::Commands = Pry::CommandSet.new

command_glob = File.expand_path('../commands/*.rb', __FILE__)

Dir[command_glob].each do |command|
require command
end

Pry.commands.import PryParsecom::Commands
19 changes: 19 additions & 0 deletions lib/pry-parsecom/commands/refresh_schemas.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# encoding: UTF-8

PryParsecom::Commands.create_command "refresh-schemas" do
group 'Parse.com'
description 'Refresh parse.com schemas'

def options opt
opt.banner <<-EOS.gsub(/^\s+/, '')
Usage: refresh-schemas
Refresh parse.com schemas
EOS
end

def process
PryParsecom::Setting.refresh *PryParsecom.ask_email_and_password
puts PryParsecom::Setting.app_names
end
end
20 changes: 20 additions & 0 deletions lib/pry-parsecom/commands/show_applications.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# encoding: UTF-8

PryParsecom::Commands.create_command "show-applications" do
group 'Parse.com'
description 'Show all parse applications'

def options opt
opt.banner unindent <<-EOS
Usage: show-applications
Show all parse applications
EOS
end

def process
PryParsecom::Setting.app_names.each do |app|
output.puts app
end
end
end
30 changes: 30 additions & 0 deletions lib/pry-parsecom/commands/show_classes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# encoding: UTF-8

PryParsecom::Commands.create_command 'show-classes' do
group 'Parse.com'
description 'Show all parse classes'

def options opt
opt.banner unindent <<-EOS
Usage: show-classes [app_name]
Show all parse classes
EOS
end

def process
if 1 < args.size
output.puts opt
return
end

setting = PryParsecom::Setting.current_setting
unless setting
output.puts 'Now using no app'
end

setting.classes.each do |klass|
output.puts klass
end
end
end
22 changes: 22 additions & 0 deletions lib/pry-parsecom/commands/show_credentials.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# encoding: UTF-8

PryParsecom::Commands.create_command "show-credentials" do
group 'Parse.com'
description 'Show credentials for parse.com'

def options opt
opt.banner unindent <<-EOS
Usage: show-credentials
Show parse.com credentials: application_id, rest_api_key and master_key.
EOS
end

def process
output.puts unindent <<-EOS
APPLICATION_ID: #{Parse.application_id}
REST_API_KEY : #{Parse.api_key}
MASTER_KEY : #{(Parse.master_key || '').sub(/.{30}$/, '*' * 30)}
EOS
end
end
37 changes: 37 additions & 0 deletions lib/pry-parsecom/commands/use.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# encoding: UTF-8

PryParsecom::Commands.create_command "use" do
group 'Parse.com'
description 'Set the current parse.com application'

def options opt
opt.banner <<-EOS.gsub(/^\s+/, '')
Usage: use your-app-name
Set the current parse.com application
EOS
end

def process
unless args.size == 1
output.puts opt
return
end

app_name = args.first.to_s
unless PryParsecom::Setting.has_app? app_name
output.puts "#{app_name} does not exist."
return
end

if PryParsecom.current_app
prev_setting = PryParsecom::Setting.current_setting
prev_setting.reset Parse::Client.default if prev_setting
end

setting = PryParsecom::Setting.by_name app_name
setting.set Parse::Client.default
PryParsecom.current_app = app_name
output.puts "The current app is #{app_name}."
end
end
Loading

0 comments on commit ee74abd

Please sign in to comment.