ididthis 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d96d5a0d64ef05567ce8088722435629e3ce11b9
4
- data.tar.gz: c3694cebc2b4b2c03670d4cb1ee468ad7fa7335e
3
+ metadata.gz: a5fdab8903df3a60ba03a9f4a27e8109d8282788
4
+ data.tar.gz: 92ec7c0fd2bef95cec4ac17acaf5461e2a26ded8
5
5
  SHA512:
6
- metadata.gz: 349d940206ae53410b28f008aba853b432e30f32111ce2a78b727cd8b8a615a35d484d8ad15686f71ecefb81e283d32925e83244edb19c1043619c774a9b12e9
7
- data.tar.gz: 394ed3a088aa9efa69970b16fdcb20008732c5a0fd09339b358f715c2d359093607efd3de9399880dffc289fd2892ffa883efb5532cae1d28c6a9831ecf4bd24
6
+ metadata.gz: 04b657883d8cf00816998cd1b31d8f0060f7eb254e797d9af74170a9a426f47d972f8ccb2e54359f9d406fcb16a198e4e6f1491d130f1c0b4f833618ccda792d
7
+ data.tar.gz: b528860b50263e07e6bdca0ad3cfc7374c9135016c9f48c97a9341258b2c6f5fe60c9be7ff2416afd8c39b1a957899b3fe34c74adaa215bc82355f5a9362c3c6
data/.codeclimate.yml ADDED
@@ -0,0 +1,3 @@
1
+ languages:
2
+ Ruby: true
3
+
data/.document ADDED
@@ -0,0 +1,6 @@
1
+ lib/*.rb
2
+ lib/**/*.rb
3
+ -
4
+ CHANGELOG.rdoc
5
+ LICENSE.md
6
+
data/.gitignore CHANGED
@@ -7,5 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
-
10
+ /bin/
11
11
  .ruby-*
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format documentation
2
+ --order random
2
3
  --color
