trello_cli 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.3-p327@trello_cli --create
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ script: "rake spec"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trello-cli.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Brett Weaver
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.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ [![Build Status](https://secure.travis-ci.org/brettweavnet/trello_cli.png)](http://travis-ci.org/brettweavnet/trello_cli)
2
+
3
+ # trello_cli
4
+
5
+ Simple Ruby Trello Command Line Interface
6
+
7
+ ## Installation
8
+
9
+ Install the trello_cli gem
10
+
11
+ gem install trello_cli
12
+
13
+ ## Setup
14
+
15
+ Get API key:
16
+
17
+ https://trello.com/1/appKey/generate
18
+
19
+ Get member token:
20
+
21
+ https://trello.com/1/connect?key=$YOUR_API_KEY&name=MY_APP_NAME&response_type=token
22
+
23
+ Set the environment variables:
24
+
25
+ TRELLO_DEVELOPER_PUBLIC_KEY=api_key
26
+ TRELLO_MEMBER_TOKEN=member_token
27
+
28
+ ## Usage
29
+
30
+ The CLI takes the following form:
31
+
32
+ trello TARGET COMMAND OPTIONS
33
+
34
+ For example, to list the boards available to the given credentials:
35
+
36
+ trello board list
37
+
38
+ to list the lists for a given board id:
39
+
40
+ trello list list -b 123
41
+
42
+ To create a card:
43
+
44
+ trello card create -b 123 -l 321 -n 'card name' -d 'card description'
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Run specs'
6
+ RSpec::Core::RakeTask.new do |t|
7
+ t.rspec_opts = %w(--color)
8
+ end
data/bin/trello ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'trello_cli'
4
+
5
+ TrelloCli::CLI::Run.new.run
@@ -0,0 +1,35 @@
1
+ module TrelloCli
2
+ module CLI
3
+ class Board
4
+
5
+ include Shared
6
+
7
+ def initialize
8
+ @options = {}
9
+ end
10
+
11
+ def list
12
+ list_boards.each do |list|
13
+ name = list.attributes[:name]
14
+ id = list.attributes[:id]
15
+
16
+ puts "#{name} ( #{id} )"
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def list_boards
23
+ lb = TrelloCli::Requests::ListBoards.new
24
+ lb.list
25
+ end
26
+
27
+ def option_parser(options=@options)
28
+ OptionParser.new do |opts|
29
+ opts.banner = "Usage: trello board [list]"
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,55 @@
1
+ module TrelloCli
2
+ module CLI
3
+ class Card
4
+
5
+ include Shared
6
+
7
+ def initialize
8
+ @options = {}
9
+ end
10
+
11
+ def create
12
+ parse_options
13
+
14
+ card = create_card
15
+ name = card.attributes[:name]
16
+ description = card.attributes[:description]
17
+
18
+ puts "Card Created."
19
+ puts "Name : #{name}"
20
+ puts "Description : #{description}"
21
+ end
22
+
23
+ private
24
+
25
+ def create_card
26
+ cc = TrelloCli::Requests::CreateCard.new
27
+ cc.create @options
28
+ end
29
+
30
+ def option_parser
31
+ OptionParser.new do |opts|
32
+ opts.banner = "Usage: trello card [create] [options]"
33
+
34
+ opts.on("-b", "--board [BOARD]", "Trello Board Id") do |b|
35
+ @options[:board_id] = b
36
+ end
37
+
38
+ opts.on("-d", "--description [DESCRIPTION]", "Description Of Card") do |d|
39
+ @options[:description] = d
40
+ end
41
+
42
+ opts.on("-l", "--list [LIST]", "List Of Card") do |l|
43
+ @options[:list_id] = l
44
+ end
45
+
46
+ opts.on("-n", "--name [NAME]", "Name Of Card") do |n|
47
+ @options[:name] = n
48
+ end
49
+ end
50
+ end
51
+
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,43 @@
1
+ module TrelloCli
2
+ module CLI
3
+ class List
4
+
5
+ include Shared
6
+
7
+ def initialize
8
+ @options = {}
9
+ end
10
+
11
+ def list
12
+ parse_options
13
+
14
+ list_lists.each do |list|
15
+ name = list.attributes[:name]
16
+ id = list.attributes[:id]
17
+
18
+ puts "#{name} ( #{id} )"
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def list_lists
25
+ ll = TrelloCli::Requests::ListLists.new
26
+ ll.list @options
27
+ end
28
+
29
+ def option_parser
30
+ OptionParser.new do |opts|
31
+
32
+ opts.banner = "Usage: trello list [list] [options]"
33
+
34
+ opts.on("-b", "--board [BOARD]", "Trello Board Id") do |b|
35
+ @options[:board_id] = b
36
+ end
37
+
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,35 @@
1
+ module TrelloCli
2
+ module CLI
3
+ class Run
4
+ def run
5
+ target = ARGV.shift
6
+ cmd = ARGV.shift || 'help'
7
+
8
+ case target
9
+ when *targets
10
+ target_object = CLI.const_get(target.capitalize).new
11
+
12
+ cmd = 'help' unless target_object.actions.include?(cmd.to_sym)
13
+
14
+ target_object.send cmd
15
+ when '-v'
16
+ puts TrelloCli::VERSION
17
+ else
18
+ puts "Unkown target: '#{target}'." unless target == '-h'
19
+ puts "trello [#{targets.join('|')}] [command] OPTIONS"
20
+ puts "Append -h for help on specific target."
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def targets
27
+ klasses = TrelloCli::CLI.constants.reject do |c|
28
+ ( c == :Run ) || ( c == :Shared )
29
+ end
30
+ klasses.map { |k| k.to_s.downcase }
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ module TrelloCli
2
+ module CLI
3
+ module Shared
4
+
5
+ def actions(obj = self)
6
+ (obj.methods - obj.class.superclass.instance_methods).sort
7
+ end
8
+
9
+ def parse_options
10
+ option_parser.parse!
11
+ end
12
+
13
+ def help
14
+ puts option_parser.help
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ require 'optparse'
2
+
3
+ require 'trello_cli/cli/shared'
4
+ require 'trello_cli/cli/run'
5
+
6
+ require 'trello_cli/cli/board'
7
+ require 'trello_cli/cli/card'
8
+ require 'trello_cli/cli/list'
@@ -0,0 +1,21 @@
1
+ module TrelloCli
2
+ module Requests
3
+ class CreateCard
4
+
5
+ include Shared
6
+
7
+ def initialize
8
+ connect_to_trello
9
+ end
10
+
11
+ def create(args)
12
+ card = Trello::Card.new 'name' => args[:name],
13
+ 'desc' => args[:description],
14
+ 'idBoard' => args[:board_id],
15
+ 'idList' => args[:list_id]
16
+ card.save
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module TrelloCli
2
+ module Requests
3
+ class ListBoards
4
+
5
+ include Shared
6
+
7
+ def initialize
8
+ connect_to_trello
9
+ end
10
+
11
+ def list
12
+ Trello::Board.all
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ module TrelloCli
2
+ module Requests
3
+ class ListLists
4
+
5
+ include Shared
6
+
7
+ def initialize
8
+ connect_to_trello
9
+ end
10
+
11
+ def list(args)
12
+ board_id = args[:board_id]
13
+ board(board_id).lists
14
+ end
15
+
16
+ private
17
+
18
+ def board(board_id)
19
+ Trello::Board.new 'id' => board_id
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ module TrelloCli
2
+ module Requests
3
+ module Shared
4
+
5
+ def connect_to_trello
6
+ Trello.configure do |config|
7
+ config.developer_public_key = key
8
+ config.member_token = token
9
+ end
10
+ end
11
+
12
+ def key
13
+ ENV['TRELLO_DEVELOPER_PUBLIC_KEY']
14
+ end
15
+
16
+ def token
17
+ ENV['TRELLO_MEMBER_TOKEN']
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ require 'trello'
2
+
3
+ require 'trello_cli/requests/shared'
4
+
5
+ require 'trello_cli/requests/create_card'
6
+ require 'trello_cli/requests/list_boards'
7
+ require 'trello_cli/requests/list_lists'
@@ -0,0 +1,3 @@
1
+ module TrelloCli
2
+ VERSION = "0.0.1"
3
+ end
data/lib/trello_cli.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "trello_cli/cli"
2
+ require "trello_cli/requests"
3
+ require "trello_cli/version"
4
+
5
+ module TrelloCli
6
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe TrelloCli::CLI::Run do
4
+
5
+ before do
6
+ @card_mock = mock 'card'
7
+ TrelloCli::CLI::Card.stub :new => @card_mock
8
+ end
9
+
10
+ it "should call the given target with sub command" do
11
+ ARGV.should_receive(:shift).and_return('card')
12
+ ARGV.should_receive(:shift).and_return('create')
13
+
14
+ @card_mock.stub :actions => [:create]
15
+ @card_mock.should_receive(:create)
16
+ cli = TrelloCli::CLI::Run.new
17
+ cli.run
18
+ end
19
+
20
+ it "should call help if the command does not exist" do
21
+ ARGV.should_receive(:shift).and_return('card')
22
+ ARGV.should_receive(:shift).and_return('bad_cmd')
23
+
24
+ @card_mock.stub :actions => [:create]
25
+ @card_mock.should_receive(:help)
26
+ cli = TrelloCli::CLI::Run.new
27
+ cli.run
28
+ end
29
+
30
+ it "should display help if the target does not exist" do
31
+ ARGV.should_receive(:shift).and_return('bad_target')
32
+ ARGV.should_receive(:shift).and_return('create')
33
+
34
+ cli = TrelloCli::CLI::Run.new
35
+ cli.should_receive(:puts).with "Unkown target: 'bad_target'."
36
+ cli.should_receive(:puts).with "trello [board|card|list] [command] OPTIONS"
37
+ cli.should_receive(:puts).with "Append -h for help on specific target."
38
+ cli.run
39
+ end
40
+
41
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe TrelloCli::Requests::CreateCard do
4
+ before do
5
+ Trello.should_receive(:configure)
6
+ end
7
+
8
+ it "should create the requested card" do
9
+ args = { :name => 'name',
10
+ :description => 'desc',
11
+ :board_id => '123',
12
+ :list_id => '321' }
13
+ options = { 'name' => args[:name],
14
+ 'desc' => args[:description],
15
+ 'idBoard' => args[:board_id],
16
+ 'idList' => args[:list_id] }
17
+ trello_card_mock = mock 'trello card'
18
+ Trello::Card.should_receive(:new).
19
+ with(options).
20
+ and_return trello_card_mock
21
+ trello_card_mock.should_receive(:save)
22
+ create_card = TrelloCli::Requests::CreateCard.new
23
+ create_card.create args
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe TrelloCli::Requests::ListBoards do
4
+ before do
5
+ Trello.should_receive(:configure)
6
+ end
7
+
8
+ it "should list the lists for given board" do
9
+ Trello::Board.stub :all => ['123']
10
+ lb = TrelloCli::Requests::ListBoards.new
11
+ lb.list.should == ['123']
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe TrelloCli::Requests::ListLists do
4
+ before do
5
+ Trello.should_receive(:configure)
6
+ end
7
+
8
+ it "should list the lists for given board" do
9
+ trello_board_mock = mock 'new'
10
+ Trello::Board.should_receive(:new).with('id' => '123').
11
+ and_return trello_board_mock
12
+ trello_board_mock.stub :lists => ['321']
13
+ ll = TrelloCli::Requests::ListLists.new
14
+ ll.list(:board_id => '123').should == ['321']
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe TrelloCli::Requests::Shared do
4
+
5
+ before do
6
+ @object = Object.new
7
+ @object.extend TrelloCli::Requests::Shared
8
+ end
9
+
10
+ it "should connect to trello" do
11
+ trello_configure_mock = mock 'trello_configure'
12
+ Trello.should_receive(:configure).and_yield trello_configure_mock
13
+ trello_configure_mock.should_receive(:developer_public_key=).
14
+ with('key')
15
+ trello_configure_mock.should_receive(:member_token=).
16
+ with('token')
17
+ @object.stub :key => 'key', :token => 'token'
18
+ @object.connect_to_trello
19
+ end
20
+
21
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'trello_cli'
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'trello_cli/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "trello_cli"
8
+ gem.version = TrelloCli::VERSION
9
+ gem.authors = ["Brett Weaver"]
10
+ gem.email = ["brett@weav.net"]
11
+ gem.description = %q{Simple Trello Command Line Interface}
12
+ gem.summary = %q{Simple Trello Command Line Interface}
13
+ gem.homepage = "https://github.com/brettweavnet/trello_cli"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "rspec"
21
+ gem.add_development_dependency "rake"
22
+
23
+ gem.add_runtime_dependency 'ruby-trello', '0.5.1'
24
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trello_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brett Weaver
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70361510553800 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70361510553800
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70361510553300 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70361510553300
36
+ - !ruby/object:Gem::Dependency
37
+ name: ruby-trello
38
+ requirement: &70361510552800 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - =
42
+ - !ruby/object:Gem::Version
43
+ version: 0.5.1
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70361510552800
47
+ description: Simple Trello Command Line Interface
48
+ email:
49
+ - brett@weav.net
50
+ executables:
51
+ - trello
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - .rvmrc
57
+ - .travis.yml
58
+ - Gemfile
59
+ - LICENSE.txt
60
+ - README.md
61
+ - Rakefile
62
+ - bin/trello
63
+ - lib/trello_cli.rb
64
+ - lib/trello_cli/cli.rb
65
+ - lib/trello_cli/cli/board.rb
66
+ - lib/trello_cli/cli/card.rb
67
+ - lib/trello_cli/cli/list.rb
68
+ - lib/trello_cli/cli/run.rb
69
+ - lib/trello_cli/cli/shared.rb
70
+ - lib/trello_cli/requests.rb
71
+ - lib/trello_cli/requests/create_card.rb
72
+ - lib/trello_cli/requests/list_boards.rb
73
+ - lib/trello_cli/requests/list_lists.rb
74
+ - lib/trello_cli/requests/shared.rb
75
+ - lib/trello_cli/version.rb
76
+ - spec/cli/run_spec.rb
77
+ - spec/requests/create_card_spec.rb
78
+ - spec/requests/list_boards_spec.rb
79
+ - spec/requests/list_lists_spec.rb
80
+ - spec/requests/shared_spec.rb
81
+ - spec/spec_helper.rb
82
+ - trello_cli.gemspec
83
+ homepage: https://github.com/brettweavnet/trello_cli
84
+ licenses: []
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ segments:
96
+ - 0
97
+ hash: -3766021795283727408
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ segments:
105
+ - 0
106
+ hash: -3766021795283727408
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 1.8.16
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: Simple Trello Command Line Interface
113
+ test_files:
114
+ - spec/cli/run_spec.rb
115
+ - spec/requests/create_card_spec.rb
116
+ - spec/requests/list_boards_spec.rb
117
+ - spec/requests/list_lists_spec.rb
118
+ - spec/requests/shared_spec.rb
119
+ - spec/spec_helper.rb