trellatin 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +14 -5
- data/lib/trellatin.rb +6 -0
- data/lib/trellatin/config.rb +12 -0
- data/lib/trellatin/config/options.rb +41 -0
- data/lib/trellatin/persistence.rb +5 -9
- data/lib/trellatin/version.rb +1 -1
- metadata +4 -2
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -20,6 +20,15 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
require 'trellatin'
|
22
22
|
|
23
|
+
Set global configuration options. You could put this in `config/initializers/trellatin.rb` if using Rails:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Trellatin.configure do |config|
|
27
|
+
config.app_id = ENV['APP_ID']
|
28
|
+
config.token = ENV['TOKEN']
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
23
32
|
In any class:
|
24
33
|
|
25
34
|
```ruby
|
@@ -30,9 +39,9 @@ class Submission
|
|
30
39
|
trellatin({
|
31
40
|
owner: 'joshuarowley',
|
32
41
|
board: 'test',
|
33
|
-
list: 'To Do'
|
34
|
-
app_key: ENV['APP_KEY'],
|
35
|
-
token: ENV['TOKEN'],
|
42
|
+
list: 'To Do',
|
43
|
+
app_key: ENV['APP_KEY'], # optional if defined in initializer
|
44
|
+
token: ENV['TOKEN'], # optional if defined in initializer
|
36
45
|
name: :some_method, # optional, defaults to :name
|
37
46
|
description: :another_method # optional, defaults to :description
|
38
47
|
})
|
@@ -49,8 +58,8 @@ class Submission
|
|
49
58
|
|
50
59
|
end
|
51
60
|
|
52
|
-
Submission.new.
|
53
|
-
|
61
|
+
Submission.new.save_card #=> creates card on Trello list with 'foobar' name,
|
62
|
+
# and 'Hello World!' in the description
|
54
63
|
```
|
55
64
|
|
56
65
|
## Contributing
|
data/lib/trellatin.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Trellatin
|
2
|
+
|
3
|
+
module Config
|
4
|
+
|
5
|
+
module Options
|
6
|
+
|
7
|
+
def defaults
|
8
|
+
@defaults ||= {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def option(name, options = {})
|
12
|
+
defaults[name] = settings[name] = options[:default]
|
13
|
+
|
14
|
+
class_eval <<-RUBY
|
15
|
+
def #{name}
|
16
|
+
settings[#{name.inspect}]
|
17
|
+
end
|
18
|
+
|
19
|
+
def #{name}=(value)
|
20
|
+
settings[#{name.inspect}] = value
|
21
|
+
end
|
22
|
+
|
23
|
+
def #{name}?
|
24
|
+
#{name}
|
25
|
+
end
|
26
|
+
|
27
|
+
def reset_#{name}
|
28
|
+
settings[#{name.inspect}] = defaults[#{name.inspect}]
|
29
|
+
end
|
30
|
+
RUBY
|
31
|
+
end
|
32
|
+
|
33
|
+
def settings
|
34
|
+
@settings ||= {}
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -12,8 +12,8 @@ module Trellatin
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def save_card
|
15
|
-
name = self.class.options[:name]
|
16
|
-
description = self.class.options[:description]
|
15
|
+
name = self.class.options[:name] || :name
|
16
|
+
description = self.class.options[:description] || :description
|
17
17
|
|
18
18
|
Trello::Card.create(
|
19
19
|
name: send(name),
|
@@ -26,13 +26,9 @@ module Trellatin
|
|
26
26
|
module ClassMethods
|
27
27
|
|
28
28
|
def configure_client
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
config.developer_public_key = options[:app_key]
|
33
|
-
config.member_token = options[:token]
|
34
|
-
end
|
35
|
-
|
29
|
+
Trello.configure do |config|
|
30
|
+
config.developer_public_key = options[:app_key] || Trellatin::Config.app_key
|
31
|
+
config.member_token = options[:token] || Trellatin::Config.token
|
36
32
|
end
|
37
33
|
end
|
38
34
|
|
data/lib/trellatin/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trellatin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -89,6 +89,8 @@ files:
|
|
89
89
|
- README.md
|
90
90
|
- Rakefile
|
91
91
|
- lib/trellatin.rb
|
92
|
+
- lib/trellatin/config.rb
|
93
|
+
- lib/trellatin/config/options.rb
|
92
94
|
- lib/trellatin/persistence.rb
|
93
95
|
- lib/trellatin/version.rb
|
94
96
|
- trellatin.gemspec
|