data/.rubocop.yml ADDED
@@ -0,0 +1,22 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ require: rubocop-rspec
4
+
5
+ AllCops:
6
+ Include:
7
+ - 'Gemfile'
8
+ - 'Rakefile'
9
+ - 'ididthis.gemspec'
10
+ Exclude:
11
+ - bin/*
12
+
13
+ # Enforce outdented access modifiers
14
+ AccessModifierIndentation:
15
+ EnforcedStyle: outdent
16
+
17
+ EmptyLinesAroundAccessModifier:
18
+ Enabled: true
19
+
20
+ # Standardize on double quotes
21
+ StringLiterals:
22
+ EnforcedStyle: double_quotes
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,69 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-08-07 11:34:15 -0400 using RuboCop version 0.33.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Lint/UselessAssignment:
11
+ Exclude:
12
+ - 'lib/ididthis/cli.rb'
13
+
14
+ # Offense count: 1
15
+ Metrics/AbcSize:
16
+ Max: 18
17
+
18
+ # Offense count: 1
19
+ # Configuration parameters: CountComments.
20
+ Metrics/ClassLength:
21
+ Max: 123
22
+
23
+ # Offense count: 5
24
+ # Configuration parameters: AllowURI, URISchemes.
25
+ Metrics/LineLength:
26
+ Max: 112
27
+
28
+ # Offense count: 3
29
+ # Configuration parameters: CountComments.
30
+ Metrics/MethodLength:
31
+ Max: 12
32
+
33
+ # Offense count: 2
34
+ # Cop supports --auto-correct.
35
+ # Configuration parameters: SupportedStyles.
36
+ Style/AccessModifierIndentation:
37
+ EnforcedStyle: outdent
38
+
39
+ # Offense count: 24
40
+ # Cop supports --auto-correct.
41
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
42
+ Style/AlignParameters:
43
+ Enabled: false
44
+
45
+ # Offense count: 1
46
+ Style/Documentation:
47
+ Exclude:
48
+ - 'lib/ididthis/version.rb'
49
+
50
+ # Offense count: 4
51
+ # Configuration parameters: Exclude.
52
+ Style/FileName:
53
+ Exclude:
54
+ - 'bin/cc-tddium-post-worker'
55
+ - 'bin/git-version-bump'
56
+ - 'bin/ruby-parse'
57
+ - 'bin/ruby-rewrite'
58
+
59
+ # Offense count: 58
60
+ # Cop supports --auto-correct.
61
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
62
+ Style/HashSyntax:
63
+ Enabled: false
64
+
65
+ # Offense count: 176
66
+ # Cop supports --auto-correct.
67
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
68
+ Style/StringLiterals:
69
+ Enabled: false
data/.simplecov ADDED
@@ -0,0 +1,15 @@
1
+ require 'coveralls'
2
+ require 'codeclimate-test-reporter'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter,
7
+ CodeClimate::TestReporter::Formatter
8
+ ]
9
+
10
+ SimpleCov.start do
11
+ add_filter "/spec/"
12
+ minimum_coverage(50.0)
13
+ end
14
+
15
+
data/.travis.yml CHANGED
@@ -1,7 +1,17 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 1.9.3
5
- - jruby
6
- before_install:
7
- - gem install bundler -v 1.10.2
3
+ - 2.2.0
4
+ - 2.1.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - jruby
8
+ before_install:
9
+ - gem install bundler -v 1.10.2
10
+ script:
11
+ - bundle exec rake test
12
+ notifications:
13
+ pushover:
14
+ api_key:
15
+ secure: B4aN8EQW8mVLk14cgY8MeZuUCj3UsoVsYvDPNIPOrWLCxdyIFSdE0ncIzejGKyfE+hIzEFEO8shBBRXu4GksEemj3RD5hm7rNMtOGbcSDq7+Bm03MU65RABDsXm4JFwCop770ZEtVbEuTmivA33Upaxlw6cBwjS8EgYVnjI60IfOiQePD5hc0X8dcGYDzxe05tzEFB8KJxUDsajfUdXFkRcRhwKrrFggs6OIRl+h35OYFs2IkYYKxRkvfsU2LJQ4D8QMq0ZxNLu5BNxTFAJmiuBzPH2gfCHnE1Ny7TFA0orAXVWcNT5s9llJpkidtgUhWI9m1c1YXPq94fmSZW9JZTzQLhl7enbw6p0ZuajYcrtacatCvdecJQeWKrJRddqOjRRUusS9zrj7UYWtMQx7Sg0+z/Yq/ooiZFo2jnMfdm3dsw7CnBw9uCVDc9St9GXU1AbysfUi8pq4tQB5CorJZO81Y0e2wAXqak/NKKFOvFpuZAaAb4zwRVd71otOoU+WvP1UxlmqJPkxWZ9MCbHvwVDyj0bn92R0hv2XfWON71dGxAHpkwQy4FFvxMztZASfg1uHElQ0bLbC0P1dXnR9ExaqU/KxwwPjFhfcKP2+mxD2upUinWHIPFjudSPlWaogCDbQ/iuZahXKZgFTMunJ5enqtYw1mjQlr3Hsn3bZ1Iw=
16
+ users:
17
+ secure: tnFgv9r4mYeVsL+uvvVh9ncoIDEQGgtIC069OP1kuNH6RZobz5qLBX2IEz6WWasyms++T1jt6UJhGR2bIzXb8GHTn2WyNjczqlLLuai/lIhQdSd3t1v4po0MDuD6pyBQ8oUri39Zuw99fqcQwEcP+pMjp0iqPSdVj1qznMl7zEirs19ZHLPp/ejA/OBSM5D44Rhi+hW8aZ0n0ROUaZSt6xHeS0qO4Gy0Rpmq4QV39ovJUHsURZF9etGUTtJw8o3ZxrFXOJSAnh+n37Gc5F+KVx7SzerwD7AC699m8CbdoDq32xK+v/wGzwRz68HoTCir4Nl0FT+JWudoJdQbcLJ7bbN0paBXc7Ogf8rGv9I7tRiMEwRVLZaRjXdDRpnHeutfWH1DG3K6Q+HnOIpVAlz4oQR5gcGOmriLB78aNCZELxc7j41bnrii53PTgtxdsXqvuIkHm5eLPQFd6AlvMlN3ZnsJja492YkBOx+jf94Uk11e12kK8q1xKR29yyH/o7eeDb8q89Pa1YksaS7m+yKy3zq26XGsFDk646D3FMc69wOS4YRmj4N0rdtpZRpHnQuvC0TCjBtfbSDmgNhj/DQzVrqOuJ8qUwWk75B3miYrRkIMLqtmXqJbpu3QUlDP4MvtH1vqZD1hOBUDqAlAIGD+4Wfd8JqUxAAxyAmnO8VpISE=
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in ididthis.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,41 +1,57 @@
1
- # Ididthis
1
+ [![Gem Version](https://badge.fury.io/rb/ididthis.svg)] [rubygems]
2
+ [![Build Status](https://travis-ci.org/duckpuppy/ididthis.svg)] [travis]
3
+ [![Dependency Status](https://gemnasium.com/duckpuppy/ididthis.svg)] [gemnasium]
4
+ [![Code Climate](https://codeclimate.com/github/duckpuppy/ididthis/badges/gpa.svg)] [code_climate]
5
+ [![Coverage Status](https://coveralls.io/repos/duckpuppy/ididthis/badge.svg?branch=develop&service=github)] [coveralls]
6
+ [![Downloads](https://img.shields.io/gem/dtv/ididthis.svg)]()
2
7
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ididthis`. To experiment with that code, run `bin/console` for an interactive prompt.
8
+ [rubygems]: http://badge.fury.io/rb/ididthis
9
+ [travis]: https://travis-ci.org/duckpuppy/ididthis
10
+ [gemnasium]: https://gemnasium.com/duckpuppy/ididthis
11
+ [code_climate]: https://codeclimate.com/github/duckpuppy/ididthis
12
+ [coveralls]: https://coveralls.io/github/duckpuppy/ididthis?branch=develop
4
13
 
5
- TODO: Delete this and the text above, and describe your gem
14
+ # ididthis
6
15
 
7
- ## Installation
16
+ `ididthis` is a command-line utilty for posting and viewing dones on [iDoneThis] [idonethis].
8
17
 
9
- Add this line to your application's Gemfile:
18
+ ## Installation
10
19
 
11
- ```ruby
12
- gem 'ididthis'
13
- ```
20
+ $ gem install ididthis
14
21
 
15
- And then execute:
22
+ ## Usage
16
23
 
17
- $ bundle
24
+ A list of commands for `ididthis` can be seen by running
18
25
 
19
- Or install it yourself as:
26
+ $ ididthis help
20
27
 
21
- $ gem install ididthis
28
+ Addtional help for a command can be show by running
22
29
 
23
- ## Usage
30
+ $ ididthis help COMMAND
24
31
 
25
- TODO: Write usage instructions here
32
+ `ididthis` supports only what the current [iDoneThis API] [idonethis_api] allows. As newer releases of the API are developed, this gem will update to take advantage of the newer functionality.
33
+ Noticably missing from the API currently are methods for manipulating existing dones.
26
34
 
27
35
  ## Development
28
36
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+ After checking out the repo, run `bundle install` to install dependencies.
38
+ Then, run `rake rspec` to run the tests. You can also run `rake console` for an
39
+ interactive prompt that will allow you to experiment.
30
40
 
31
- 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).
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To
42
+ release a new version, update the version number in `version.rb`, and then run
43
+ `bundle exec rake release`, which will create a git tag for the version if one
44
+ doesn't exist, push git commits and tags, and push the `.gem` file to
45
+ [rubygems.org](https://rubygems.org).
32
46
 
33
47
  ## Contributing
34
48
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ididthis. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/duckpuppy/ididthis. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
50
 
37
51
 
38
52
  ## License
39
53
 
40
54
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
55
 
56
+ [idonethis]: https://idonethis.com
57
+ [idonethis_api]: https://idoneths.com/api
data/Rakefile CHANGED
@@ -1,18 +1,51 @@
1
- require "bundler/gem_tasks"
1
+ # require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
  require "rubygems/tasks"
4
4
  require "dotenv/tasks"
5
+ require "rake/clean"
6
+ require "rdoc/task"
7
+ require "rubocop/rake_task"
5
8
 
6
- lib_dir = File.expand_path('lib', File.dirname(__FILE__))
9
+ lib_dir = File.expand_path("lib", File.dirname(__FILE__))
7
10
  $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
8
11
 
12
+ CLEAN.include("pkg")
13
+ CLEAN.include("coverage")
14
+
9
15
  RSpec::Core::RakeTask.new(:spec)
16
+
17
+ RuboCop::RakeTask.new do |task|
18
+ task.requires << "rubocop-rspec"
19
+ task.options = ["-fh", "-ocoverage/rubocop.html",
20
+ "-fj", "-ocoverage/rubocop.json"]
21
+ end
22
+
10
23
  Gem::Tasks.new(
11
- build: {gem: true, tar: true, zip:true},
12
- sign: {checksum: true, pgp: false}
24
+ build: { gem: true, tar: true, zip: true },
25
+ sign: { checksum: true, pgp: false },
26
+ scm: { tag: false }
13
27
  ) do |tasks|
14
- tasks.console.command = 'pry'
28
+ tasks.console.command = "pry"
15
29
  end
16
30
 
17
- task :default => :spec
18
- task :test => :spec
31
+ task default: :spec
32
+ task test: :spec
33
+
34
+ desc "Run all code analysis tools"
35
+ task :analyze => [:test, :rubocop]
36
+
37
+ namespace :reports do
38
+ desc "Open test coverage in browser"
39
+ task :coverage => [:test] do
40
+ # TODO: Switch based on OS
41
+ `open coverage/index.html`
42
+ end
43
+
44
+ desc "Open RuboCop report in browser"
45
+ task :rubocop do
46
+ sh "bundle exec rake rubocop" do
47
+ # Ignore errors
48
+ end
49
+ `open coverage/rubocop.html`
50
+ end
51
+ end
data/exe/ididthis CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'ididthis'
2
+ require "ididthis"
3
3
 
4
4
  Ididthis::CommandLine.start(ARGV)
data/ididthis.gemspec CHANGED
@@ -1,29 +1,37 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'ididthis/version'
4
+ require "ididthis/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "ididthis"
8
- spec.version = Ididthis::VERSION
9
- spec.authors = ["Patrick Aikens"]
10
- spec.email = ["paikens@gmail.com"]
7
+ spec.name = "ididthis"
8
+ spec.description = "A command line utility for posting and viewing dones on iDidThis."
9
+ spec.version = Ididthis::VERSION
10
+ spec.authors = ["Patrick Aikens"]
11
+ spec.email = ["paikens@gmail.com"]
11
12
 
12
- spec.summary = %q{Command line interface to iDoneThis using the API}
13
- spec.homepage = "https://github.com/duckpuppy/ididthis.git"
14
- spec.license = "MIT"
13
+ spec.summary = "Command line interface to iDoneThis using the API"
14
+ spec.homepage = "https://github.com/duckpuppy/ididthis.git"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 1.9.3"
15
17
 
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
18
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
20
22
 
21
- spec.add_dependency "highline"
22
- spec.add_dependency "rest-client"
23
- spec.add_dependency "thor"
24
- spec.add_development_dependency "dotenv"
23
+ spec.add_dependency "highline", "~> 1.7"
24
+ spec.add_dependency "rest-client", "~> 1.8"
25
+ spec.add_dependency "thor", "~> 0.19.1"
26
+ spec.add_development_dependency "rubygems-tasks", "~> 0.2.4"
27
+ spec.add_development_dependency "dotenv", "~> 2.0"
25
28
  spec.add_development_dependency "bundler", "~> 1.10"
26
29
  spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec"
28
- spec.add_development_dependency "pry"
30
+ spec.add_development_dependency "rspec", "~> 3.3"
31
+ spec.add_development_dependency "pry", "~> 0.9"
32
+ spec.add_development_dependency "travis", "~>1.8"
33
+ spec.add_development_dependency "coveralls", "~> 0.8"
34
+ spec.add_development_dependency "rubocop", "~> 0.33"
35
+ spec.add_development_dependency "rubocop-rspec", "~> 1.3"
36
+ spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4"
29
37
  end
data/lib/ididthis/api.rb CHANGED
@@ -1,39 +1,46 @@
1
- require 'rest-client'
1
+ require "rest-client"
2
2
 
3
3
  module Ididthis
4
4
  module API
5
+ # TODO: Investigate using the ActiveResource-style calls
6
+ # Class for accessing the iDoneThis API
5
7
  class Client
6
- def validate_token(token)
7
- RestClient.get(ENDPOINTS[:noop], {:content_type => :json, :accept => :json, :Authorization => tokenize(token)}) { |response, request, result, &block|
8
+ attr_writer :token
9
+
10
+ def initialize(token)
11
+ @token = token
12
+ end
13
+
14
+ def validate_token
15
+ RestClient.get(ENDPOINTS[:noop], header_map) do |response|
8
16
  case response.code
9
17
  when 200
10
18
  return true
11
19
  else
12
20
  return false
13
21
  end
14
- }
22
+ end
15
23
  end
16
24
 
17
- def get_teams(token)
25
+ def teams
18
26
  RestClient.get(
19
- ENDPOINTS[:team],
20
- {:content_type => :json, :accept => :json, :Authorization => tokenize(token)}
27
+ ENDPOINTS[:team], header_map
21
28
  ) do |response, request, result, &block|
22
29
  case response.code
23
30
  when 200
24
31
  resp = JSON.parse(response.body, :symbolize_names => true)
25
- # TODO This is not right, need to throw an error when no teams are found
26
- resp[:ok] ? resp[:results] : []
32
+ # FIXME: This is not right, need to throw an error when no teams
33
+ # are found
34
+ resp[:ok] ? resp[:results] : []
27
35
  else
28
36
  response.return!(request, result, &block)
29
37
  end
30
38
  end
31
39
  end
32
40
 
33
- def get_team(token)
41
+ def team
34
42
  RestClient.get(
35
- Ididthis::Config[:team],
36
- {:content_type => :json, :accept => :json, :Authorization => tokenize(token)}
43
+ Ididthis::Config[:team], header_map
37
44
  ) do |response, request, result, &block|
38
45
  case response.code
39
46
  when 200
@@ -42,19 +49,13 @@ module Ididthis
42
49
  else
43
50
  response.return!(request, result, &block)
44
51
  end
45
- end
52
+ end
46
53
  end
47
54
 
48
- def post_done(token, done, team, options)
49
- payload = {:raw_text => done, :team => team}
50
- payload[:done_date] = options[:date] if options[:date]
51
- payload[:meta_data] = options[:metadata] if options[:metadata]
52
-
55
+ def post_done(done, team, options)
56
+ payload = { raw_text: done, team: team }.merge(options)
53
57
  RestClient.post(
54
- ENDPOINTS[:dones],
55
- payload.to_json,
56
- {:content_type => :json, :accept => :json, :Authorization => tokenize(token)}
57
- ) do |response, request, result, &block|
58
+ ENDPOINTS[:dones], payload.to_json, header_map) do |response|
58
59
  case response.code
59
60
  when 201
60
61
  puts "Posted your done!"
@@ -64,10 +65,10 @@ module Ididthis
64
65
  end
65
66
  end
66
67
 
67
- def get_dones(token, options)
68
+ def dones(options)
68
69
  RestClient.get(
69
70
  ENDPOINTS[:dones],
70
- {:content_type => :json, :accept => :json, :Authorization => tokenize(token), :params => options},
71
+ header_map.merge(:params => options)
71
72
  ) do |response, request, result, &block|
72
73
  case response.code
73
74
  when 200
@@ -79,11 +80,13 @@ module Ididthis
79
80
  end
80
81
  end
81
82
 
82
- private
83
- def tokenize(token)
84
- "Token #{token}"
83
+ def header_map
84
+ {
85
+ :content_type => :json,
86
+ :accept => :json,
87
+ :Authorization => "Token #{@token}"
88
+ }
85
89
  end
86
90
  end
87
91
  end
88
92
  end
89
-
data/lib/ididthis/cli.rb CHANGED
@@ -1,9 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
- require 'thor'
3
- require 'ididthis'
2
+ require "thor"
3
+ require "ididthis"
4
4
 
5
5
  module Ididthis
6
+ # Class providing the command line interface processing
6
7
  class CommandLine < Thor
8
+ class_option :color,
9
+ :type => :boolean,
10
+ :default => true,
11
+ :desc => "Colorize output"
12
+
7
13
  desc "configure", "(Re)configure the client."
8
14
  long_desc <<-CONFIGURE
9
15
 
@@ -19,50 +25,124 @@ module Ididthis
19
25
  desc "post [OPTIONS] DONE", "Post a new done"
20
26
  long_desc <<-POST
21
27
 
22
- `post` will post a new done or goal to iDoneThis.
23
- To tag the done, simply include the tags in the done using #hashtags. If any tag doesn't already exist, it will be created.
28
+ `post` will post a new done or goal to iDoneThis.
29
+ To tag the done, simply include the tags in the done using #hashtags.
30
+ If any tag doesn"t already exist, it will be created.
24
31
  POST
25
- option :date, :aliases => "-d", :type => :string, :banner => "YYYY-MM-DD", :desc => "The date for this done."
26
- option :team, :aliases => "-t", :type => :string, :default => Ididthis::Config[:team], :banner => "SHORT_NAME", :desc => "The team to post to."
27
- option :goal, :aliases => "-g", :type => :boolean, :desc => "Post a goal rather than a done"
32
+ option :date,
33
+ :aliases => "-d",
34
+ :type => :string,
35
+ :banner => "YYYY-MM-DD",
36
+ :desc => "The date for this done."
37
+ option :team,
38
+ :aliases => "-t",
39
+ :type => :string,
40
+ :default => Ididthis::Config[:team],
41
+ :banner => "SHORT_NAME",
42
+ :desc => "The team to post to."
43
+ option :goal,
44
+ :aliases => "-g",
45
+ :type => :boolean,
46
+ :desc => "Post a goal rather than a done"
28
47
  def post(done)
29
- c = Ididthis::API::Client.new
30
- c.post_done(Ididthis::Config[:token], options[:goal] ? "[] #{done}" : done, options[:team], options)
48
+ post_options = {}
49
+ post_options[:done_date] = options[:date] if options[:date]
50
+ post_options[:meta_data] = options[:metadata] if options[:metadata]
51
+ c = Ididthis::API::Client.new(Ididthis::Config[:token])
52
+ c.post_done(
53
+ options[:goal] ? "[] #{done}" : done, options[:team],
54
+ post_options
55
+ )
31
56
  end
32
57
 
33
58
  desc "dones [OPTIONS]", "List dones"
34
59
  long_desc <<-DONES
35
60
  DONES
36
- option :team, :aliases => "-t", :type => :string, :default => Ididthis::Config[:team], :banner => "SHORT_NAME", :desc => "Show only dones from TEAM"
37
- option :owner, :aliases => "-o", :type => :string, :banner => "USERNAME", :desc => "Show only dones belonging to USERNAME"
38
- option :date, :aliases => "-d", :type => :string, :banner => "YYYY-MM-DD, yesterday, or today", :desc => "Show only dones from DATE"
39
- option :after, :type => :string, :banner => "YYYY-MM-DD", :desc => "Show only dones on or after DATE"
40
- option :before, :type => :string, :banner => "YYYY-MM-DD", :desc => "Show only dones on or before DATE"
41
- option :tags, :type => :string, :banner => "TAG...", :desc => "Show only dones tagged with TAGs. Comma separated list."
42
- option :order, :type => :string, :banner => "ORDER", :enum => ['created', 'done_date', '-created', '-done_date'], :desc => "Order results by ORDER."
43
- option :limit, :aliases => "-l", :type => :numeric, :banner => "LIMIT", :desc => "Limit the number of results returned. Maximum of 100."
44
- option :page, :aliases => "-p", :type => :numeric, :banner => "PAGE", :desc => "Used in conjunction with --limit to get more results."
61
+ option :team,
62
+ :aliases => "-t",
63
+ :type => :string,
64
+ :default => Ididthis::Config[:team],
65
+ :banner => "SHORT_NAME",
66
+ :desc => "Show only dones from TEAM"
67
+ option :owner,
68
+ :aliases => "-o",
69
+ :type => :string,
70
+ :banner => "USERNAME",
71
+ :desc => "Show only dones belonging to USERNAME"
72
+ option :date,
73
+ :aliases => "-d",
74
+ :type => :string,
75
+ :banner => "YYYY-MM-DD, yesterday, or today",
76
+ :desc => "Show only dones from DATE"
77
+ option :after,
78
+ :type => :string,
79
+ :banner => "YYYY-MM-DD",
80
+ :desc => "Show only dones on or after DATE"
81
+ option :before,
82
+ :type => :string,
83
+ :banner => "YYYY-MM-DD",
84
+ :desc => "Show only dones on or before DATE"
85
+ option :tags,
86
+ :type => :string,
87
+ :banner => "TAG...",
88
+ :desc => "Show only dones tagged with TAGs. Comma separated list."
89
+ option :order,
90
+ :type => :string,
91
+ :banner => "ORDER",
92
+ :enum => ["created", "done_date", "-created", "-done_date"],
93
+ :desc => "Order results by ORDER."
94
+ option :limit,
95
+ :aliases => "-l",
96
+ :type => :numeric,
97
+ :banner => "LIMIT",
98
+ :desc => "Limit the number of results returned. Maximum of 100."
99
+ option :page,
100
+ :aliases => "-p",
101
+ :type => :numeric,
102
+ :banner => "PAGE",
103
+ :desc => "Used in conjunction with --limit to get more results."
45
104
  def dones
46
- query_mappings = { date: "done_date", after: "done_date_after", before: "done_date_before", order: "order_by", limit: "page_size" }
105
+ query_mappings = {
106
+ date: "done_date",
107
+ after: "done_date_after",
108
+ before: "done_date_before",
109
+ order: "order_by",
110
+ limit: "page_size" }
47
111
  params = Hash[options.map { |k, v| [query_mappings[k] || k, v] }]
48
- c = Ididthis::API::Client.new
49
- dones = c.get_dones(Ididthis::Config[:token], params)
50
- dones.each do |done|
51
- puts "#{yellow(done[:done_date])} #{green(done[:owner])}\t#{done[:raw_text]}".gsub(/(#\b[^\s]+\b)/, "\e[31m\\1\e[0m")
52
- end
112
+ c = Ididthis::API::Client.new(Ididthis::Config[:token])
113
+ print_dones(c.dones(params))
53
114
  end
54
115
 
55
116
  desc "teams", "Update your team list from the server."
56
117
  def teams
57
118
  end
58
119
 
59
- private
60
- def colorize(text, color_code)
61
- "#{color_code}#{text}\e[0m"
120
+ private
121
+
122
+ # TODO: Break output to separate formatter classes
123
+ def print_dones(dones)
124
+ dones.each do |done|
125
+ print format_column(done[:done_date], COLORS[:yellow])
126
+ print format_column(done[:owner], COLORS[:green], " ")
127
+ puts format_column(highlight_tags(done[:raw_text]), "", "\t")
128
+ end
129
+ end
130
+
131
+ def highlight_tags(done_text)
132
+ options[:color] ? done_text.gsub(/(#\b[^\s]+\b)/, "\e[31m\\1\e[0m") : done_text
133
+ end
134
+
135
+ def format_column(text, color_code, prefix = "", suffix = "")
136
+ column_text = "#{prefix}#{color_code if options[:color] && color_code}"
137
+ column_text += text
138
+ column_text += "#{COLORS[:reset] if options[:color] && color_code}#{suffix}"
62
139
  end
63
140
 
64
- def red(text); colorize(text, "\e[31m"); end
65
- def green(text); colorize(text, "\e[32m"); end
66
- def yellow(text); colorize(text, "\e[33m"); end
141
+ COLORS = {
142
+ reset: "\e[0m",
143
+ red: "\e[31m",
144
+ green: "\e[32m",
145
+ yellow: "\e[33m"
146
+ }
67
147
  end
68
148
  end
@@ -1,54 +1,40 @@
1
- require 'highline/import'
2
- require 'yaml'
1
+ require "highline/import"
2
+ require "yaml"
3
3
 
4
4
  module Ididthis
5
+ # Handles creating and retrieving configuration
5
6
  module Config
6
- extend self
7
- PATH = ENV['IDIDTHIS_CONFIG_FILE'] || File.join(ENV['HOME'], '.ididthis.yml')
7
+ module_function
8
+
9
+ PATH = ENV["IDIDTHIS_CONFIG"] || File.join(ENV["HOME"], ".ididthis.yml")
8
10
 
9
11
  def defaults
10
12
  {
11
13
  teams: {},
12
- team: '',
13
- token: ''
14
+ team: "",
15
+ token: ""
14
16
  }
15
17
  end
16
18
 
17
19
  def [](key)
18
20
  configs[key]
19
21
  rescue => e
20
- warn 'invalid config file'
22
+ warn "invalid config file"
21
23
  warn e.message
22
24
  defaults[key]
23
25
  end
24
26
 
25
27
  def configure!
26
- current = configs
27
- client = Ididthis::API::Client.new
28
-
29
- token = ask("iDoneThis API Token: ") do |token|
30
- token.default = current[:token]
31
- token.whitespace = :strip
32
- token.responses[:not_valid] = "The token you have entered cannot be validated. Please try again."
33
- token.responses[:ask_on_error] = :question
34
- token.validate = lambda do |t|
35
- client.validate_token(t)
36
- end
37
- end
28
+ token = ask_token
38
29
 
39
- teams = client.get_teams(token)
40
- team = choose do |menu|
41
- menu.prompt = "Which team will you be posting dones to? "
42
- menu.select_by = :index_or_name
43
- teams.each do |team|
44
- menu.choice(team[:name]) {
45
- team
46
- }
47
- end
48
- end
30
+ client = Ididthis::API::Client.new(token)
31
+ teams = client.teams
32
+ team = ask_team(teams)
49
33
 
50
- File.open(PATH, 'w') do |f|
51
- f << { :token => token, :team => team[:short_name], :teams => teams }.to_yaml
34
+ File.open(PATH, "w") do |f|
35
+ f << { :token => token,
36
+ :team => team[:short_name],
37
+ :teams => teams }.to_yaml
52
38
  end
53
39
  end
54
40
 
@@ -59,5 +45,28 @@ module Ididthis
59
45
  defaults
60
46
  end
61
47
  end
48
+
49
+ def ask_token
50
+ ask("iDoneThis API Token: ") do |tkn|
51
+ tkn.default = configs[:token]
52
+ tkn.whitespace = :strip
53
+ tkn.responses[:not_valid] = "The token you have entered cannot be validated. Please try again."
54
+ tkn.responses[:ask_on_error] = :question
55
+ tkn.validate = lambda do |t|
56
+ client = Ididthis::API::Client.new(t)
57
+ client.validate_token
58
+ end
59
+ end
60
+ end
61
+
62
+ def ask_team(teams)
63
+ choose do |menu|
64
+ menu.prompt = "Which team will you be posting dones to? "
65
+ menu.select_by = :index_or_name
66
+ teams.each do |t|
67
+ menu.choice(t[:name]) { t }
68
+ end
69
+ end
70
+ end
62
71
  end
63
72
  end
@@ -1,3 +1,3 @@
1
1
  module Ididthis
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/ididthis.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  begin
3
- require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
3
+ require "Win32/Console/ANSI" if RUBY_PLATFORM =~ /win32/
4
4
  rescue LoadError
5
5
  raise "You must gem install win32console to use color on Windows"
6
6
  end
@@ -12,6 +12,7 @@ require "ididthis/cli"
12
12
  require "highline/import"
13
13
  require "json"
14
14
 
15
+ # Main module
15
16
  module Ididthis
16
17
  CONFIG_FILE = File.expand_path("~/.ididthis")
17
18
  API_VERSION = "0.1"
metadata CHANGED
@@ -1,71 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ididthis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Aikens
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-04 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rest-client
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.19.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.19.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubygems-tasks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '0'
68
+ version: 0.2.4
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: dotenv
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ">="
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0'
75
+ version: '2.0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ">="
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '0'
82
+ version: '2.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -98,31 +112,101 @@ dependencies:
98
112
  name: rspec
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ">="
115
+ - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '0'
117
+ version: '3.3'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ">="
122
+ - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '0'
124
+ version: '3.3'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - ">="
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.9'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.9'
139
+ - !ruby/object:Gem::Dependency
140
+ name: travis
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
116
144
  - !ruby/object:Gem::Version
117
- version: '0'
145
+ version: '1.8'
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
149
  requirements:
122
- - - ">="
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.8'
153
+ - !ruby/object:Gem::Dependency
154
+ name: coveralls
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
123
158
  - !ruby/object:Gem::Version
124
- version: '0'
125
- description:
159
+ version: '0.8'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.8'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.33'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.33'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop-rspec
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '1.3'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '1.3'
195
+ - !ruby/object:Gem::Dependency
196
+ name: codeclimate-test-reporter
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '0.4'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '0.4'
209
+ description: A command line utility for posting and viewing dones on iDidThis.
126
210
  email:
127
211
  - paikens@gmail.com
128
212
  executables:
@@ -130,9 +214,14 @@ executables:
130
214
  extensions: []
131
215
  extra_rdoc_files: []
132
216
  files:
217
+ - ".codeclimate.yml"
218
+ - ".document"
133
219
  - ".env"
134
220
  - ".gitignore"
135
221
  - ".rspec"
222
+ - ".rubocop.yml"
223
+ - ".rubocop_todo.yml"
224
+ - ".simplecov"
136
225
  - ".travis.yml"
137
226
  - CODE_OF_CONDUCT.md
138
227
  - Gemfile
@@ -144,7 +233,6 @@ files:
144
233
  - lib/ididthis.rb
145
234
  - lib/ididthis/api.rb
146
235
  - lib/ididthis/cli.rb
147
- - lib/ididthis/cli/done.rb
148
236
  - lib/ididthis/config.rb
149
237
  - lib/ididthis/version.rb
150
238
  homepage: https://github.com/duckpuppy/ididthis.git
@@ -159,7 +247,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
247
  requirements:
160
248
  - - ">="
161
249
  - !ruby/object:Gem::Version
162
- version: '0'
250
+ version: 1.9.3
163
251
  required_rubygems_version: !ruby/object:Gem::Requirement
164
252
  requirements:
165
253
  - - ">="
@@ -1,12 +0,0 @@
1
- module Ididthis
2
- module CLI
3
- class Done < Thor
4
- def post
5
- end
6
-
7
- def log
8
- end
9
- end
10
- end
11
- end
12
-