trellatin 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
+ sample.rb
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trellatin.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Josh Rowley
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,62 @@
1
+ # Trellatin
2
+
3
+ Trellatin lets you easily convert Ruby objects into Trello cards.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'trellatin'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install trellatin
18
+
19
+ ## Usage
20
+
21
+ require 'trellatin'
22
+
23
+ In any class:
24
+
25
+ ```ruby
26
+ class Submission
27
+
28
+ include Trellatin::Persistence
29
+
30
+ trellatin({
31
+ owner: 'joshuarowley',
32
+ board: 'test',
33
+ list: 'To Do'
34
+ app_key: ENV['APP_KEY'],
35
+ token: ENV['TOKEN'],
36
+ name: :some_method, # optional, defaults to :name
37
+ description: :another_method # optional, defaults to :description
38
+ })
39
+
40
+ def some_method
41
+ # method to be saved in a card's title field
42
+ 'foobar'
43
+ end
44
+
45
+ def another_method
46
+ # method to be saved in a card's description
47
+ 'Hello World!'
48
+ end
49
+
50
+ end
51
+
52
+ Submission.new.save #=> creates card on Trello list with 'foobar' name,
53
+ # and 'Hello World!' in the description
54
+ ```
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/trellatin.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "trellatin/version"
2
+ require 'trellatin/persistence'
3
+
4
+ module Trellatin
5
+
6
+ end
@@ -0,0 +1,67 @@
1
+ require 'active_support/core_ext'
2
+ require 'trello'
3
+
4
+ module Trellatin
5
+
6
+ module Persistence
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ class_attribute :options, :owner, :board, :list
11
+ self.options = {}
12
+ end
13
+
14
+ def save_card
15
+ name = self.class.options[:name] || :name
16
+ description = self.class.options[:description] || :description
17
+
18
+ Trello::Card.create(
19
+ name: send(name),
20
+ description: send(description),
21
+ list_id: self.class.list.id
22
+ )
23
+ end
24
+
25
+
26
+ module ClassMethods
27
+
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
+
36
+ end
37
+ end
38
+
39
+ def set_trello_objects
40
+ self.set_owner
41
+ self.set_board
42
+ self.set_list
43
+ end
44
+
45
+ def set_owner
46
+ self.owner = Trello::Member.find(options[:owner])
47
+ end
48
+
49
+ def set_board
50
+ self.board = owner.boards.select { |b| b.name == options[:board] }.first
51
+ end
52
+
53
+ def set_list
54
+ self.list = board.lists.select { |l| l.name == options[:list] }.first
55
+ end
56
+
57
+ def trellatin(options = {})
58
+ self.options = options
59
+ configure_client
60
+ set_trello_objects
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+
67
+ end
@@ -0,0 +1,3 @@
1
+ module Trellatin
2
+ VERSION = "0.0.2"
3
+ end
data/trellatin.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'trellatin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trellatin"
8
+ spec.version = Trellatin::VERSION
9
+ spec.authors = ["Josh Rowley"]
10
+ spec.email = ["joshua.f.rowley@gmail.com"]
11
+ spec.description = %q{Inherit from Trellatin to easily use Trello as a persistence layer for your classes.}
12
+ spec.summary = %q{Use Trello as a persistence layer.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "bundler", "~> 1.3"
22
+ spec.add_dependency "rake"
23
+ spec.add_dependency "activesupport"
24
+ spec.add_dependency "ruby-trello"
25
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trellatin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Josh Rowley
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
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: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
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: activesupport
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
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
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
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
+ description: Inherit from Trellatin to easily use Trello as a persistence layer for
79
+ your classes.
80
+ email:
81
+ - joshua.f.rowley@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - lib/trellatin.rb
92
+ - lib/trellatin/persistence.rb
93
+ - lib/trellatin/version.rb
94
+ - trellatin.gemspec
95
+ homepage: ''
96
+ licenses:
97
+ - MIT
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 1.8.23
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Use Trello as a persistence layer.
120
+ test_files: []