trellish 0.0.3 → 0.0.4
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/bin/trellish +2 -1
 - data/lib/trellish.rb +2 -1
 - data/lib/trellish/card.rb +4 -14
 - data/lib/trellish/git.rb +30 -8
 - data/lib/trellish/version.rb +1 -1
 - data/trellish.example.yml +10 -1
 - data/trellish.gemspec +2 -1
 - metadata +20 -4
 
    
        data/bin/trellish
    CHANGED
    
    | 
         @@ -23,7 +23,8 @@ end 
     | 
|
| 
       23 
23 
     | 
    
         
             
            Trellish.configure(
         
     | 
| 
       24 
24 
     | 
    
         
             
              trello_api_key: config_file['trello_api_key'],
         
     | 
| 
       25 
25 
     | 
    
         
             
              trello_oauth_secret: config_file['trello_oauth_secret'],
         
     | 
| 
       26 
     | 
    
         
            -
              trello_oauth_token: config_file['trello_oauth_token'] 
     | 
| 
      
 26 
     | 
    
         
            +
              trello_oauth_token: config_file['trello_oauth_token'],
         
     | 
| 
      
 27 
     | 
    
         
            +
              github_oauth_token: config_file['github_oauth_token'])
         
     | 
| 
       27 
28 
     | 
    
         | 
| 
       28 
29 
     | 
    
         
             
            card = Trellish::Card.new(ARGV[0])
         
     | 
| 
       29 
30 
     | 
    
         
             
            card.finish
         
     | 
    
        data/lib/trellish.rb
    CHANGED
    
    | 
         @@ -10,7 +10,8 @@ module Trellish 
     | 
|
| 
       10 
10 
     | 
    
         
             
              @config = {
         
     | 
| 
       11 
11 
     | 
    
         
             
                trello_api_key: 'TRELLO_API_KEY',
         
     | 
| 
       12 
12 
     | 
    
         
             
                trello_oauth_secret: 'TRELLO_OAUTH_SECRET',
         
     | 
| 
       13 
     | 
    
         
            -
                trello_oauth_token: 'TRELLO_OAUTH_TOKEN'
         
     | 
| 
      
 13 
     | 
    
         
            +
                trello_oauth_token: 'TRELLO_OAUTH_TOKEN',
         
     | 
| 
      
 14 
     | 
    
         
            +
                github_oauth_token: 'GITHUB_OAUTH_TOKEN'
         
     | 
| 
       14 
15 
     | 
    
         
             
              }
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
17 
     | 
    
         
             
              @valid_config_keys = @config.keys
         
     | 
    
        data/lib/trellish/card.rb
    CHANGED
    
    | 
         @@ -10,23 +10,13 @@ module Trellish 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  @card = Trello::Card.find(parse_card_id(card_id_or_url))
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                def  
     | 
| 
       14 
     | 
    
         
            -
                  @card. 
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                def add_merge_to_master_item
         
     | 
| 
       18 
     | 
    
         
            -
                  checklist = @card.checklists.first
         
     | 
| 
       19 
     | 
    
         
            -
                  if checklist.nil?
         
     | 
| 
       20 
     | 
    
         
            -
                    new_checklist = Checklist.create(name: 'Checklist', board_id: @card.board_id)
         
     | 
| 
       21 
     | 
    
         
            -
                    @card.add_checklist(new_checklist)
         
     | 
| 
       22 
     | 
    
         
            -
                    checklist = @card.refresh!.checklists.first
         
     | 
| 
       23 
     | 
    
         
            -
                  end
         
     | 
| 
       24 
     | 
    
         
            -
                  checklist.add_item('Merge to master')
         
     | 
| 
      
 13 
     | 
    
         
            +
                def add_pull_request_link
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @card.description = "[Pull Request] (#{github_pull_request_url})\n\n#{@card.description}"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  @card.save
         
     | 
| 
       25 
16 
     | 
    
         
             
                end
         
     | 
| 
       26 
17 
     | 
    
         | 
| 
       27 
18 
     | 
    
         
             
                def finish
         
     | 
| 
       28 
     | 
    
         
            -
                   
     | 
| 
       29 
     | 
    
         
            -
                  add_merge_to_master_item
         
     | 
| 
      
 19 
     | 
    
         
            +
                  add_pull_request_link
         
     | 
| 
       30 
20 
     | 
    
         
             
                  remove_all
         
     | 
| 
       31 
