trello-changelog 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6b64822d440d4e3c32f06ffa09265185d0dc54a5
4
+ data.tar.gz: 404237a8825e40e226f5b4d45ba352f8b3b2375f
5
+ SHA512:
6
+ metadata.gz: 51d5b9c696a2d54e08db1446ab774cac3d332711785a6e8175cb8ef9668dc8e353e8a7fb9f2f6eaaca9bcc8779f2752def6109eb74c6ee0e1e3b66c1ed2e6359
7
+ data.tar.gz: 759a42ffeda700b7de266f568a4282b058b892b60269f6447e020441e7fb1edf52cb825726bf216536da0a673a4aaaa8300e9b113e35adb9edbe5e3cb3a488b9
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'date'
4
+ require 'thor'
5
+ require 'trello-changelog'
6
+
7
+ class TrelloChangelogCommand < Thor
8
+ desc 'print', 'print trelloboard from a startdate (example: trello-changelog --start_date=2015-02-01) this parameter is only needed if you want to run on an other day than friday.'
9
+ option :start_date, type: :string, desc: 'Start date'
10
+
11
+ def print
12
+ TrelloChangelog.new(options[:start_date])
13
+ end
14
+ end
15
+
16
+ TrelloChangelogCommand.start
@@ -0,0 +1,94 @@
1
+ require 'date'
2
+ require 'trello'
3
+
4
+ begin
5
+ require '~/.trello-changelog.rb'
6
+ rescue LoadError
7
+ puts 'File: ".trello-changelog.rb" was not found in your home directory!'
8
+ exit
9
+ end
10
+
11
+
12
+ module Trello
13
+ class Card < BasicData
14
+ def creation_date
15
+ epoch_from_id = self.id[0..7].hex
16
+ DateTime.strptime(epoch_from_id.to_s,'%s')
17
+ end
18
+ end
19
+ end
20
+
21
+ class TrelloChangelog
22
+ def initialize(start_date)
23
+
24
+ Trello.configure do |trello_config|
25
+ trello_config.developer_public_key = Variables::DEVKEY
26
+ trello_config.member_token = Variables::MEM_TOKEN
27
+ end
28
+
29
+ @board = Trello::Board.find(Variables::BOARD)
30
+ if(start_date == nil)
31
+ @start_date = Date.today - 6
32
+ else
33
+ begin
34
+ @start_date = Date.parse start_date
35
+ rescue ArgumentError
36
+ puts 'The start date syntax is wrong. Possible correct syntax are: YYYY-MM-DD, DD-MM-YYYY, YYYY/MM/DD, DD/MM/YYYY, ... . Please try again.'
37
+ exit
38
+ end
39
+ end
40
+ @year = Date.today.year
41
+ @done_list = @board.lists.select { |list| list.name == Variables::DONE_LIST_NAME }.last
42
+
43
+ print
44
+ end
45
+
46
+ private
47
+
48
+ def new_tickets
49
+ @new_tickets ||= @board.cards.select { |card| card.creation_date >= @start_date}
50
+ end
51
+
52
+ def done_tickets
53
+ @done_tickets ||= @board.cards.select { |card| card.list_id == @done_list.id }
54
+ end
55
+
56
+ def archived_tickets
57
+ @archived_tickets ||= @board.cards( { filter: :all } ).select { |card| card.creation_date >= @start_date }.select { |card| card.closed == true } - archived_done_tickets
58
+ end
59
+
60
+ def archived_done_tickets
61
+ @archived_done_tickets ||= @board.cards( { filter: :all } ).select { |card| card.creation_date >= @start_date }.select { |card| card.list_id == @done_list.id }.select { |card| card.closed == true }
62
+ end
63
+
64
+ def new_tickets_count
65
+ new_tickets.count
66
+ end
67
+
68
+ def done_tickets_count
69
+ done_tickets.count
70
+ end
71
+
72
+ def archived_tickets_count
73
+ archived_tickets.count
74
+ end
75
+
76
+ def print
77
+ puts "# Start date: #{@start_date}\n\n"
78
+
79
+ puts "Created Trello items since #{@start_date}: #{new_tickets_count}\n\n"
80
+ puts "Finished Trello items since #{@start_date}: #{done_tickets_count}\n\n"
81
+ puts "Archived Trello items since #{@start_date}: #{archived_tickets_count}\n\n"
82
+
83
+ puts "Summary: #{new_tickets_count} tickets in, #{done_tickets_count + archived_tickets_count} tickets out\n\n"
84
+
85
+ for label_name in Variables::LABELS do
86
+ tickets_label_name = done_tickets.select { |ticket| ticket.labels.select { |label| label.name == label_name}.count > 0 }
87
+ puts "\n## #{label_name}:\n\n"
88
+ tickets_label_name.each do |ticket|
89
+ puts " * [#{ticket.name}](#{ticket.url})"
90
+ end
91
+ puts 'n.a.' if tickets_label_name.count == 0
92
+ end
93
+ end
94
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trello-changelog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Giel De Bleser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ruby-trello
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Changelog for Trello
56
+ email: giel@openminds.be
57
+ executables:
58
+ - trello-changelog
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/trello-changelog.rb
63
+ - bin/trello-changelog
64
+ homepage: https://github.com/openminds/trello-changelog
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.0.14
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Changelog for Trello
88
+ test_files: []