├── .gitignore ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── lib └── omnifocus │ ├── trello.rb │ └── trello │ └── version.rb └── omnifocus-trello.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in omnifocus-trello.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Vesa Vänskä 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # omnifocus-trello 2 | 3 | code: https://github.com/vesan/omnifocus-trello 4 | 5 | Plugin for omnifocus gem to provide Trello BTS synchronization. 6 | 7 | Pulls all cards assigned to a user and creates corresponding tasks to OmniFocus. 8 | Cards in lists having completed cards are marked as done. The user whose tasks 9 | are synced and the lists that are considered as having completed cards are 10 | configurable using the config file. 11 | 12 | ## Usage 13 | 14 | 1. Install 15 | 16 | $ gem install omnifocus-trello 17 | 18 | 2. Sync 19 | 20 | $ of sync 21 | 22 | 3. (On the first run, configuration file will be generated at 23 | ~/.omnifocus-trello.yml. Follow to instructions to get a token.) 24 | 25 | # Changing the default Folder for trello boards. 26 | 27 | By default, the OmniFocus projects created from your trello boards will be stored in a folder called "nerd". To change this, set an environment variable called 'OF_FOLDER'. You can do this by adding the following to your `bash_profile` or similar: 28 | 29 | export OF_FOLDER="My Trello Boards" 30 | 31 | Note that this environment variable is used by the [omnifocus](https://github.com/seattlerb/omnifocus) gem, so will apply to any other gems that rely on that. 32 | 33 | 34 | ## Contributing 35 | 36 | 1. Fork it 37 | 2. Create your feature branch (`git checkout -b my-new-feature`) 38 | 3. Commit your changes (`git commit -am 'Added some feature'`) 39 | 4. Push to the branch (`git push origin my-new-feature`) 40 | 5. Create new Pull Request 41 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | require "bundler/gem_tasks" 3 | -------------------------------------------------------------------------------- /lib/omnifocus/trello.rb: -------------------------------------------------------------------------------- 1 | require "open-uri" 2 | require "json" 3 | require "yaml" 4 | 5 | module OmniFocus::Trello 6 | PREFIX = "TR" 7 | KEY = "3ad9e72a2e2d41a98450ca775a0bafe4" 8 | 9 | def load_or_create_trello_config 10 | path = File.expand_path "~/.omnifocus-trello.yml" 11 | config = YAML.load(File.read(path)) rescue nil 12 | 13 | unless config then 14 | config = { :token => "Open URL https://trello.com/1/authorize?key=#{KEY}&name=OmniFocus+Trello+integration&expiration=never&response_type=token and copy the token from the web page here.", :done_lists => ["Done", "Deployed", "Finished", "Cards in these boards are considered done, you add and remove names to fit your workflow."] } 15 | 16 | File.open(path, "w") { |f| 17 | YAML.dump(config, f) 18 | } 19 | 20 | abort "Created default config in #{path}. Go fill it out." 21 | end 22 | 23 | config 24 | end 25 | 26 | def populate_trello_tasks 27 | config = load_or_create_trello_config 28 | token = config[:token] 29 | done_lists = config[:done_lists] || config[:done_boards] 30 | 31 | boards = fetch_trello_boards(token) 32 | fetch_trello_cards(token).each do |card| 33 | process_trello_card(boards, done_lists, card) 34 | end 35 | end 36 | 37 | def fetch_trello_cards(token) 38 | url = "https://api.trello.com/1/members/my/cards?key=#{KEY}&token=#{token}" 39 | 40 | JSON.parse(open(url).read) 41 | end 42 | 43 | def process_trello_card(boards, done_lists, card) 44 | number = card["idShort"] 45 | description = if card["desc"].length > 0 46 | card["shortUrl"] + "\n\n" + card["desc"] 47 | else 48 | card["shortUrl"] 49 | end 50 | board = boards.find {|candidate| candidate["id"] == card["idBoard"] } 51 | project_name = board["name"] 52 | ticket_id = "#{PREFIX}-#{project_name}##{number}" 53 | title = "#{ticket_id}: #{card["name"]}" 54 | list = board["lists"].find {|candidate| candidate["id"] == card["idList"] } 55 | 56 | # If card is in a "done" list, mark it as completed. 57 | if done_lists.include?(list["name"]) 58 | return 59 | end 60 | 61 | if existing[ticket_id] 62 | bug_db[existing[ticket_id]][ticket_id] = true 63 | return 64 | end 65 | 66 | bug_db[project_name][ticket_id] = [title, description] 67 | end 68 | 69 | def fetch_trello_boards(token) 70 | url = "https://api.trello.com/1/members/my/boards?key=#{KEY}&token=#{token}&lists=open" 71 | JSON.parse(open(url).read) 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /lib/omnifocus/trello/version.rb: -------------------------------------------------------------------------------- 1 | require "omnifocus" 2 | 3 | module OmniFocus::Trello 4 | VERSION = "1.2.2" 5 | end 6 | -------------------------------------------------------------------------------- /omnifocus-trello.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | require File.expand_path('../lib/omnifocus/trello/version', __FILE__) 3 | 4 | Gem::Specification.new do |gem| 5 | gem.authors = ["Vesa Vänskä"] 6 | gem.email = ["vesa@vesavanska.com"] 7 | gem.description = %q{Plugin for omnifocus gem to provide Trello BTS synchronization.} 8 | gem.summary = %q{Plugin for omnifocus gem to provide Trello BTS synchronization.} 9 | gem.homepage = "https://github.com/vesan/omnifocus-trello" 10 | 11 | gem.files = `git ls-files`.split($\) 12 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } 13 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 14 | gem.name = "omnifocus-trello" 15 | gem.require_paths = ["lib"] 16 | gem.version = OmniFocus::Trello::VERSION 17 | 18 | gem.add_dependency "omnifocus", "~> 2.2" 19 | end 20 | --------------------------------------------------------------------------------