trello_freestyler 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +36 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +87 -0
- data/LICENSE.txt +21 -0
- data/README.md +186 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/trello_freestyler +4 -0
- data/lib/trello_freestyler.rb +28 -0
- data/lib/trello_freestyler/cli.rb +71 -0
- data/lib/trello_freestyler/client.rb +29 -0
- data/lib/trello_freestyler/main.rb +72 -0
- data/lib/trello_freestyler/utils/hash.rb +30 -0
- data/lib/trello_freestyler/version.rb +5 -0
- data/trello_freestyler.gemspec +39 -0
- metadata +179 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 35de638b7bb3a0f9ff9c56a4af3f31c5151075ff1e12c3411fe0ef770cae0264
|
4
|
+
data.tar.gz: bd8a271525555b14b2dfa82b4b57e56bc13ac53613e7df4487735e59a1ad5fae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a24ffae7a1431c18654581712ed51e7a9afbb785aa19261245fa90a2ae27191b20b7e4f399fa03d5bea5410321156f10d9a48c25a01d5029d07c59a2532b8222
|
7
|
+
data.tar.gz: 1b46c57c2cecfae190294daa4de405b4af8bb36dd4b41ac8e798bf381ca35af22983c21914470c9263243905208ed453900ad302f1bc04476e04a982e1e8c550
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop/formatter/emoji_formatter
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.7.1
|
6
|
+
NewCops: enable
|
7
|
+
|
8
|
+
Metrics/AbcSize:
|
9
|
+
Max: 20
|
10
|
+
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Max: 100
|
13
|
+
|
14
|
+
Metrics/ClassLength:
|
15
|
+
Max: 250
|
16
|
+
|
17
|
+
Metrics/LineLength:
|
18
|
+
Max: 130
|
19
|
+
|
20
|
+
Metrics/MethodLength:
|
21
|
+
Max: 25
|
22
|
+
|
23
|
+
Layout/SpaceBeforeBlockBraces:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Layout/SpaceInsideBlockBraces:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
30
|
+
EnforcedStyle: no_space
|
31
|
+
|
32
|
+
Style/Documentation:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Style/FormatStringToken:
|
36
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at justinhamman@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
trello_freestyler (0.1.0)
|
5
|
+
rest-client
|
6
|
+
tty-spinner
|
7
|
+
tzinfo
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
ast (2.4.1)
|
13
|
+
concurrent-ruby (1.1.7)
|
14
|
+
diff-lcs (1.4.4)
|
15
|
+
domain_name (0.5.20190701)
|
16
|
+
unf (>= 0.0.5, < 1.0.0)
|
17
|
+
http-accept (1.7.0)
|
18
|
+
http-cookie (1.0.3)
|
19
|
+
domain_name (~> 0.5)
|
20
|
+
mime-types (3.3.1)
|
21
|
+
mime-types-data (~> 3.2015)
|
22
|
+
mime-types-data (3.2020.0512)
|
23
|
+
netrc (0.11.0)
|
24
|
+
parallel (1.19.2)
|
25
|
+
parser (2.7.1.4)
|
26
|
+
ast (~> 2.4.1)
|
27
|
+
rainbow (3.0.0)
|
28
|
+
rake (12.3.3)
|
29
|
+
regexp_parser (1.8.0)
|
30
|
+
rest-client (2.1.0)
|
31
|
+
http-accept (>= 1.7.0, < 2.0)
|
32
|
+
http-cookie (>= 1.0.2, < 2.0)
|
33
|
+
mime-types (>= 1.16, < 4.0)
|
34
|
+
netrc (~> 0.8)
|
35
|
+
rexml (3.2.4)
|
36
|
+
rspec (3.9.0)
|
37
|
+
rspec-core (~> 3.9.0)
|
38
|
+
rspec-expectations (~> 3.9.0)
|
39
|
+
rspec-mocks (~> 3.9.0)
|
40
|
+
rspec-core (3.9.2)
|
41
|
+
rspec-support (~> 3.9.3)
|
42
|
+
rspec-expectations (3.9.2)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.9.0)
|
45
|
+
rspec-mocks (3.9.1)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.9.0)
|
48
|
+
rspec-support (3.9.3)
|
49
|
+
rubocop (0.91.0)
|
50
|
+
parallel (~> 1.10)
|
51
|
+
parser (>= 2.7.1.1)
|
52
|
+
rainbow (>= 2.2.2, < 4.0)
|
53
|
+
regexp_parser (>= 1.7)
|
54
|
+
rexml
|
55
|
+
rubocop-ast (>= 0.4.0, < 1.0)
|
56
|
+
ruby-progressbar (~> 1.7)
|
57
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
58
|
+
rubocop-ast (0.4.2)
|
59
|
+
parser (>= 2.7.1.4)
|
60
|
+
rubocop-emoji (0.1.0)
|
61
|
+
rubocop (~> 0.3)
|
62
|
+
rubocop-rspec (1.43.2)
|
63
|
+
rubocop (~> 0.87)
|
64
|
+
ruby-progressbar (1.10.1)
|
65
|
+
tty-cursor (0.7.1)
|
66
|
+
tty-spinner (0.9.3)
|
67
|
+
tty-cursor (~> 0.7)
|
68
|
+
tzinfo (2.0.2)
|
69
|
+
concurrent-ruby (~> 1.0)
|
70
|
+
unf (0.1.4)
|
71
|
+
unf_ext
|
72
|
+
unf_ext (0.0.7.7)
|
73
|
+
unicode-display_width (1.7.0)
|
74
|
+
|
75
|
+
PLATFORMS
|
76
|
+
ruby
|
77
|
+
|
78
|
+
DEPENDENCIES
|
79
|
+
rake
|
80
|
+
rspec
|
81
|
+
rubocop
|
82
|
+
rubocop-emoji
|
83
|
+
rubocop-rspec
|
84
|
+
trello_freestyler!
|
85
|
+
|
86
|
+
BUNDLED WITH
|
87
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Justin Hamman
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
# TrelloFreestyler
|
2
|
+
|
3
|
+
Uses the Trello API to dump json line files for a Trello board and its actions.
|
4
|
+
Built with the intention of ingesting the files into BigQuery (but obviously this gem can be used for other purposes)
|
5
|
+
For BigQuery ingestion we need json line files and they need to be scrubbed of any empty objects.
|
6
|
+
This is because BigQuery will not ingest an empty json object unless you also supply a schema, which is a hassle and also means we won't auto load new columns that Trello create.
|
7
|
+
|
8
|
+
Two key trello concepts are exported
|
9
|
+
- `cards.jsonl`
|
10
|
+
- `actions.jsonl`
|
11
|
+
|
12
|
+
From the above, one can do analysis on how long the card has spent in each column and which trello user was on the card at any point in time.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'trello_freestyler'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle install
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install trello_freestyler
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
```bash
|
33
|
+
trello_freestyler --key <TRELLO_KEY> --token <TRELLO_TOKEN> --board_id <TRELLO_BOARD_ID>
|
34
|
+
```
|
35
|
+
|
36
|
+
## Output
|
37
|
+
|
38
|
+
The gem will output two files.
|
39
|
+
|
40
|
+
- `.output/cards.jsonl`
|
41
|
+
- `.output/actions.jsonl`
|
42
|
+
|
43
|
+
### Card Data Example
|
44
|
+
|
45
|
+
Example:
|
46
|
+
```json
|
47
|
+
{
|
48
|
+
"id": "5f55b9c16c827d25a1102c86",
|
49
|
+
"checkItemStates": null,
|
50
|
+
"closed": false,
|
51
|
+
"dateLastActivity": "2020-09-18T06:04:20.026Z",
|
52
|
+
"desc": "Long description of what is going on in this card",
|
53
|
+
"dueReminder": null,
|
54
|
+
"idBoard": "5a83b75266739ccd8007fb93",
|
55
|
+
"idList": "5a83b77ebc78a107c1ee0123",
|
56
|
+
"idMembersVoted": [],
|
57
|
+
"idShort": 1727,
|
58
|
+
"idAttachmentCover": null,
|
59
|
+
"idLabels": ["5f4c45dbff786e0e699910e5", "5f4c45dbff786e0e699910ca"],
|
60
|
+
"manualCoverAttachment": false,
|
61
|
+
"name": "Write lots of code",
|
62
|
+
"pos": 1081343,
|
63
|
+
"shortLink": "IEOr8bp4",
|
64
|
+
"isTemplate": false,
|
65
|
+
"badges": {
|
66
|
+
"attachmentsByType": {
|
67
|
+
"trello": {
|
68
|
+
"board": 0,
|
69
|
+
"card": 0
|
70
|
+
}
|
71
|
+
},
|
72
|
+
"location": false,
|
73
|
+
"votes": 0,
|
74
|
+
"viewingMemberVoted": false,
|
75
|
+
"subscribed": false,
|
76
|
+
"fogbugz": "",
|
77
|
+
"checkItems": 0,
|
78
|
+
"checkItemsChecked": 0,
|
79
|
+
"checkItemsEarliestDue": null,
|
80
|
+
"comments": 0,
|
81
|
+
"attachments": 0,
|
82
|
+
"description": true,
|
83
|
+
"due": null,
|
84
|
+
"dueComplete": false,
|
85
|
+
"start": null
|
86
|
+
},
|
87
|
+
"dueComplete": false,
|
88
|
+
"due": null,
|
89
|
+
"idChecklists": [],
|
90
|
+
"idMembers": [],
|
91
|
+
"labels": [{
|
92
|
+
"id": "5f4c45dbff786e0e699910e5",
|
93
|
+
"idBoard": "5a83b75266739ccd8007fb93",
|
94
|
+
"name": "Important",
|
95
|
+
"color": "sky"
|
96
|
+
}, {
|
97
|
+
"id": "5f4c45dbff786e0e699910ca",
|
98
|
+
"idBoard": "5a83b75266739ccd8007fb93",
|
99
|
+
"name": "Build XYZ",
|
100
|
+
"color": "yellow"
|
101
|
+
}],
|
102
|
+
"shortUrl": "https://trello.com/c/IEOr8bp4",
|
103
|
+
"start": null,
|
104
|
+
"subscribed": false,
|
105
|
+
"url": "https://trello.com/c/IEOr8bp4/1727-interesting-trello-card",
|
106
|
+
"cover": {
|
107
|
+
"idAttachment": null,
|
108
|
+
"color": null,
|
109
|
+
"idUploadedBackground": null,
|
110
|
+
"size": "normal",
|
111
|
+
"brightness": "light"
|
112
|
+
}
|
113
|
+
}
|
114
|
+
```
|
115
|
+
|
116
|
+
### Actions Data Example
|
117
|
+
|
118
|
+
Only a subset of actions are exported.
|
119
|
+
By default the cli will export these actions.
|
120
|
+
- `'addMemberToCard,removeMemberFromCard,createCard,moveCardFromBoard,moveCardToBoard,updateCard'`
|
121
|
+
|
122
|
+
They form the minimum requirements to work out which member was on which card at any given point in time.
|
123
|
+
|
124
|
+
```json
|
125
|
+
{
|
126
|
+
"id": "5e78321d12600747e2e88a22",
|
127
|
+
"idMemberCreator": "59681948d79a0c42c27891da",
|
128
|
+
"data": {
|
129
|
+
"card": {
|
130
|
+
"id": "5e78321c12600747e2e88a21",
|
131
|
+
"name": "Iteration goals",
|
132
|
+
"idShort": 1398,
|
133
|
+
"shortLink": "XiyVVDx0"
|
134
|
+
},
|
135
|
+
"list": {
|
136
|
+
"id": "5a83b76966d66e23d2198d72",
|
137
|
+
"name": "Iteration Details"
|
138
|
+
},
|
139
|
+
"board": {
|
140
|
+
"id": "5a83b75266739ccd8007fb93",
|
141
|
+
"name": "Go team go board",
|
142
|
+
"shortLink": "HOdivmmF"
|
143
|
+
}
|
144
|
+
},
|
145
|
+
"type": "createCard",
|
146
|
+
"date": "2020-03-23T03:50:53.024Z",
|
147
|
+
"memberCreator": {
|
148
|
+
"id": "59681948d79a0c42c27891da",
|
149
|
+
"username": "rachel",
|
150
|
+
"activityBlocked": false,
|
151
|
+
"avatarHash": "20e3b40ee3bc83d5200348d96485a3be",
|
152
|
+
"avatarUrl": "https://trello-members.s3.amazonaws.com/59681948d79a0c42c27891da/20e3b40ee3bc83",
|
153
|
+
"fullName": "Rachel",
|
154
|
+
"idMemberReferrer": null,
|
155
|
+
"initials": "RF",
|
156
|
+
"nonPublicAvailable": false
|
157
|
+
}
|
158
|
+
}
|
159
|
+
```
|
160
|
+
|
161
|
+
## Development
|
162
|
+
|
163
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
164
|
+
|
165
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
166
|
+
|
167
|
+
Can use this gem to bump versions
|
168
|
+
```bash
|
169
|
+
gem install gem-release
|
170
|
+
$ gem bump --version minor # bumps to the next minor version
|
171
|
+
$ gem bump --version major # bumps to the next major version
|
172
|
+
$ gem bump --version 1.1.1 # bumps to the specified version
|
173
|
+
```
|
174
|
+
|
175
|
+
## Contributing
|
176
|
+
|
177
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/trello_freestyler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/trello_freestyler/blob/master/CODE_OF_CONDUCT.md).
|
178
|
+
|
179
|
+
|
180
|
+
## License
|
181
|
+
|
182
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
183
|
+
|
184
|
+
## Code of Conduct
|
185
|
+
|
186
|
+
Everyone interacting in the TrelloFreestyler project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/trello_freestyler/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'trello_freestyler'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'trello_freestyler/version'
|
4
|
+
require_relative 'trello_freestyler/cli'
|
5
|
+
require_relative 'trello_freestyler/main'
|
6
|
+
require 'tty-spinner'
|
7
|
+
|
8
|
+
if ARGV.length.positive?
|
9
|
+
spinners = TTY::Spinner::Multi.new("[:spinner] Trello Freestyler")
|
10
|
+
sp1 = spinners.register "[:spinner] Validate input options"
|
11
|
+
sp1.auto_spin
|
12
|
+
|
13
|
+
options = TrelloFreestyler::Cli.parse(ARGV)
|
14
|
+
|
15
|
+
sp1.success
|
16
|
+
|
17
|
+
sp2 = spinners.register "[:spinner] Download and clean trello data"
|
18
|
+
sp3 = spinners.register "[:spinner] Output data to: '#{options.output}'"
|
19
|
+
sp2.auto_spin
|
20
|
+
sp3.auto_spin
|
21
|
+
|
22
|
+
TrelloFreestyler::Main.dump(options)
|
23
|
+
|
24
|
+
sp2.success
|
25
|
+
sp3.success
|
26
|
+
else
|
27
|
+
TrelloFreestyler::Cli.parse %w[--help]
|
28
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'tzinfo'
|
5
|
+
|
6
|
+
module TrelloFreestyler
|
7
|
+
class Cli
|
8
|
+
Options = Struct.new(:key, :token, :url, :board_id, :action_types, :output, :timezone)
|
9
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Layout/LineLength
|
10
|
+
def self.parse(options)
|
11
|
+
# DEFAULTS
|
12
|
+
args = Options.new(nil,
|
13
|
+
nil,
|
14
|
+
'https://api.trello.com/1',
|
15
|
+
nil,
|
16
|
+
'addMemberToCard,removeMemberFromCard,createCard,moveCardFromBoard,moveCardToBoard,updateCard',
|
17
|
+
'.output',
|
18
|
+
TZInfo::Timezone.get('Australia/Melbourne'))
|
19
|
+
|
20
|
+
opt_parser = OptionParser.new do |opts|
|
21
|
+
opts.banner = 'Usage: trello_freestyler -k <KEY> -t <TOKEN> -b <BOARD_ID>'
|
22
|
+
|
23
|
+
opts.on('-k', '--key KEY', String, 'REQUIRED - Developer Trello Key') do |i|
|
24
|
+
args.key = i
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on('-t', '--token TOKEN', String, 'REQUIRED - Developer Trello Token') do |i|
|
28
|
+
args.token = i
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on('-b', '--board_id BOARD_ID', String, 'REQUIRED - The Trello Board Id to export') do |i|
|
32
|
+
args.board_id = i
|
33
|
+
end
|
34
|
+
|
35
|
+
opts.on('-a', '--actions ACTIONS', Array, "Override the list of Trello action types to dump: example 'createCard,updateCard'") do |i|
|
36
|
+
args.action_types = i.join(',')
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on('-u', '--url TRELLO_URL', String, 'Override the default Trello API Url [https://api.trello.com/1]') do |i|
|
40
|
+
args.url = i
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on('-o', '--output OUTPUT_FOLDER', String, 'Override the default output folder [.output]') do |i|
|
44
|
+
args.output = i
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on('-z', '--timezone TIME_ZONE', String, 'Override the default timezone for folder naming [Australia/Melbourne]') do |i|
|
48
|
+
args.timezone = TZInfo::Timezone.get(i)
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on('-h', '--help', 'Prints this help') do
|
52
|
+
puts opts
|
53
|
+
exit
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
opt_parser.parse!(options)
|
58
|
+
validate(args)
|
59
|
+
end
|
60
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Layout/LineLength
|
61
|
+
|
62
|
+
def self.validate(options)
|
63
|
+
if options.key && options.token && options.board_id
|
64
|
+
options
|
65
|
+
else
|
66
|
+
puts 'ERROR: One of the mandory arguments is missing. [--key, --token, --board_id]'
|
67
|
+
exit 1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rest-client'
|
4
|
+
|
5
|
+
module TrelloFreestyler
|
6
|
+
class Client
|
7
|
+
def initialize(key, token, trello_url)
|
8
|
+
@key = key
|
9
|
+
@token = token
|
10
|
+
@trello_url = trello_url
|
11
|
+
end
|
12
|
+
|
13
|
+
def auth
|
14
|
+
{ key: @key, token: @token }
|
15
|
+
end
|
16
|
+
|
17
|
+
def cards(board_id)
|
18
|
+
url = @trello_url + "/boards/#{board_id}/cards"
|
19
|
+
params = { params: auth }
|
20
|
+
RestClient.get url, params
|
21
|
+
end
|
22
|
+
|
23
|
+
def card_actions(card_id, action_types)
|
24
|
+
url = @trello_url + "/cards/#{card_id}/actions"
|
25
|
+
params = { params: auth.merge({ filter: action_types }) }
|
26
|
+
RestClient.get url, params
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'client'
|
4
|
+
require_relative 'utils/hash'
|
5
|
+
require 'json'
|
6
|
+
require 'pathname'
|
7
|
+
|
8
|
+
module TrelloFreestyler
|
9
|
+
class Main
|
10
|
+
Struct.new('CardDump', :card_ids, :raw)
|
11
|
+
Struct.new('ActionsDump', :raw)
|
12
|
+
|
13
|
+
# rubocop:disable Metrics/AbcSize
|
14
|
+
def self.dump(options)
|
15
|
+
client = TrelloFreestyler::Client.new(options.key, options.token, options.url)
|
16
|
+
|
17
|
+
response_cards = client.cards(options.board_id)
|
18
|
+
card_dump = parse_cards(response_cards.body)
|
19
|
+
|
20
|
+
actions_dump = Struct::ActionsDump.new(
|
21
|
+
card_dump
|
22
|
+
.card_ids
|
23
|
+
.map do |card_id|
|
24
|
+
action_response = client.card_actions(card_id, options.action_types)
|
25
|
+
parse_actions(action_response.body)
|
26
|
+
end.flatten
|
27
|
+
)
|
28
|
+
|
29
|
+
basename = init_output_basename(options.output, options.timezone)
|
30
|
+
export(card_dump.raw, basename.join('cards.jsonl').to_s)
|
31
|
+
export(actions_dump.raw, basename.join('actions.jsonl').to_s)
|
32
|
+
end
|
33
|
+
# rubocop:enable Metrics/AbcSize
|
34
|
+
|
35
|
+
def self.init_output_basename(base, timezone)
|
36
|
+
time = Time.now.getlocal(timezone.current_period.offset.utc_total_offset)
|
37
|
+
date = Date.parse(time.strftime('%Y/%m/%d')).to_s
|
38
|
+
base = Pathname.new(base).join(date)
|
39
|
+
Pathname.new(base).mkpath
|
40
|
+
base
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.full_filename(base, filename, timezone)
|
44
|
+
time = Time.now.getlocal(timezone.current_period.offset.utc_total_offset)
|
45
|
+
date = Date.parse(time.strftime('%Y/%m/%d')).to_s
|
46
|
+
Pathname.new(base).join(date).join(filename).to_s
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.parse_cards(raw_text)
|
50
|
+
cards = JSON.parse(raw_text)
|
51
|
+
cards.each_with_object(Struct::CardDump.new([], [])) do |card, all|
|
52
|
+
Struct::CardDump.new(
|
53
|
+
all.card_ids.push(card['id']),
|
54
|
+
all.raw.push(Utils.deep_deep_clean(card))
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.parse_actions(raw_text)
|
60
|
+
actions = JSON.parse(raw_text)
|
61
|
+
actions.map do |action|
|
62
|
+
Utils.deep_deep_clean(action)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.export(dump, to)
|
67
|
+
File.open(to, 'w') do |f|
|
68
|
+
dump.each { |row| f.puts row.to_json }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TrelloFreestyler
|
4
|
+
class Utils
|
5
|
+
def self.deep_deep_clean(hash)
|
6
|
+
# Sometimes removing one layer of empty objects creates another.
|
7
|
+
# So loop until cleaning is no longer detecting changes.
|
8
|
+
current_state = deep_copy(hash) # Who knew that object mutation was bad
|
9
|
+
loop do
|
10
|
+
new_state = deep_clean(hash)
|
11
|
+
return current_state if current_state == new_state
|
12
|
+
|
13
|
+
current_state = new_state
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.deep_clean(hash)
|
18
|
+
return hash unless hash.is_a?(Hash)
|
19
|
+
|
20
|
+
scrubed = hash.delete_if { |_, value| value == {} }
|
21
|
+
scrubed.transform_values do |val|
|
22
|
+
deep_clean(val)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.deep_copy(obj)
|
27
|
+
Marshal.load(Marshal.dump(obj))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/trello_freestyler/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'trello_freestyler'
|
7
|
+
spec.version = TrelloFreestyler::VERSION
|
8
|
+
spec.authors = ['Justin Hamman']
|
9
|
+
spec.email = ['justinhamman@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Uses the Trello API to dump json line files for a Trello board and its actions.'
|
12
|
+
spec.description = 'Built so trello data can be easily ingested into BigQuery.'
|
13
|
+
spec.homepage = 'https://rubygems.org/gems/trello_freestyler'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/juzham/trello_freestyler'
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/juzham/trello_freestyler/CHANGELOG.md'
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'rest-client'
|
22
|
+
spec.add_runtime_dependency 'tty-spinner'
|
23
|
+
spec.add_runtime_dependency 'tzinfo'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
spec.add_development_dependency 'rubocop'
|
28
|
+
spec.add_development_dependency 'rubocop-emoji'
|
29
|
+
spec.add_development_dependency 'rubocop-rspec'
|
30
|
+
|
31
|
+
# Specify which files should be added to the gem when it is released.
|
32
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
33
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
34
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
35
|
+
end
|
36
|
+
spec.bindir = 'exe'
|
37
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
|
+
spec.require_paths = ['lib']
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trello_freestyler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Hamman
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-09-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
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: tty-spinner
|
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: tzinfo
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-emoji
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Built so trello data can be easily ingested into BigQuery.
|
126
|
+
email:
|
127
|
+
- justinhamman@gmail.com
|
128
|
+
executables:
|
129
|
+
- trello_freestyler
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".rubocop.yml"
|
136
|
+
- ".travis.yml"
|
137
|
+
- CODE_OF_CONDUCT.md
|
138
|
+
- Gemfile
|
139
|
+
- Gemfile.lock
|
140
|
+
- LICENSE.txt
|
141
|
+
- README.md
|
142
|
+
- Rakefile
|
143
|
+
- bin/console
|
144
|
+
- bin/setup
|
145
|
+
- exe/trello_freestyler
|
146
|
+
- lib/trello_freestyler.rb
|
147
|
+
- lib/trello_freestyler/cli.rb
|
148
|
+
- lib/trello_freestyler/client.rb
|
149
|
+
- lib/trello_freestyler/main.rb
|
150
|
+
- lib/trello_freestyler/utils/hash.rb
|
151
|
+
- lib/trello_freestyler/version.rb
|
152
|
+
- trello_freestyler.gemspec
|
153
|
+
homepage: https://rubygems.org/gems/trello_freestyler
|
154
|
+
licenses:
|
155
|
+
- MIT
|
156
|
+
metadata:
|
157
|
+
homepage_uri: https://rubygems.org/gems/trello_freestyler
|
158
|
+
source_code_uri: https://github.com/juzham/trello_freestyler
|
159
|
+
changelog_uri: https://github.com/juzham/trello_freestyler/CHANGELOG.md
|
160
|
+
post_install_message:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
163
|
+
- lib
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 2.3.0
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
requirements: []
|
175
|
+
rubygems_version: 3.1.2
|
176
|
+
signing_key:
|
177
|
+
specification_version: 4
|
178
|
+
summary: Uses the Trello API to dump json line files for a Trello board and its actions.
|
179
|
+
test_files: []
|