21 
     | 
    
         
             
                  move_to_qa
         
     | 
| 
       32 
22 
     | 
    
         
             
                end
         
     | 
    
        data/lib/trellish/git.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'faraday'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Trellish
         
     | 
| 
       2 
4 
     | 
    
         
             
              module Git
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
         @@ -5,24 +7,44 @@ module Trellish 
     | 
|
| 
       5 
7 
     | 
    
         
             
                  @current_git_branch ||= `cat .git/head`.split('/').last
         
     | 
| 
       6 
8 
     | 
    
         
             
                end
         
     | 
| 
       7 
9 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                def  
     | 
| 
       9 
     | 
    
         
            -
                  @ 
     | 
| 
      
 10 
     | 
    
         
            +
                def github_pull_request_url
         
     | 
| 
      
 11 
     | 
    
         
            +
                  return @github_pull_request_url if @github_pull_request_url
         
     | 
| 
      
 12 
     | 
    
         
            +
                  conn = Faraday.new(:url => 'https://api.github.com', :ssl => {:ca_file => '/System/Library/OpenSSL/certs/ca-certificates.crt'}) do |faraday|
         
     | 
| 
      
 13 
     | 
    
         
            +
                    faraday.request :url_encoded
         
     | 
| 
      
 14 
     | 
    
         
            +
                    faraday.adapter ::Faraday.default_adapter
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
                  response = conn.post do |req|
         
     | 
| 
      
 17 
     | 
    
         
            +
                    req.url "/repos/#{git_repository_owner}/#{git_repository_name}/pulls"
         
     | 
| 
      
 18 
     | 
    
         
            +
                    req.headers['Content-Type'] = 'application/json'
         
     | 
| 
      
 19 
     | 
    
         
            +
                    req.headers['Authorization'] = "token #{Trellish.config[:github_oauth_token]}"
         
     | 
| 
      
 20 
     | 
    
         
            +
                    req.body = %Q|{
         
     | 
| 
      
 21 
     | 
    
         
            +
                      "title": "#{pull_request_title}",
         
     | 
| 
      
 22 
     | 
    
         
            +
                      "base": "master",
         
     | 
| 
      
 23 
     | 
    
         
            +
                      "head": "#{git_repository_owner}:#{current_git_branch}"
         
     | 
| 
      
 24 
     | 
    
         
            +
                    }|.gsub(/\s/, '')
         
     | 
| 
      
 25 
     | 
    
         
            +
                    true
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  @github_pull_request_url = JSON.parse(response.body)["html_url"]
         
     | 
| 
       10 
28 
     | 
    
         
             
                end
         
     | 
| 
       11 
29 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                def  
     | 
| 
       13 
     | 
    
         
            -
                  @ 
     | 
| 
      
 30 
     | 
    
         
            +
                def git_repository_name
         
     | 
| 
      
 31 
     | 
    
         
            +
                  @git_repository_name ||= matches[2]
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                def git_repository_owner
         
     | 
| 
      
 35 
     | 
    
         
            +
                  @git_repository_owner ||= matches[1]
         
     | 
| 
       14 
36 
     | 
    
         
             
                end
         
     | 
| 
       15 
37 
     | 
    
         | 
| 
       16 
38 
     | 
    
         
             
                def matches
         
     | 
| 
       17 
39 
     | 
    
         
             
                  @matches ||= matches = remote_url.match(%r|^git@github.com:([^/]*)\/([^\.]*)\.git$|)
         
     | 
| 
       18 
40 
     | 
    
         
             
                end
         
     | 
| 
       19 
41 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                def  
     | 
| 
       21 
     | 
    
         
            -
                  @ 
     | 
| 
      
 42 
     | 
    
         
            +
                def pull_request_title
         
     | 
| 
      
 43 
     | 
    
         
            +
                  @pull_request_title ||= `git show -s --format=%s head`
         
     | 
| 
       22 
44 
     | 
    
         
             
                end
         
     | 
| 
       23 
45 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                def  
     | 
| 
       25 
     | 
    
         
            -
                  @ 
     | 
| 
      
 46 
     | 
    
         
            +
                def remote_url
         
     | 
| 
      
 47 
     | 
    
         
            +
                  @remote_url ||= `git config remote.origin.url`
         
     | 
| 
       26 
48 
     | 
    
         
             
                end
         
     | 
| 
       27 
49 
     | 
    
         | 
| 
       28 
