totrello 0.0.6

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b62b102f663086f4c104af18795b654704f07416
4
+ data.tar.gz: a3a5ca5835da9fff3cf8f5b17ea9995b1b6ddfe5
5
+ SHA512:
6
+ metadata.gz: 797c2dffa68f99090748db06a6fd55360264e070dcb409ab745581761d7c85e545c45b64accaae541ae191e18d1421727b36b515becb96907dfc47f6e3200808
7
+ data.tar.gz: ea5a00b7e752b03fe178452dd2dc81fc23d6c28d016014ae52830bfbc11961ecd67b9c6d294effa8518525edae4a45bc62156cf64185f9207e5640e294dfae47
data/.gitignore ADDED
@@ -0,0 +1,91 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+
16
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
17
+
18
+ /*.iml
19
+
20
+ ## Directory-based project format:
21
+ .idea/
22
+ # if you remove the above rule, at least ignore the follwing:
23
+
24
+ # User-specific stuff:
25
+ # .idea/workspace.xml
26
+ # .idea/tasks.xml
27
+ # .idea/dictionaries
28
+
29
+ # Sensitive or high-churn files:
30
+ # .idea/dataSources.ids
31
+ # .idea/dataSources.xml
32
+ # .idea/sqlDataSources.xml
33
+ # .idea/dynamic.xml
34
+ # .idea/uiDesigner.xml
35
+
36
+ # Gradle:
37
+ # .idea/gradle.xml
38
+ # .idea/libraries
39
+
40
+ # Mongo Explorer plugin:
41
+ # .idea/mongoSettings.xml
42
+
43
+ ## File-based project format:
44
+ *.ipr
45
+ *.iws
46
+
47
+ ## Plugin-specific files:
48
+
49
+ # IntelliJ
50
+ out/
51
+
52
+ # mpeltonen/sbt-idea plugin
53
+ .idea_modules/
54
+
55
+ # JIRA plugin
56
+ atlassian-ide-plugin.xml
57
+
58
+ # Crashlytics plugin (for Android Studio and IntelliJ)
59
+ com_crashlytics_export_strings.xml
60
+
61
+ *.rbc
62
+ capybara-*.html
63
+ .rspec
64
+ /log
65
+ /tmp
66
+ /db/*.sqlite3
67
+ /public/system
68
+ /coverage/
69
+ /spec/tmp
70
+ **.orig
71
+ rerun.txt
72
+ pickle-email-*.html
73
+
74
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
75
+ config/initializers/secret_token.rb
76
+ config/secrets.yml
77
+
78
+ ## Environment normalisation:
79
+ /.bundle
80
+ /vendor/bundle
81
+
82
+ # these should all be checked in to normalise the environment:
83
+ # Gemfile.lock, .ruby-version, .ruby-gemset
84
+
85
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
86
+ .rvmrc
87
+
88
+ # if using bower-rails ignore default bower_components path bower.json files
89
+ /vendor/assets/bower_components
90
+ *.bowerrc
91
+ bower.json
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ - 2.1.1
5
+ - 2.0.0-p247
6
+ - 1.9.3-p194
7
+ # uncomment this line if your project needs to run something other than `rake`:
8
+ script:
9
+ gem install bundler &&
10
+ bundle exec rspec test/totrello_spec.rb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in totrello.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Whatisinternet
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,42 @@
1
+ [![Build Status](https://travis-ci.org/whatisinternet/ToTrello.svg?branch=master)](https://travis-ci.org/whatisinternet/ToTrello)
2
+ # Totrello
3
+
4
+ TODO: Turns Todo items into Trello cards
5
+
6
+ ## Notes
7
+
8
+ This is very early in development and makes several assumptions.
9
+ + As it stands you cannot specify the board you want todo items posted to. They are always posted to a board with the projects name
10
+ + Todo items are placed into the To Do list by default
11
+
12
+
13
+ ## Installation
14
+
15
+ Install it yourself as:
16
+
17
+ $ gem install totrello
18
+
19
+
20
+ ## Usage
21
+
22
+ + You must define TRELLO_DEVELOPER_PUBLIC_KEY & TRELLO_MEMBER_TOKEN
23
+ + Generate your TRELLO_DEVELOPER_PUBLIC_KEY at: [https://trello.com/1/appKey/generate](https://trello.com/1/appKey/generate)
24
+ + Generate your TRELLO_MEMBER_TOKEN at: https://trello.com/1/authorize?key=[TRELLO_DEVELOPER_PUBLIC_KEY]&name=ToTrelloGem&expiration=never&response_type=token&scope=read,write
25
+
26
+ $ export TRELLO_DEVELOPER_PUBLIC_KEY='[Your key here]'
27
+ $ export TRELLO_MEMBER_TOKEN='[Your key here]'
28
+
29
+
30
+ ### To Index the current working folder and create trello cards for it
31
+ $ ToTrello
32
+
33
+ ### To index and create cards for another folder
34
+ $ ToTrello [some other folder with full path]
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( https://github.com/whatisinternet/totrello/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/ToTrello ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'totrello'
4
+ TRELLO_DEVELOPER_PUBLIC_KEY = ENV['TRELLO_DEVELOPER_PUBLIC_KEY']
5
+ TRELLO_MEMBER_TOKEN = ENV['TRELLO_MEMBER_TOKEN']
6
+
7
+ def main
8
+
9
+ if TRELLO_DEVELOPER_PUBLIC_KEY.nil? || TRELLO_MEMBER_TOKEN.nil?
10
+ exit(-1)
11
+ else
12
+
13
+ dir = ARGV[0].to_s
14
+ if dir == ''
15
+ dir = Dir.pwd
16
+ end
17
+
18
+
19
+ puts "You've specified to work in: #{dir}"
20
+
21
+ trel = Totrello::Trelloize.new(dir)
22
+ trel.find_todo_items
23
+
24
+ end
25
+ end
26
+
27
+
28
+ main
data/lib/to_do_find.rb ADDED
@@ -0,0 +1,71 @@
1
+ require 'fileutils'
2
+
3
+ class ToDoFind
4
+
5
+ # This will search a given directory
6
+ #
7
+ def search(directory)
8
+
9
+ dir = directory
10
+ dir ||= Dir.pwd
11
+
12
+ todos= {directory: dir.split('/').last, :todo_list=>[] }
13
+
14
+ rbfiles = File.join("#{dir}/**", "*.*rb")
15
+
16
+ Dir.glob(rbfiles) do |my_text_file|
17
+
18
+ found_todo = find_todo(my_text_file)
19
+
20
+
21
+ if found_todo
22
+ todos[:todo_list].append(
23
+ {:file=> my_text_file.gsub(dir,''),
24
+ :todos => found_todo}
25
+ )
26
+ end
27
+
28
+ end
29
+ todos
30
+ end
31
+
32
+ #TODO: Kind of important but this doesn't seem to be working...
33
+ private
34
+ def find_todo(file)
35
+ @out = []
36
+ histories = File.readlines(file)
37
+ line_num = 0
38
+ histories.each do |hist|
39
+ line_num += 1
40
+ todo_location = is_todo?( hist, 'TODO' )
41
+ todo_location ||= is_todo?( hist, 'TODO:' )
42
+ todo_location ||= is_todo?( hist, ' TODO:' )
43
+ todo_location ||= is_todo?( hist, ' TODO' )
44
+ todo_location ||= is_todo?( hist, '#TODO:' )
45
+ todo_location ||= is_todo?( hist, '#TODO' )
46
+ unless todo_location.nil?
47
+ temp_string_array = hist.split(' ')
48
+ todo = hist.split(' ')[(todo_location + 1)..((temp_string_array.length) - 1)].join(' ')
49
+ puts "Found! #{todo}"
50
+ todo_and_location = {:todo => todo,
51
+ :location => line_num}
52
+ @out.append(todo_and_location)
53
+ end
54
+
55
+
56
+
57
+ end
58
+ @out
59
+ end
60
+
61
+ private
62
+ def is_todo?( string, test_string )
63
+ begin
64
+ string.split(' ').index test_string
65
+ rescue
66
+ return nil
67
+ end
68
+
69
+ end
70
+
71
+ end
@@ -0,0 +1,3 @@
1
+ module Totrello
2
+ VERSION = "0.0.6"
3
+ end
data/lib/totrello.rb ADDED
@@ -0,0 +1,77 @@
1
+ require "totrello/version"
2
+ require 'trello_creator'
3
+ require 'to_do_find'
4
+
5
+
6
+ module Totrello
7
+
8
+ class Trelloize
9
+ @trello
10
+ @directory
11
+
12
+ def initialize(directory)
13
+ begin
14
+ @trello = TrelloCreator.new
15
+ @directory = directory
16
+ rescue
17
+ error_data = "It looks like you're missing some details:\n\n\n"
18
+ error_data += " You must define TRELLO_DEVELOPER_PUBLIC_KEY & TRELLO_MEMBER_TOKEN\n"
19
+ error_data += " \nYou can generate the TRELLO_DEVELOPER_PUBLIC_KEY at:\n"
20
+ error_data += " \nhttps://trello.com/1/appKey/generate\n"
21
+ error_data += " \nYou can generate the TRELLO_MEMBER_TOKEN at:\n "
22
+ error_data += "\nhttps://trello.com/1/authorize?key=[TRELLO_DEVELOPER_PUBLIC_KEY]&name=ToTrelloGem&expiration=never&response_type=token&scope=read,write\n"
23
+ raise CustomException.new(error: error_data)
24
+ end
25
+
26
+ #find_todo_items
27
+ end
28
+
29
+ def find_todo_items
30
+ puts 'Finding your todo items... This should take a minute...'
31
+ todo = ToDoFind.new
32
+ todos = todo.search(@directory)
33
+ puts "Woot! We've got'em"
34
+
35
+ puts 'Generating your board'
36
+ begin
37
+ board = @trello.find_board(todos[:directory])
38
+ rescue
39
+ board =@trello.create_board(todos[:directory], 'Auto Generated by ToTrello Gem')
40
+ end
41
+
42
+
43
+
44
+ puts 'Taking to Trello, this is the longest part...'
45
+ todos[:todo_list].each do |tdl|
46
+ tdl[:todos].each do |td|
47
+ @trello.create_card(board,td, gen_description(tdl[:file],td),'To Do') unless td == ''
48
+ end
49
+ end
50
+ puts "And you're ready to go!"
51
+ end
52
+
53
+ def test_find_todo_items
54
+
55
+ todo = ToDoFind.new
56
+ todos = todo.search(@directory)
57
+
58
+ todos[:todo_list].each do |tdl|
59
+ tdl[:todos].each do |td|
60
+ puts gen_description(tdl[:file], td)
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+ def gen_description(file, todo)
67
+ out = "TODO item found by ToTrello\n"
68
+ out += "Filename: #{file}\n"
69
+ out += "Action item: #{todo[:todo]}\n"
70
+ out += "Location (at or near) line: #{todo[:location]}\n"
71
+ end
72
+
73
+
74
+ end
75
+
76
+
77
+ end
@@ -0,0 +1,57 @@
1
+ require 'trello'
2
+
3
+ class TrelloCreator
4
+ def initialize
5
+ Trello.configure do |config|
6
+ config.developer_public_key = TRELLO_DEVELOPER_PUBLIC_KEY
7
+ config.member_token = TRELLO_MEMBER_TOKEN
8
+ end
9
+ end
10
+
11
+ def create_card(board, name, description, list_name)
12
+ list_names = ['To Do', 'Doing', 'Done']
13
+ unless card_exists?(board, list_names, name[:todo])
14
+ card = Trello::Card.create(name: name[:todo], list_id: self.find_list(board, list_name), description: description)
15
+ card.save
16
+ end
17
+ end
18
+
19
+ def find_cards(board,list)
20
+ list = Trello::List.new 'idBoard' => board,
21
+ 'id' => list
22
+ list.cards
23
+ end
24
+
25
+ def create_board(board_name, description)
26
+ Trello::Board.create(name: board_name, description: description)
27
+ end
28
+
29
+ def find_board(name)
30
+ out = ''
31
+ Trello::Board.all.each do |board|
32
+ if board.name.upcase == name.upcase
33
+ out = board.id
34
+ end
35
+ end
36
+ Trello::Board.find(out)
37
+ end
38
+
39
+ def find_list(board, list_name)
40
+ board.lists.find { |list| list.name == list_name }.id
41
+ end
42
+
43
+ def card_exists?(board, list_names, card_name)
44
+ out = false
45
+ list_names.each do |list_name|
46
+ self.find_cards(board,self.find_list(board, list_name)).each do |card|
47
+ return true if card_name.nil?
48
+ if card.name.include? card_name
49
+ out = true
50
+ end
51
+ end
52
+ end
53
+
54
+ out
55
+ end
56
+
57
+ end
@@ -0,0 +1,6 @@
1
+ #TODO: test1
2
+ # TODO: test2
3
+ # TODO test3
4
+ # TODO: test4}
5
+ #TODO test5
6
+ #TODO: test6
@@ -0,0 +1,36 @@
1
+ require 'totrello'
2
+
3
+ describe "#initialize" do
4
+ it 'fails without having the correct information' do
5
+ expect{Totrello::Trelloize.new(nil)}.to raise_error
6
+ end
7
+ end
8
+
9
+ describe '#find_todo_items' do
10
+ it 'returns a hash of todo items from a directory'do
11
+ todo = ToDoFind.new
12
+ todos = todo.search("#{Dir.pwd}/test/test_data")
13
+ expected = {:directory => "test_data", :todo_list => [{:file => "/testing.rb", :todos => [{:todo => "test1", :location => 1}, {:todo => "test2", :location => 2}, {:todo => "test3", :location => 3}, {:todo => "test4}", :location => 4}, {:todo => "test5", :location => 5}, {:todo => "test6", :location => 6}]}]}
14
+ expect(todos).to include(expected)
15
+ end
16
+
17
+ end
18
+
19
+ describe 'formatted_data' do
20
+ it "Should have a string for the todo and an Int for the locaion" do
21
+ todo = ToDoFind.new
22
+ todos = todo.search("#{Dir.pwd}/test/test_data")
23
+
24
+ todos[:todo_list].each do |tdl|
25
+ tdl[:todos].each do |td|
26
+ expect(td[:todo]).to be_a_kind_of(String)
27
+ expect(td[:location]).to be_a_kind_of(Integer)
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
35
+
36
+
data/totrello.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'totrello/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "totrello"
8
+ spec.version = Totrello::VERSION
9
+ spec.authors = ["Josh Teeter"]
10
+ spec.email = ["joshteeter@gmail.com"]
11
+ spec.summary = ["Turns todo items into trello cards."]
12
+ spec.description = ["This will take the todo items in your code and turn them into trello cards"]
13
+ spec.homepage = "https://github.com/whatisinternet/ToTrello"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'rspec', '~> 3.0.0'
24
+
25
+ spec.add_runtime_dependency 'ruby-trello', '~> 0'
26
+
27
+ end
28
+
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: totrello
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - Josh Teeter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-trello
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: '["This will take the todo items in your code and turn them into trello
70
+ cards"]'
71
+ email:
72
+ - joshteeter@gmail.com
73
+ executables:
74
+ - ToTrello
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/ToTrello
85
+ - lib/to_do_find.rb
86
+ - lib/totrello.rb
87
+ - lib/totrello/version.rb
88
+ - lib/trello_creator.rb
89
+ - test/test_data/testing.rb
90
+ - test/totrello_spec.rb
91
+ - totrello.gemspec
92
+ homepage: https://github.com/whatisinternet/ToTrello
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.2.2
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: '["Turns todo items into trello cards."]'
116
+ test_files:
117
+ - test/test_data/testing.rb
118
+ - test/totrello_spec.rb