idonethis-cli 0.6.0 → 0.7.0
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 +4 -4
- data/.gitignore +11 -11
- data/.travis.yml +4 -4
- data/Gemfile +3 -3
- data/LICENSE.txt +21 -21
- data/README.md +82 -82
- data/Rakefile +7 -7
- data/bin/console +14 -14
- data/bin/idonethis +9 -6
- data/bin/setup +7 -7
- data/idonethis-cli.gemspec +35 -35
- data/lib/adapters/cli.rb +71 -71
- data/lib/adapters/internet.rb +14 -14
- data/lib/adapters/settings.rb +19 -19
- data/lib/adapters/views/cli.rb +20 -20
- data/lib/idonethis/cli/version.rb +5 -5
- data/lib/idonethis/index.rb +14 -14
- data/lib/idonethis/settings_file.rb +11 -11
- data/lib/idonethis/use_cases/config.rb +40 -40
- data/lib/idonethis/use_cases/git.rb +74 -74
- data/lib/idonethis/use_cases/list.rb +62 -62
- data/lib/idonethis/use_cases/new.rb +24 -24
- data/lib/idonethis.rb +10 -10
- metadata +17 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9812e45200856e2ab7912999d37d9540083ce1a6
|
|
4
|
+
data.tar.gz: f5be7a40fdcf02920e83dec43790962f74af02f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f962cf9028626f5563ad4f6d76f3cf4bcd1d3e2bd188e3f1a78a566b54f85cacbd7b72545f443da3205cb8d9e167134f89eef1642977018f08bc5a1f7f022f35
|
|
7
|
+
data.tar.gz: 779a96f0ac78a738ea6934292190c31e7ff55b89a31f92cedd9b54c55939a2e52077868386b1d5c32d774d494175c5664820afe2473fdb796e5c71afcd380f02
|
data/.gitignore
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/.bundle/
|
|
2
|
-
/.yardoc
|
|
3
|
-
/Gemfile.lock
|
|
4
|
-
/_yardoc/
|
|
5
|
-
/coverage/
|
|
6
|
-
/doc/
|
|
7
|
-
/pkg/
|
|
8
|
-
/spec/reports/
|
|
9
|
-
/tmp/
|
|
10
|
-
.settings
|
|
11
|
-
.rspec
|
|
1
|
+
/.bundle/
|
|
2
|
+
/.yardoc
|
|
3
|
+
/Gemfile.lock
|
|
4
|
+
/_yardoc/
|
|
5
|
+
/coverage/
|
|
6
|
+
/doc/
|
|
7
|
+
/pkg/
|
|
8
|
+
/spec/reports/
|
|
9
|
+
/tmp/
|
|
10
|
+
.settings
|
|
11
|
+
.rspec
|
data/.travis.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
rvm:
|
|
3
|
-
- 2.2.1
|
|
4
|
-
before_install: gem install bundler -v 1.10.6
|
|
1
|
+
language: ruby
|
|
2
|
+
rvm:
|
|
3
|
+
- 2.2.1
|
|
4
|
+
before_install: gem install bundler -v 1.10.6
|
data/Gemfile
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
gemspec
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gemspec
|
data/LICENSE.txt
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 Ben Biddington
|
|
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.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Ben Biddington
|
|
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
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
A CLI for [idonethis](https://idonethis.com/).
|
|
2
|
-
|
|
3
|
-
[](http://travis-ci.org/ben-biddington/idonethis-cli)
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
$ gem install idonethis-cli
|
|
9
|
-
```
|
|
10
|
-
## Usage
|
|
11
|
-
|
|
12
|
-
### Configuration
|
|
13
|
-
|
|
14
|
-
Set up your token and team (find your token [here](https://idonethis.com/api/token/)):
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
$ idonethis config user.token=7513375f96b158a5c42a1337f1025d4d76d1deb
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
$ idonethis config user.team=benbiddington-personal
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### List dones
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
$ idonethis list today
|
|
28
|
-
1 2015-09-21T04:42:21.832 -- Moved settings file into lib
|
|
29
|
-
2 2015-09-21T01:22:53.058 -- Some more refactoring
|
|
30
|
-
3 2015-09-21T01:13:00.111 -- [idone] Split adapters and use cases
|
|
31
|
-
4 2015-09-20T23:29:01.002 -- Some work in change contact (js)
|
|
32
|
-
5 2015-09-20T21:47:00.903 -- Do <code>backticks</code> work?
|
|
33
|
-
6 2015-09-20T21:46:00.053 -- Seems to work on windows, though we do get that gem warning <Unresolved specs during Gem::Specification.reset>
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
You can also list dones fore the past week:
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
$ idonethis list week
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Add done
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
$ bin/idonethis new -m "Ricky Bizzness"
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Add dones based on commit activity [alpha]
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
$ bin/idonethis git
|
|
52
|
-
Scanning dir </home/ben/sauce>, which has <1> repositories that have changed
|
|
53
|
-
|
|
54
|
-
idonethis-cli (10):
|
|
55
|
-
-- [22:07] `idonethis git` prints an activity summary
|
|
56
|
-
-- [21:16] v0.4.0
|
|
57
|
-
-- [21:16] Use raw text for CLI display
|
|
58
|
-
-- [21:14] Document `list week`
|
|
59
|
-
-- [21:12] Add build status icon
|
|
60
|
-
-- [21:09] Enable `rake` (runs tests)
|
|
61
|
-
-- [21:07] v0.3.0 -- `list week`
|
|
62
|
-
-- [21:06] Enable `idonethis list week`
|
|
63
|
-
-- [20:55] Refactor: simplified
|
|
64
|
-
-- [20:48] Refactor: extract function"
|
|
65
|
-
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Development
|
|
69
|
-
|
|
70
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
71
|
-
|
|
72
|
-
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).
|
|
73
|
-
|
|
74
|
-
## Contributing
|
|
75
|
-
|
|
76
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/idonethis-cli.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
## License
|
|
80
|
-
|
|
81
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
82
|
-
|
|
1
|
+
A CLI for [idonethis](https://idonethis.com/).
|
|
2
|
+
|
|
3
|
+
[](http://travis-ci.org/ben-biddington/idonethis-cli)
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
$ gem install idonethis-cli
|
|
9
|
+
```
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
### Configuration
|
|
13
|
+
|
|
14
|
+
Set up your token and team (find your token [here](https://idonethis.com/api/token/)):
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
$ idonethis config user.token=7513375f96b158a5c42a1337f1025d4d76d1deb
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
$ idonethis config user.team=benbiddington-personal
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### List dones
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
$ idonethis list today
|
|
28
|
+
1 2015-09-21T04:42:21.832 -- Moved settings file into lib
|
|
29
|
+
2 2015-09-21T01:22:53.058 -- Some more refactoring
|
|
30
|
+
3 2015-09-21T01:13:00.111 -- [idone] Split adapters and use cases
|
|
31
|
+
4 2015-09-20T23:29:01.002 -- Some work in change contact (js)
|
|
32
|
+
5 2015-09-20T21:47:00.903 -- Do <code>backticks</code> work?
|
|
33
|
+
6 2015-09-20T21:46:00.053 -- Seems to work on windows, though we do get that gem warning <Unresolved specs during Gem::Specification.reset>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You can also list dones fore the past week:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
$ idonethis list week
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Add done
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
$ bin/idonethis new -m "Ricky Bizzness"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Add dones based on commit activity [alpha]
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
$ bin/idonethis git
|
|
52
|
+
Scanning dir </home/ben/sauce>, which has <1> repositories that have changed
|
|
53
|
+
|
|
54
|
+
idonethis-cli (10):
|
|
55
|
+
-- [22:07] `idonethis git` prints an activity summary
|
|
56
|
+
-- [21:16] v0.4.0
|
|
57
|
+
-- [21:16] Use raw text for CLI display
|
|
58
|
+
-- [21:14] Document `list week`
|
|
59
|
+
-- [21:12] Add build status icon
|
|
60
|
+
-- [21:09] Enable `rake` (runs tests)
|
|
61
|
+
-- [21:07] v0.3.0 -- `list week`
|
|
62
|
+
-- [21:06] Enable `idonethis list week`
|
|
63
|
+
-- [20:55] Refactor: simplified
|
|
64
|
+
-- [20:48] Refactor: extract function"
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Development
|
|
69
|
+
|
|
70
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
71
|
+
|
|
72
|
+
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).
|
|
73
|
+
|
|
74
|
+
## Contributing
|
|
75
|
+
|
|
76
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/idonethis-cli.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
82
|
+
|
data/Rakefile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require "bundler/gem_tasks"
|
|
2
|
-
|
|
3
|
-
require 'rspec/core/rake_task'
|
|
4
|
-
|
|
5
|
-
RSpec::Core::RakeTask.new(:test)
|
|
6
|
-
|
|
7
|
-
task :default => :test
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
|
|
3
|
+
require 'rspec/core/rake_task'
|
|
4
|
+
|
|
5
|
+
RSpec::Core::RakeTask.new(:test)
|
|
6
|
+
|
|
7
|
+
task :default => :test
|
data/bin/console
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "idonethis/cli"
|
|
5
|
-
|
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
-
|
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
# require "pry"
|
|
11
|
-
# Pry.start
|
|
12
|
-
|
|
13
|
-
require "irb"
|
|
14
|
-
IRB.start
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "idonethis/cli"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/idonethis
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "
|
|
4
|
-
require "
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "rubygems"
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "idonethis"
|
|
6
|
+
|
|
7
|
+
Bundler.require(:default)
|
|
8
|
+
|
|
9
|
+
Idonethis::Adapters::Cli.run ARGV
|
data/bin/setup
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
IFS=$'\n\t'
|
|
4
|
-
|
|
5
|
-
bundle install
|
|
6
|
-
|
|
7
|
-
# Do any other automated setup that you need to do here
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
IFS=$'\n\t'
|
|
4
|
+
|
|
5
|
+
bundle install
|
|
6
|
+
|
|
7
|
+
# Do any other automated setup that you need to do here
|
data/idonethis-cli.gemspec
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'idonethis/cli/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = "idonethis-cli"
|
|
8
|
-
spec.version = Idonethis::Cli::VERSION
|
|
9
|
-
spec.authors = ["Ben Biddington"]
|
|
10
|
-
spec.email = ["ben.biddington@gmail.com"]
|
|
11
|
-
|
|
12
|
-
spec.summary = %q{Command line interface for idonethis}
|
|
13
|
-
spec.description = %q{Command line interface for idonethis}
|
|
14
|
-
spec.homepage = "https://github.com/ben-biddington/idonethis-cli"
|
|
15
|
-
spec.license = "MIT"
|
|
16
|
-
|
|
17
|
-
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
-
# delete this section to allow pushing this gem to any host.
|
|
19
|
-
if spec.respond_to?(:metadata)
|
|
20
|
-
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
21
|
-
else
|
|
22
|
-
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
-
spec.bindir = "bin"
|
|
27
|
-
spec.executables = ['idonethis']
|
|
28
|
-
spec.require_paths = ["lib"]
|
|
29
|
-
|
|
30
|
-
spec.add_development_dependency "bundler" , "~> 1.10"
|
|
31
|
-
spec.add_development_dependency "rake" , "~> 10.0"
|
|
32
|
-
spec.add_development_dependency "rspec" , "~> 3"
|
|
33
|
-
spec.add_dependency "rest-client" , "~> 1"
|
|
34
|
-
spec.add_dependency "git" , "~> 1"
|
|
35
|
-
end
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'idonethis/cli/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "idonethis-cli"
|
|
8
|
+
spec.version = Idonethis::Cli::VERSION
|
|
9
|
+
spec.authors = ["Ben Biddington"]
|
|
10
|
+
spec.email = ["ben.biddington@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Command line interface for idonethis}
|
|
13
|
+
spec.description = %q{Command line interface for idonethis}
|
|
14
|
+
spec.homepage = "https://github.com/ben-biddington/idonethis-cli"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.bindir = "bin"
|
|
27
|
+
spec.executables = ['idonethis']
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency "bundler" , "~> 1.10"
|
|
31
|
+
spec.add_development_dependency "rake" , "~> 10.0"
|
|
32
|
+
spec.add_development_dependency "rspec" , "~> 3"
|
|
33
|
+
spec.add_dependency "rest-client" , "~> 1"
|
|
34
|
+
spec.add_dependency "git" , "~> 1"
|
|
35
|
+
end
|
data/lib/adapters/cli.rb
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
require 'internet'
|
|
2
|
-
require 'views/cli'
|
|
3
|
-
require 'use_cases/new'
|
|
4
|
-
require 'use_cases/list'
|
|
5
|
-
require 'settings_file'
|
|
6
|
-
|
|
7
|
-
module Idonethis::Adapters
|
|
8
|
-
class Cli
|
|
9
|
-
class << self
|
|
10
|
-
def run(argv={})
|
|
11
|
-
args = parse(argv)
|
|
12
|
-
|
|
13
|
-
command,*rest = argv
|
|
14
|
-
|
|
15
|
-
log = choose_log(args)
|
|
16
|
-
|
|
17
|
-
args.merge!({ opts: rest, log: log, internet: Idonethis::Adapters::Internet, view: Idonethis::Adapters::Views::Cli::List.method(:apply)})
|
|
18
|
-
credential = Settings.credential
|
|
19
|
-
|
|
20
|
-
log.call "args: #{args}, command: #{command}, rest: #{rest}"
|
|
21
|
-
|
|
22
|
-
use_cases = {
|
|
23
|
-
list: Idonethis::UseCases::List.method(:apply),
|
|
24
|
-
new: Idonethis::UseCases::New.method(:apply),
|
|
25
|
-
config: Idonethis::UseCases::Config.method(:apply),
|
|
26
|
-
git: Idonethis::UseCases::Git.method(:apply),
|
|
27
|
-
help: ->(credential, args) { puts "TODO: implement help" }
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
use_case = use_cases[command.to_sym]
|
|
31
|
-
|
|
32
|
-
unless use_case
|
|
33
|
-
puts "No command <#{command.to_sym}> found"
|
|
34
|
-
return
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
use_case.call credential, args
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
private
|
|
41
|
-
|
|
42
|
-
def choose_log(args={})
|
|
43
|
-
args[:verbose] == true ? ->(msg){puts "[LOG] #{msg}"} : ->(_){}
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def parse(argv={})
|
|
47
|
-
args = {}
|
|
48
|
-
|
|
49
|
-
require 'optparse'
|
|
50
|
-
|
|
51
|
-
OptionParser.new do |opts|
|
|
52
|
-
opts.banner = "Usage: command [options]"
|
|
53
|
-
|
|
54
|
-
opts.on("-v", "--verbose", "Run verbosely") do |v|
|
|
55
|
-
args[:verbose] = v
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
opts.on("-m MESSAGE", "Message") do |m|
|
|
59
|
-
args[:message] = m
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
opts.on("-d", "Dry run") do |_|
|
|
63
|
-
args[:dry_run] = true
|
|
64
|
-
end
|
|
65
|
-
end.parse!
|
|
66
|
-
|
|
67
|
-
args
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
1
|
+
require 'internet'
|
|
2
|
+
require 'views/cli'
|
|
3
|
+
require 'use_cases/new'
|
|
4
|
+
require 'use_cases/list'
|
|
5
|
+
require 'settings_file'
|
|
6
|
+
|
|
7
|
+
module Idonethis::Adapters
|
|
8
|
+
class Cli
|
|
9
|
+
class << self
|
|
10
|
+
def run(argv={})
|
|
11
|
+
args = parse(argv)
|
|
12
|
+
|
|
13
|
+
command,*rest = argv
|
|
14
|
+
|
|
15
|
+
log = choose_log(args)
|
|
16
|
+
|
|
17
|
+
args.merge!({ opts: rest, log: log, internet: Idonethis::Adapters::Internet, view: Idonethis::Adapters::Views::Cli::List.method(:apply)})
|
|
18
|
+
credential = Settings.credential
|
|
19
|
+
|
|
20
|
+
log.call "args: #{args}, command: #{command}, rest: #{rest}"
|
|
21
|
+
|
|
22
|
+
use_cases = {
|
|
23
|
+
list: Idonethis::UseCases::List.method(:apply),
|
|
24
|
+
new: Idonethis::UseCases::New.method(:apply),
|
|
25
|
+
config: Idonethis::UseCases::Config.method(:apply),
|
|
26
|
+
git: Idonethis::UseCases::Git.method(:apply),
|
|
27
|
+
help: ->(credential, args) { puts "TODO: implement help" }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
use_case = use_cases[command.to_sym]
|
|
31
|
+
|
|
32
|
+
unless use_case
|
|
33
|
+
puts "No command <#{command.to_sym}> found"
|
|
34
|
+
return
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
use_case.call credential, args
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def choose_log(args={})
|
|
43
|
+
args[:verbose] == true ? ->(msg){puts "[LOG] #{msg}"} : ->(_){}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def parse(argv={})
|
|
47
|
+
args = {}
|
|
48
|
+
|
|
49
|
+
require 'optparse'
|
|
50
|
+
|
|
51
|
+
OptionParser.new do |opts|
|
|
52
|
+
opts.banner = "Usage: command [options]"
|
|
53
|
+
|
|
54
|
+
opts.on("-v", "--verbose", "Run verbosely") do |v|
|
|
55
|
+
args[:verbose] = v
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
opts.on("-m MESSAGE", "Message") do |m|
|
|
59
|
+
args[:message] = m
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
opts.on("-d", "Dry run") do |_|
|
|
63
|
+
args[:dry_run] = true
|
|
64
|
+
end
|
|
65
|
+
end.parse!
|
|
66
|
+
|
|
67
|
+
args
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
data/lib/adapters/internet.rb
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
module Idonethis::Adapters
|
|
2
|
-
module Internet
|
|
3
|
-
class << self
|
|
4
|
-
require 'restclient'
|
|
5
|
-
|
|
6
|
-
def get(url, headers = {}, body = {})
|
|
7
|
-
RestClient.get(url, headers)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def post(url, headers = {}, body = {})
|
|
11
|
-
RestClient.post(url, body, headers)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
1
|
+
module Idonethis::Adapters
|
|
2
|
+
module Internet
|
|
3
|
+
class << self
|
|
4
|
+
require 'restclient'
|
|
5
|
+
|
|
6
|
+
def get(url, headers = {}, body = {})
|
|
7
|
+
RestClient.get(url, headers)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def post(url, headers = {}, body = {})
|
|
11
|
+
RestClient.post(url, body, headers)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
15
|
end
|
data/lib/adapters/settings.rb
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
module Idonethis::Adapters
|
|
2
|
-
module Settings
|
|
3
|
-
class << self
|
|
4
|
-
def credential
|
|
5
|
-
from_disk || from_env
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def from_disk
|
|
11
|
-
require 'yaml'
|
|
12
|
-
YAML.load_file Idonethis::SettingsFile.path if Idonethis::SettingsFile.exists?
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def from_env
|
|
16
|
-
{ token: ENV["TOKEN"], team: ENV["TEAM"] }
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
1
|
+
module Idonethis::Adapters
|
|
2
|
+
module Settings
|
|
3
|
+
class << self
|
|
4
|
+
def credential
|
|
5
|
+
from_disk || from_env
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def from_disk
|
|
11
|
+
require 'yaml'
|
|
12
|
+
YAML.load_file Idonethis::SettingsFile.path if Idonethis::SettingsFile.exists?
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def from_env
|
|
16
|
+
{ token: ENV["TOKEN"], team: ENV["TEAM"] }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
20
|
end
|
data/lib/adapters/views/cli.rb
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
module Idonethis::Adapters
|
|
2
|
-
module Views
|
|
3
|
-
module Cli
|
|
4
|
-
module List
|
|
5
|
-
class << self
|
|
6
|
-
def apply(dones=[])
|
|
7
|
-
dones.select{|it| it["is_goal"] == false}.each_with_index do |d,i|
|
|
8
|
-
#{
|
|
9
|
-
# "id"=>22609300, "created"=>"2015-09-09T06:26:07.120", "updated"=>"2015-09-19T13:00:03.570", "markedup_text"=>"fix api smoke", "done_date"=>"2015-09-20", "owner"=>"ben.biddington",
|
|
10
|
-
# "team_short_name"=>"benbiddington-personal", "tags"=>[], "likes"=>[], "comments"=>[], "meta_data"=>{}, "is_goal"=>true, "goal_completed"=>false,
|
|
11
|
-
# "url"=>"https://idonethis.com/api/v0.1/dones/22609300/", "team"=>"https://idonethis.com/api/v0.1/teams/benbiddington-personal/", "raw_text"=>"[ ] fix api smoke", "permalink"=>"https://idonethis.com/done/22609300/"}
|
|
12
|
-
# puts d.inspect
|
|
13
|
-
printf("%-5s", i+1); puts %Q{#{d["created"]} -- #{d["raw_text"].slice(0,150)}}
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
1
|
+
module Idonethis::Adapters
|
|
2
|
+
module Views
|
|
3
|
+
module Cli
|
|
4
|
+
module List
|
|
5
|
+
class << self
|
|
6
|
+
def apply(dones=[])
|
|
7
|
+
dones.select{|it| it["is_goal"] == false}.each_with_index do |d,i|
|
|
8
|
+
#{
|
|
9
|
+
# "id"=>22609300, "created"=>"2015-09-09T06:26:07.120", "updated"=>"2015-09-19T13:00:03.570", "markedup_text"=>"fix api smoke", "done_date"=>"2015-09-20", "owner"=>"ben.biddington",
|
|
10
|
+
# "team_short_name"=>"benbiddington-personal", "tags"=>[], "likes"=>[], "comments"=>[], "meta_data"=>{}, "is_goal"=>true, "goal_completed"=>false,
|
|
11
|
+
# "url"=>"https://idonethis.com/api/v0.1/dones/22609300/", "team"=>"https://idonethis.com/api/v0.1/teams/benbiddington-personal/", "raw_text"=>"[ ] fix api smoke", "permalink"=>"https://idonethis.com/done/22609300/"}
|
|
12
|
+
# puts d.inspect
|
|
13
|
+
printf("%-5s", i+1); puts %Q{#{d["created"]} -- #{d["raw_text"].slice(0,150)}}
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
module Idonethis
|
|
2
|
-
module Cli
|
|
3
|
-
VERSION = "0.
|
|
4
|
-
end
|
|
5
|
-
end
|
|
1
|
+
module Idonethis
|
|
2
|
+
module Cli
|
|
3
|
+
VERSION = "0.7.0"
|
|
4
|
+
end
|
|
5
|
+
end
|
data/lib/idonethis/index.rb
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
module Idonethis
|
|
2
|
-
module Index
|
|
3
|
-
class << self
|
|
4
|
-
def dones(params={})
|
|
5
|
-
%Q{#{dones_base_earl}?#{params.map{|k,v| "#{k}=#{v}"}.join('&')}}
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
def dones_base_earl
|
|
11
|
-
"https://idonethis.com/api/v0.1/dones/"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
1
|
+
module Idonethis
|
|
2
|
+
module Index
|
|
3
|
+
class << self
|
|
4
|
+
def dones(params={})
|
|
5
|
+
%Q{#{dones_base_earl}?#{params.map{|k,v| "#{k}=#{v}"}.join('&')}}
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
private
|
|
9
|
+
|
|
10
|
+
def dones_base_earl
|
|
11
|
+
"https://idonethis.com/api/v0.1/dones/"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
15
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
module Idonethis
|
|
2
|
-
class SettingsFile
|
|
3
|
-
class << self
|
|
4
|
-
def exists?; File.exists?(path); end
|
|
5
|
-
|
|
6
|
-
def path
|
|
7
|
-
@@path ||= File.expand_path("~/.idonethis.settings")
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
1
|
+
module Idonethis
|
|
2
|
+
class SettingsFile
|
|
3
|
+
class << self
|
|
4
|
+
def exists?; File.exists?(path); end
|
|
5
|
+
|
|
6
|
+
def path
|
|
7
|
+
@@path ||= File.expand_path("~/.idonethis.settings")
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
module Idonethis::UseCases
|
|
2
|
-
module Config
|
|
3
|
-
class << self
|
|
4
|
-
def apply(_, args={})
|
|
5
|
-
log = args[:log] || fail("You need to supply :log adapter")
|
|
6
|
-
|
|
7
|
-
log.call "args: #{args}"
|
|
8
|
-
|
|
9
|
-
require 'yaml'
|
|
10
|
-
|
|
11
|
-
settings = File.exists?(filename) ? YAML.load_file(filename) : {}
|
|
12
|
-
|
|
13
|
-
token = (args[:opts].map{|it| it.match /user.token=(.+)/}.compact || []).first
|
|
14
|
-
|
|
15
|
-
if token
|
|
16
|
-
File.open filename, "w+" do |f|
|
|
17
|
-
f.puts(settings.merge({token: token[1]}).to_yaml)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
team = (args[:opts].map{|it| it.match /user.team=(.+)/}.compact || []).first
|
|
22
|
-
|
|
23
|
-
if team
|
|
24
|
-
File.open filename, "w+" do |f|
|
|
25
|
-
f.puts(settings.merge({team: team[1]}).to_yaml)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
puts "Settings saved to <#{filename}>"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
def filename
|
|
35
|
-
require 'settings_file'
|
|
36
|
-
Idonethis::SettingsFile.path
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
1
|
+
module Idonethis::UseCases
|
|
2
|
+
module Config
|
|
3
|
+
class << self
|
|
4
|
+
def apply(_, args={})
|
|
5
|
+
log = args[:log] || fail("You need to supply :log adapter")
|
|
6
|
+
|
|
7
|
+
log.call "args: #{args}"
|
|
8
|
+
|
|
9
|
+
require 'yaml'
|
|
10
|
+
|
|
11
|
+
settings = File.exists?(filename) ? YAML.load_file(filename) : {}
|
|
12
|
+
|
|
13
|
+
token = (args[:opts].map{|it| it.match /user.token=(.+)/}.compact || []).first
|
|
14
|
+
|
|
15
|
+
if token
|
|
16
|
+
File.open filename, "w+" do |f|
|
|
17
|
+
f.puts(settings.merge({token: token[1]}).to_yaml)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
team = (args[:opts].map{|it| it.match /user.team=(.+)/}.compact || []).first
|
|
22
|
+
|
|
23
|
+
if team
|
|
24
|
+
File.open filename, "w+" do |f|
|
|
25
|
+
f.puts(settings.merge({team: team[1]}).to_yaml)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
puts "Settings saved to <#{filename}>"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def filename
|
|
35
|
+
require 'settings_file'
|
|
36
|
+
Idonethis::SettingsFile.path
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
module Idonethis::UseCases
|
|
2
|
-
module Git
|
|
3
|
-
class << self
|
|
4
|
-
def apply(credential, args={})
|
|
5
|
-
log = args[:log] || fail("You need to supply :log adapter")
|
|
6
|
-
|
|
7
|
-
log.call args
|
|
8
|
-
|
|
9
|
-
opts = args[:opts]
|
|
10
|
-
|
|
11
|
-
dir = opts.any? ? File.expand_path(opts.first) : File.expand_path(".")
|
|
12
|
-
|
|
13
|
-
if opts.any?
|
|
14
|
-
all_dirs = directories_in(dir)
|
|
15
|
-
|
|
16
|
-
log.call("All directories in <#{dir}>: #{all_dirs}")
|
|
17
|
-
|
|
18
|
-
dirs_that_have_changed_today = all_dirs.select{|it| modified_today?(it, log) }
|
|
19
|
-
|
|
20
|
-
puts "Scanning dir <#{dir}>, which has <#{dirs_that_have_changed_today.size}> repositories that have changed today\n\n"
|
|
21
|
-
|
|
22
|
-
summarise *dirs_that_have_changed_today
|
|
23
|
-
|
|
24
|
-
puts ""
|
|
25
|
-
else
|
|
26
|
-
puts "Scanning the current directory <#{dir}>\n\n"
|
|
27
|
-
summarise dir
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def summarise(*dirs)
|
|
32
|
-
dirs.each do |dir|
|
|
33
|
-
summary = commit_summary(dir)
|
|
34
|
-
puts %Q{#{Pathname.new(dir).basename} (#{summary.size}):\n-- #{summary.join("\n-- ")}}
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def directories_in(dir)
|
|
39
|
-
Dir.entries(dir).
|
|
40
|
-
reject{|it| ["..", "."].include?(it) }.
|
|
41
|
-
select{|it| File.directory?(File.join(dir, it))}.
|
|
42
|
-
map{ |it| File.expand_path(File.join(dir, it))}
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def modified_today?(dir, log)
|
|
46
|
-
time = File.ctime(dir)
|
|
47
|
-
now = Time.now
|
|
48
|
-
|
|
49
|
-
any_file_changed_today?(dir, time, now, log).tap do |result|
|
|
50
|
-
log.call "[#{dir}] Comparing mtime <#{time}> to today <#{now}>. Today? <#{result}>"
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def any_file_changed_today?(dir, time, now, log)
|
|
55
|
-
Dir["#{dir}/**/**"].select do |file|
|
|
56
|
-
mtime = File.ctime(file)
|
|
57
|
-
log.call "File <#{file}> has mtime <#{mtime}>"
|
|
58
|
-
return true if today?(mtime, now)
|
|
59
|
-
end
|
|
60
|
-
return false
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def today?(time, now)
|
|
64
|
-
time.year == now.year && time.month == now.month && time.day == now.day
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def commit_summary(dir)
|
|
68
|
-
require 'git'
|
|
69
|
-
git = ::Git.open(dir)
|
|
70
|
-
git.log.since('1am').map{|it| %Q{[#{it.date.strftime("%H:%M")}] #{it.message}}}
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
1
|
+
module Idonethis::UseCases
|
|
2
|
+
module Git
|
|
3
|
+
class << self
|
|
4
|
+
def apply(credential, args={})
|
|
5
|
+
log = args[:log] || fail("You need to supply :log adapter")
|
|
6
|
+
|
|
7
|
+
log.call args
|
|
8
|
+
|
|
9
|
+
opts = args[:opts]
|
|
10
|
+
|
|
11
|
+
dir = opts.any? ? File.expand_path(opts.first) : File.expand_path(".")
|
|
12
|
+
|
|
13
|
+
if opts.any?
|
|
14
|
+
all_dirs = directories_in(dir)
|
|
15
|
+
|
|
16
|
+
log.call("All directories in <#{dir}>: #{all_dirs}")
|
|
17
|
+
|
|
18
|
+
dirs_that_have_changed_today = all_dirs.select{|it| modified_today?(it, log) }
|
|
19
|
+
|
|
20
|
+
puts "Scanning dir <#{dir}>, which has <#{dirs_that_have_changed_today.size}> repositories that have changed today\n\n"
|
|
21
|
+
|
|
22
|
+
summarise *dirs_that_have_changed_today
|
|
23
|
+
|
|
24
|
+
puts ""
|
|
25
|
+
else
|
|
26
|
+
puts "Scanning the current directory <#{dir}>\n\n"
|
|
27
|
+
summarise dir
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def summarise(*dirs)
|
|
32
|
+
dirs.each do |dir|
|
|
33
|
+
summary = commit_summary(dir)
|
|
34
|
+
puts %Q{#{Pathname.new(dir).basename} (#{summary.size}):\n-- #{summary.join("\n-- ")}}
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def directories_in(dir)
|
|
39
|
+
Dir.entries(dir).
|
|
40
|
+
reject{|it| ["..", "."].include?(it) }.
|
|
41
|
+
select{|it| File.directory?(File.join(dir, it))}.
|
|
42
|
+
map{ |it| File.expand_path(File.join(dir, it))}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def modified_today?(dir, log)
|
|
46
|
+
time = File.ctime(dir)
|
|
47
|
+
now = Time.now
|
|
48
|
+
|
|
49
|
+
any_file_changed_today?(dir, time, now, log).tap do |result|
|
|
50
|
+
log.call "[#{dir}] Comparing mtime <#{time}> to today <#{now}>. Today? <#{result}>"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def any_file_changed_today?(dir, time, now, log)
|
|
55
|
+
Dir["#{dir}/**/**"].select do |file|
|
|
56
|
+
mtime = File.ctime(file)
|
|
57
|
+
log.call "File <#{file}> has mtime <#{mtime}>"
|
|
58
|
+
return true if today?(mtime, now)
|
|
59
|
+
end
|
|
60
|
+
return false
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def today?(time, now)
|
|
64
|
+
time.year == now.year && time.month == now.month && time.day == now.day
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def commit_summary(dir)
|
|
68
|
+
require 'git'
|
|
69
|
+
git = ::Git.open(dir)
|
|
70
|
+
git.log.since('1am').map{|it| %Q{[#{it.date.strftime("%H:%M")}] #{it.message}}}
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
module Idonethis::UseCases
|
|
2
|
-
module List
|
|
3
|
-
class << self
|
|
4
|
-
def apply(credential, args={})
|
|
5
|
-
log = args[:log] || fail("You need to supply :log adapter")
|
|
6
|
-
view = args[:view] || fail("You need to supply :view adapter")
|
|
7
|
-
|
|
8
|
-
list = get(credential, log, args).tap{|result| log.call(result)}
|
|
9
|
-
|
|
10
|
-
view.call list
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
private
|
|
14
|
-
|
|
15
|
-
def get(credential, log, args)
|
|
16
|
-
result = []
|
|
17
|
-
page = 1
|
|
18
|
-
|
|
19
|
-
loop do
|
|
20
|
-
reply = get_page(page, credential, log, args)
|
|
21
|
-
|
|
22
|
-
result += reply["results"]
|
|
23
|
-
|
|
24
|
-
page += 1
|
|
25
|
-
|
|
26
|
-
break if reply["next"].nil?
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
result
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def get_page(page, credential, log, args) # https://idonethis.com/api/v0.1/dones/
|
|
33
|
-
params = {"order_by" => "-created", "page_size" => 100, "page" => page}.
|
|
34
|
-
merge(done_date_from(args))
|
|
35
|
-
|
|
36
|
-
url = Idonethis::Index.dones(params)
|
|
37
|
-
|
|
38
|
-
log.call "url: #{url}"
|
|
39
|
-
|
|
40
|
-
internet = args[:internet] || fail("You need to supply :internet adapter")
|
|
41
|
-
|
|
42
|
-
parse internet.get(url, { "Authorization" => "Token #{credential[:token]}", accept: "application/json"})
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def done_date_from(args)
|
|
46
|
-
if args[:opts].include?("week")
|
|
47
|
-
return { done_date_after: (Time.now - (7*24*60*60)).strftime("%F") }
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
intersection = (args[:opts] || []) & %W{ today yesterday }
|
|
51
|
-
|
|
52
|
-
return intersection.empty? ? { done_date: 'today' } : { done_date: intersection.first }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def parse(reply)
|
|
56
|
-
require 'json'
|
|
57
|
-
|
|
58
|
-
JSON.parse(reply.body)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
1
|
+
module Idonethis::UseCases
|
|
2
|
+
module List
|
|
3
|
+
class << self
|
|
4
|
+
def apply(credential, args={})
|
|
5
|
+
log = args[:log] || fail("You need to supply :log adapter")
|
|
6
|
+
view = args[:view] || fail("You need to supply :view adapter")
|
|
7
|
+
|
|
8
|
+
list = get(credential, log, args).tap{|result| log.call(result)}
|
|
9
|
+
|
|
10
|
+
view.call list
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def get(credential, log, args)
|
|
16
|
+
result = []
|
|
17
|
+
page = 1
|
|
18
|
+
|
|
19
|
+
loop do
|
|
20
|
+
reply = get_page(page, credential, log, args)
|
|
21
|
+
|
|
22
|
+
result += reply["results"]
|
|
23
|
+
|
|
24
|
+
page += 1
|
|
25
|
+
|
|
26
|
+
break if reply["next"].nil?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
result
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def get_page(page, credential, log, args) # https://idonethis.com/api/v0.1/dones/
|
|
33
|
+
params = {"order_by" => "-created", "page_size" => 100, "page" => page}.
|
|
34
|
+
merge(done_date_from(args))
|
|
35
|
+
|
|
36
|
+
url = Idonethis::Index.dones(params)
|
|
37
|
+
|
|
38
|
+
log.call "url: #{url}"
|
|
39
|
+
|
|
40
|
+
internet = args[:internet] || fail("You need to supply :internet adapter")
|
|
41
|
+
|
|
42
|
+
parse internet.get(url, { "Authorization" => "Token #{credential[:token]}", accept: "application/json"})
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def done_date_from(args)
|
|
46
|
+
if args[:opts].include?("week")
|
|
47
|
+
return { done_date_after: (Time.now - (7*24*60*60)).strftime("%F") }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
intersection = (args[:opts] || []) & %W{ today yesterday }
|
|
51
|
+
|
|
52
|
+
return intersection.empty? ? { done_date: 'today' } : { done_date: intersection.first }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def parse(reply)
|
|
56
|
+
require 'json'
|
|
57
|
+
|
|
58
|
+
JSON.parse(reply.body)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
module Idonethis::UseCases
|
|
2
|
-
module New
|
|
3
|
-
class << self
|
|
4
|
-
def apply(credential, args={})
|
|
5
|
-
log = args[:log] || fail("You need to supply :internet adapter")
|
|
6
|
-
internet = args[:internet] || fail("You need to supply :internet adapter")
|
|
7
|
-
|
|
8
|
-
log.call "args: #{args}"
|
|
9
|
-
|
|
10
|
-
parse internet.post(
|
|
11
|
-
Idonethis::Index.dones,
|
|
12
|
-
{ "Authorization" => "Token #{credential[:token]}", accept: "application/json"},
|
|
13
|
-
{ "raw_text" => args[:message], "team" => credential[:team]})
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def parse(reply)
|
|
19
|
-
require 'json'
|
|
20
|
-
|
|
21
|
-
JSON.parse(reply.body)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
1
|
+
module Idonethis::UseCases
|
|
2
|
+
module New
|
|
3
|
+
class << self
|
|
4
|
+
def apply(credential, args={})
|
|
5
|
+
log = args[:log] || fail("You need to supply :internet adapter")
|
|
6
|
+
internet = args[:internet] || fail("You need to supply :internet adapter")
|
|
7
|
+
|
|
8
|
+
log.call "args: #{args}"
|
|
9
|
+
|
|
10
|
+
parse internet.post(
|
|
11
|
+
Idonethis::Index.dones,
|
|
12
|
+
{ "Authorization" => "Token #{credential[:token]}", accept: "application/json"},
|
|
13
|
+
{ "raw_text" => args[:message], "team" => credential[:team]})
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def parse(reply)
|
|
19
|
+
require 'json'
|
|
20
|
+
|
|
21
|
+
JSON.parse(reply.body)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
25
|
end
|
data/lib/idonethis.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require "idonethis/cli/version"
|
|
2
|
-
|
|
3
|
-
lib = File.expand_path(File.join(File.dirname(__FILE__), "idonethis"))
|
|
4
|
-
adapters = File.expand_path(File.join(File.dirname(__FILE__), "adapters"))
|
|
5
|
-
|
|
6
|
-
$:.unshift lib
|
|
7
|
-
$:.unshift adapters
|
|
8
|
-
|
|
9
|
-
Dir.glob(File.join(lib, "**", "*.rb")).each {|file| require file}
|
|
10
|
-
Dir.glob(File.join(adapters, "**", "*.rb")).each {|file| require file}
|
|
1
|
+
require "idonethis/cli/version"
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path(File.join(File.dirname(__FILE__), "idonethis"))
|
|
4
|
+
adapters = File.expand_path(File.join(File.dirname(__FILE__), "adapters"))
|
|
5
|
+
|
|
6
|
+
$:.unshift lib
|
|
7
|
+
$:.unshift adapters
|
|
8
|
+
|
|
9
|
+
Dir.glob(File.join(lib, "**", "*.rb")).each {|file| require file}
|
|
10
|
+
Dir.glob(File.join(adapters, "**", "*.rb")).each {|file| require file}
|
metadata
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: idonethis-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Biddington
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-09-
|
|
11
|
+
date: 2015-09-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - ~>
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '1.10'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - ~>
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.10'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - ~>
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '10.0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - ~>
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '10.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- -
|
|
45
|
+
- - ~>
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: '3'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- -
|
|
52
|
+
- - ~>
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '3'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: rest-client
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- -
|
|
59
|
+
- - ~>
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '1'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- -
|
|
66
|
+
- - ~>
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '1'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: git
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- -
|
|
73
|
+
- - ~>
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '1'
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- -
|
|
80
|
+
- - ~>
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '1'
|
|
83
83
|
description: Command line interface for idonethis
|
|
@@ -88,8 +88,8 @@ executables:
|
|
|
88
88
|
extensions: []
|
|
89
89
|
extra_rdoc_files: []
|
|
90
90
|
files:
|
|
91
|
-
-
|
|
92
|
-
-
|
|
91
|
+
- .gitignore
|
|
92
|
+
- .travis.yml
|
|
93
93
|
- Gemfile
|
|
94
94
|
- LICENSE.txt
|
|
95
95
|
- README.md
|
|
@@ -121,17 +121,17 @@ require_paths:
|
|
|
121
121
|
- lib
|
|
122
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
requirements:
|
|
124
|
-
- -
|
|
124
|
+
- - '>='
|
|
125
125
|
- !ruby/object:Gem::Version
|
|
126
126
|
version: '0'
|
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
|
-
- -
|
|
129
|
+
- - '>='
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
131
|
version: '0'
|
|
132
132
|
requirements: []
|
|
133
133
|
rubyforge_project:
|
|
134
|
-
rubygems_version: 2.
|
|
134
|
+
rubygems_version: 2.0.3
|
|
135
135
|
signing_key:
|
|
136
136
|
specification_version: 4
|
|
137
137
|
summary: Command line interface for idonethis
|