Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ayanko committed Nov 15, 2011
0 parents commit ddfcf8b
Show file tree
Hide file tree
Showing 14 changed files with 551 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.gem
.bundle
Gemfile.lock
pkg/*
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "http://rubygems.org"

gemspec
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Highrise Assist

highrise_assist is command line for 37signals' highrise.

## Description

TODO

## Installation

$ gem install highrise_assist

## Usage

Usage: ./bin/highrise_assist COMMAND [options]

Commands:
* export - export next highrise items:
* cases
* deals
* people
* companies
* emails
* notes
* comments
* attachments

Common options:
--domain DOMAIN highrise subdomain or full domain name
--token TOKEN highrise API authentication token

Export options:
--tag TAG filter items with given tag name
--directory DIRECTORY working directory
--format FORMAT data format (yaml,xml)
--skip-attachments don't download attachments
--skip-cases don't export cases
--skip-deals don't export deals
--skip-notes don't export notes
--skip-emails don't export emails
--skip-comments don't export comments

Misc options:
-h, --help Show this message
-v, --version Show version

## Export Command

### DESCRIPTION

TODO

### Synopsis

$ highrise_assistexport OPTIONS

### Options

* _domain_ (required) is either your full highrise domain name or subdomain name.
* _token_ (required) is your API authentication token.
* _tag_ is tag name for entities associated with it.
* _directory_ - directory to store export data (default is highrise_data_YYYYMMDDHHMMSS)

### Example

$ highrise_assist export \
--domain MYSUBDOMAIN \
--token 11111111111111111111111111111111 \
--directory highrise_data \
--tag old-clients \
--format xml \
--skip-attachments

Export result:

$ tree --dirsfirst
.
├── cases
│   ├── case-573785-test-case
│   │   ├── attachments
│   │   │   └── 22039573-20111111-p7km4bk33ugutcrrb5mxxw7fjj.jpeg
│   │   ├── case-573785-test-case.xml
│   │   └── note-78169727-test.xml
│   └── case-573786-what-is-highrise
│   ├── attachments
│   └── case-573786-what-is-highrise.xml
├── deals
│   └── deal-1471928-test-deal
│   ├── attachments
│   ├── deal-1471928-test-deal.xml
│   └── note-78499917.xml
└── persons
└── person-92632832-test-test
├── attachments
├── cases
│   └── case-573785-test-case -> ../../../cases/case-573785-test-case
├── deals
│   └── deal-1471928-test-deal -> ../../../deals/deal-1471928-test-deal
└── person-92632832-test-test.xml

1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "bundler/gem_tasks"
5 changes: 5 additions & 0 deletions bin/highrise_assist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env ruby

require "highrise_assist"

HighriseAssist::Runner.run(ARGV)
23 changes: 23 additions & 0 deletions highrise_assist.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "highrise_assist/version"

Gem::Specification.new do |s|
s.name = "highrise_assist"
s.version = HighriseAssist::VERSION
s.authors = ["Andriy Yanko"]
s.email = ["andriy.yanko@gmail.com"]
s.homepage = "https://github.com/railsware/highrise_assist"
s.summary = %q{Assist for 37signals' highrise}
s.description = %q{Assist for 37signals' highrise}

s.rubyforge_project = "highrise_assist"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_runtime_dependency "highrise", "~>3.0.0"
s.add_runtime_dependency "net-http-persistent", "~>2.3"
end
9 changes: 9 additions & 0 deletions lib/highrise_assist.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "highrise_assist/version"

require "highrise_ext"

module HighriseAssist
autoload :Runner, "highrise_assist/runner"
autoload :Command, "highrise_assist/command"
autoload :FileTransfer, "highrise_assist/file_transfer"
end
20 changes: 20 additions & 0 deletions lib/highrise_assist/command.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module HighriseAssist
module Command
class << self
def names
@names ||= []
end

def defined?(name)
names.include?(name)
end

def run(name, options)
self.const_get(name.classify).new(options).run
end
end
end
end

require "highrise_assist/command/base"
require "highrise_assist/command/export"
56 changes: 56 additions & 0 deletions lib/highrise_assist/command/base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
require "fileutils"

module HighriseAssist
module Command
class Base
class << self
def inherited(klass)
Command.names.push klass.name.split("::").last.underscore
super(klass)
end
end

def initialize(options)
@options = options.dup
authenticate
end

attr_reader :options

def run
raise NotImplementedError, "'run' is not implemented by #{self.class.name}"
end

protected

def authenticate
require_option!(:domain, :token)

Highrise::Base.site = "https://" + options[:domain]
Highrise::Base.user = options[:token]
end

def require_option!(*names)
names.each do |name|
options[name].blank? and abort "#{name} option required"
end
end

def log(message)
puts message
end

def file_transfer
@file_transfer ||= FileTransfer.new(options)
end

def download_file(*args)
file_transfer.download(*args)
end

def upload_file(*args)
file_transfer.upload(*args)
end
end
end
end
Loading

0 comments on commit ddfcf8b

Please sign in to comment.