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 CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .DS_Store
5
6
  .yardoc
6
7
  Gemfile.lock
7
8
  InstalledFiles
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.save #=> creates card on Trello list with 'foobar' name,
53
- # and 'Hello World!' in the description
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
@@ -1,6 +1,12 @@
1
1
  require "trellatin/version"
2
+ require 'trellatin/config'
2
3
  require 'trellatin/persistence'
3
4
 
4
5
  module Trellatin
6
+ extend self
7
+
8
+ def configure
9
+ block_given? ? yield(Trellatin::Config) : Trellatin::Config
10
+ end
5
11
 
6
12
  end
@@ -0,0 +1,12 @@
1
+ require 'trellatin/config/options'
2
+
3
+ module Trellatin
4
+ module Config
5
+ extend self
6
+ extend Options
7
+
8
+ option :app_key
9
+ option :token
10
+
11
+ end
12
+ end
@@ -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] || :name
16
- description = self.class.options[:description] || :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
- if options[:app_key] && options[:token]
30
-
31
- Trello.configure do |config|
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
 
@@ -1,3 +1,3 @@
1
1
  module Trellatin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-16 00:00:00.000000000 Z
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