trelloid 0.0.1
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/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/Guardfile +24 -0
- data/LICENSE.txt +22 -0
- data/README.md +25 -0
- data/Rakefile +1 -0
- data/examples/hello_world.rb +18 -0
- data/lib/trelloid/version.rb +3 -0
- data/lib/trelloid.rb +112 -0
- data/spec/lib/trelloid_spec.rb +65 -0
- data/spec/spec_helper.rb +20 -0
- data/trelloid.gemspec +28 -0
- metadata +156 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Stratos Voukelatos
|
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,25 @@
|
|
1
|
+
# Trelloid
|
2
|
+
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem 'trelloid'
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
|
12
|
+
$ bundle
|
13
|
+
|
14
|
+
Or install it yourself as:
|
15
|
+
|
16
|
+
$ gem install trelloid
|
17
|
+
|
18
|
+
|
19
|
+
## Contributing
|
20
|
+
|
21
|
+
1. Fork it
|
22
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
23
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
24
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
25
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../lib/trelloid'
|
2
|
+
API_KEY = 'Your trello app key'
|
3
|
+
TOKEN = 'Your trello bot user token'
|
4
|
+
|
5
|
+
app = Trelloid::Bot.new(API_KEY, TOKEN, interval: 5)
|
6
|
+
|
7
|
+
app.behaviour do
|
8
|
+
|
9
|
+
task "Say hello world" do
|
10
|
+
process do
|
11
|
+
puts 'Hello World!'
|
12
|
+
puts card.name
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
app.run
|
data/lib/trelloid.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'celluloid'
|
2
|
+
require 'trello'
|
3
|
+
require 'active_support/all'
|
4
|
+
|
5
|
+
require 'trelloid/version'
|
6
|
+
|
7
|
+
module Trelloid
|
8
|
+
class Bot
|
9
|
+
|
10
|
+
include Celluloid
|
11
|
+
|
12
|
+
attr_reader :api_key, :token, :tasks, :interval
|
13
|
+
|
14
|
+
def initialize(api_key, token, options = {})
|
15
|
+
@api_key = api_key
|
16
|
+
@token = token
|
17
|
+
@tasks = []
|
18
|
+
@interval = options.delete(:interval) || 30
|
19
|
+
@task_runners = TaskRunner.pool
|
20
|
+
@client = Trello::Client.new(
|
21
|
+
developer_public_key: @api_key,
|
22
|
+
member_token: @token
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
interrupted = false
|
28
|
+
start_polling
|
29
|
+
trap('INT'){interrupted = true}
|
30
|
+
while !interrupted
|
31
|
+
sleep 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def behaviour(&blk)
|
36
|
+
instance_eval(&blk)
|
37
|
+
end
|
38
|
+
|
39
|
+
def task(name, &blk)
|
40
|
+
add_task(Task.new(name, &blk))
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_task(task)
|
44
|
+
@tasks << task
|
45
|
+
end
|
46
|
+
|
47
|
+
def find_task(title)
|
48
|
+
tasks.select{|t| t.match? title}.first
|
49
|
+
end
|
50
|
+
|
51
|
+
def start_polling
|
52
|
+
@poller = every(interval){poll}
|
53
|
+
@poller.fire
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def poll
|
59
|
+
cards = @client.find(:members, 'me').cards
|
60
|
+
cards.each do |card|
|
61
|
+
task = find_task card.name
|
62
|
+
run_task(task, card)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def run_task(task, card)
|
67
|
+
@task_runners.run(task, card)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
class Task
|
74
|
+
|
75
|
+
attr_reader :name, :proc
|
76
|
+
|
77
|
+
def initialize(name, &blk)
|
78
|
+
@name = name
|
79
|
+
instance_eval(&blk)
|
80
|
+
end
|
81
|
+
|
82
|
+
def process(&blk)
|
83
|
+
@proc = blk
|
84
|
+
end
|
85
|
+
|
86
|
+
def match?(title)
|
87
|
+
!!name.match(title)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
class TaskRunner
|
94
|
+
|
95
|
+
include Celluloid
|
96
|
+
attr_reader :card, :task
|
97
|
+
|
98
|
+
def run(task, card)
|
99
|
+
assign_instance_variables(task, card)
|
100
|
+
instance_eval(&task.proc)
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def assign_instance_variables(task, card)
|
106
|
+
@card = card
|
107
|
+
@task = task
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'trelloid'
|
3
|
+
include Trelloid
|
4
|
+
|
5
|
+
describe Trelloid do
|
6
|
+
|
7
|
+
let(:blk){ Proc.new {process { 1+1 }} }
|
8
|
+
let(:task){Task.new('A task', &blk)}
|
9
|
+
let(:card){double("Trello::Card").stub(:name => "A task")}
|
10
|
+
let(:api_key){"api_key"}
|
11
|
+
let(:token){"token"}
|
12
|
+
let(:bot){Trelloid::Bot.new(api_key, token)}
|
13
|
+
|
14
|
+
let(:blk)do
|
15
|
+
Proc.new {process { 1+1 }}
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:task){Task.new('A task', &blk)}
|
19
|
+
|
20
|
+
let(:card)do
|
21
|
+
card = double("Trello::Card")
|
22
|
+
card.stub(:name => "A task")
|
23
|
+
end
|
24
|
+
|
25
|
+
describe Bot do
|
26
|
+
|
27
|
+
subject{bot}
|
28
|
+
|
29
|
+
describe "#initialize" do
|
30
|
+
its(:api_key){should eq api_key}
|
31
|
+
its(:token){should eq token}
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#add_task" do
|
35
|
+
it "Adds task" do
|
36
|
+
bot.add_task task
|
37
|
+
bot.tasks.length.should eq 1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#find_task" do
|
42
|
+
before(:each){bot.add_task task}
|
43
|
+
it{bot.find_task("A task").should eq task}
|
44
|
+
it{bot.find_task("Not a task").should eq nil}
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "DSL methods" do
|
48
|
+
describe "#task" do
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
describe Task do
|
57
|
+
|
58
|
+
subject{ task }
|
59
|
+
its(:name){should eq 'A task'}
|
60
|
+
it{subject.proc.call.should eq 2}
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
|
15
|
+
# Run specs in random order to surface order dependencies. If you find an
|
16
|
+
# order dependency and want to debug it, you can fix the order by providing
|
17
|
+
# the seed, which is printed after each run.
|
18
|
+
# --seed 1234
|
19
|
+
config.order = 'random'
|
20
|
+
end
|
data/trelloid.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'trelloid/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "trelloid"
|
8
|
+
gem.version = Trelloid::VERSION
|
9
|
+
gem.authors = ["Stratos Voukelatos"]
|
10
|
+
gem.email = ["stratosvoukel@gmail.com"]
|
11
|
+
gem.description = %q{Trello automation DSL}
|
12
|
+
gem.summary = %q{Use trello as an task doer}
|
13
|
+
gem.homepage = ""
|
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 "rspec-mocks"
|
22
|
+
gem.add_development_dependency "simplecov"
|
23
|
+
|
24
|
+
gem.add_dependency "ruby-trello"
|
25
|
+
gem.add_dependency "activesupport"
|
26
|
+
gem.add_dependency "celluloid"
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trelloid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Stratos Voukelatos
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
type: :development
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec-mocks
|
32
|
+
type: :development
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: simplecov
|
48
|
+
type: :development
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: ruby-trello
|
64
|
+
type: :runtime
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: activesupport
|
80
|
+
type: :runtime
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: celluloid
|
96
|
+
type: :runtime
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: Trello automation DSL
|
111
|
+
email:
|
112
|
+
- stratosvoukel@gmail.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .rspec
|
119
|
+
- Gemfile
|
120
|
+
- Guardfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- examples/hello_world.rb
|
125
|
+
- lib/trelloid.rb
|
126
|
+
- lib/trelloid/version.rb
|
127
|
+
- spec/lib/trelloid_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
- trelloid.gemspec
|
130
|
+
homepage: ''
|
131
|
+
licenses: []
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 1.8.23
|
151
|
+
signing_key:
|
152
|
+
specification_version: 3
|
153
|
+
summary: Use trello as an task doer
|
154
|
+
test_files:
|
155
|
+
- spec/lib/trelloid_spec.rb
|
156
|
+
- spec/spec_helper.rb
|