50 
     | 
    
         
             
              end
         
     | 
    
        data/lib/trellish/version.rb
    CHANGED
    
    
    
        data/trellish.example.yml
    CHANGED
    
    | 
         @@ -1,7 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Sign in to Trello and go here https://trello.com/1/appKey/generate.
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Copy "Key" from that page to tello_api_key.
         
     | 
| 
       3 
3 
     | 
    
         
             
            trello_api_key: numbers_and_letters_and_stuff
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       4 
5 
     | 
    
         
             
            # Copy "Secret (for OAuth signing)" from that page to tello_oauth_secret.
         
     | 
| 
       5 
6 
     | 
    
         
             
            trello_oauth_secret: numbers_and_letters_and_stuff
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            # Visit
         
     | 
| 
      
 9 
     | 
    
         
            +
            #   http://trello.com/1/connect?key=TRELLO_API_KEY_FROM_ABOVE&name=Trellish&response_type=token&scope=read,write&expiration=never
         
     | 
| 
      
 10 
     | 
    
         
            +
            # and copy the token to trello_oauth_token here.
         
     | 
| 
       7 
11 
     | 
    
         
             
            trello_oauth_token: numbers_and_letters_and_stuff
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            # Run:
         
     | 
| 
      
 14 
     | 
    
         
            +
            #   curl -u 'username' -d '{"scopes":["repo"],"note":"Trellish"}' https://api.github.com/authorizations
         
     | 
| 
      
 15 
     | 
    
         
            +
            # and copy the token parameter from the response here.
         
     | 
| 
      
 16 
     | 
    
         
            +
            github_oauth_token: numbers_and_letters_and_stuff
         
     | 
    
        data/trellish.gemspec
    CHANGED
    
    | 
         @@ -4,7 +4,7 @@ require File.expand_path('../lib/trellish/version', __FILE__) 
     | 
|
| 
       4 
4 
     | 
    
         
             
            Gem::Specification.new do |gem|
         
     | 
| 
       5 
5 
     | 
    
         
             
              gem.authors       = ["Wes Gibbs"]
         
     | 
| 
       6 
6 
     | 
    
         
             
              gem.email         = ["wesgibbs@gmail.com"]
         
     | 
| 
       7 
     | 
    
         
            -
              gem.description   = %q{ 
     | 
| 
      
 7 
     | 
    
         
            +
              gem.description   = %q{Create a pull request, put link to it on the card, remove everyone and move the card to the QA list}
         
     | 
| 
       8 
8 
     | 
    
         
             
              gem.summary       = %q{Finish a Trello card}
         
     | 
| 
       9 
9 
     | 
    
         
             
              gem.homepage      = "http://rubygems.org/gems/trellish"
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
         @@ -15,5 +15,6 @@ Gem::Specification.new do |gem| 
     | 
|
| 
       15 
15 
     | 
    
         
             
              gem.require_paths = ["lib"]
         
     | 
| 
       16 
16 
     | 
    
         
             
              gem.version       = Trellish::VERSION
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
              gem.add_dependency 'oauth2', '>=0.7.0'
         
     | 
| 
       18 
19 
     | 
    
         
             
              gem.add_dependency 'ruby-trello-wgibbs', '>=0.4.4'
         
     | 
| 
       19 
20 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: trellish
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.4
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,8 +9,24 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2012- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-10-02 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 15 
     | 
    
         
            +
              name: oauth2
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: 0.7.0
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 25 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 26 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: 0.7.0
         
     | 
| 
       14 
30 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
31 
     | 
    
         
             
              name: ruby-trello-wgibbs
         
     | 
| 
       16 
32 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -27,8 +43,8 @@ dependencies: 
     | 
|
| 
       27 
43 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
       28 
44 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       29 
45 
     | 
    
         
             
                    version: 0.4.4
         
     | 
| 
       30 
     | 
    
         
            -
            description:  
     | 
| 
       31 
     | 
    
         
            -
               
     | 
| 
      
 46 
     | 
    
         
            +
            description: Create a pull request, put link to it on the card, remove everyone and
         
     | 
| 
      
 47 
     | 
    
         
            +
              move the card to the QA list
         
     | 
| 
       32 
48 
     | 
    
         
             
            email:
         
     | 
| 
       33 
49 
     | 
    
         
             
            - wesgibbs@gmail.com
         
     | 
| 
       34 
50 
     | 
    
         
             
            executables:
         
     |