wip-cli 1.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f6769807e30279443f27ef2ebdee3380ba941aade21d5787338ea28e0eb81c2d
4
+ data.tar.gz: 61e38788589c5ca17f83c86d725a52687f1b5793cc1647f291577c4bfcdea2e3
5
+ SHA512:
6
+ metadata.gz: 8e6d780083b9b5da3fa9c4a3865c4ddcb7a9b1cd0c2466e19dfbe87719dbd1403d419ad72ef413ef2a8765e00e9e465039cc116fc25c27c59a093ca58f3749fd
7
+ data.tar.gz: 6e702061b7662cc33d7e4bd54605659666f974e89e002e94df889725bbb392b8cb2ec0f7f2529b806a2e75f5f2904349b2252f6d664e36a95ae96d8c131d8d81
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ .byebug_history
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ .ruby-version
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.3
6
+ before_install: gem install bundler -v 2.1.1
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [1.1.0] - 2020-11-11
6
+
7
+ - Renamed command from wipco to wip
8
+ - Renamed gem from wipco to wip-cli
9
+
10
+ ## [1.0.0] - 2020-11-10
11
+
12
+ ### Added
13
+
14
+ - Everything
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wip-cli (1.1.0)
5
+ thor (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ byebug (11.1.3)
11
+ diff-lcs (1.4.4)
12
+ rake (13.0.1)
13
+ rspec (3.10.0)
14
+ rspec-core (~> 3.10.0)
15
+ rspec-expectations (~> 3.10.0)
16
+ rspec-mocks (~> 3.10.0)
17
+ rspec-core (3.10.0)
18
+ rspec-support (~> 3.10.0)
19
+ rspec-expectations (3.10.0)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.10.0)
22
+ rspec-mocks (3.10.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.10.0)
25
+ rspec-support (3.10.0)
26
+ thor (1.0.1)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ byebug (~> 11.0)
33
+ rake (~> 13.0)
34
+ rspec (~> 3.9)
35
+ wip-cli!
36
+
37
+ BUNDLED WITH
38
+ 2.1.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Arnaud Joubay
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.
@@ -0,0 +1,44 @@
1
+ # Wip-CLI
2
+
3
+ A ruby CLI to interact with wip.co from your terminal.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'wip-cli'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install wip-cli
20
+
21
+ ## Usage
22
+
23
+ Define an ENV var named `WIP_API_KEY` with your [api key](https://wip.co/api).
24
+
25
+ `wip todo "Grab a cup of ☕️"`
26
+
27
+ `wip complete 123`
28
+
29
+ `wip done "Installed wip-cli gem"`
30
+
31
+ ## Development
32
+
33
+ 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.
34
+
35
+ 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).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sowenjub/wip-cli.
40
+
41
+
42
+ ## License
43
+
44
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "byebug"
5
+ require "wip"
6
+ require "wip/todo"
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+
11
+ # (If you use this, don't forget to add pry to your Gemfile!)
12
+ # require "pry"
13
+ # Pry.start
14
+
15
+ require "irb"
16
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/wip ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "wip"
4
+ require "wip/cli"
5
+
6
+ Wip::CLI.start(ARGV)
@@ -0,0 +1,6 @@
1
+ require "wip/version"
2
+
3
+ module Wip
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,7 @@
1
+ require "wip"
2
+
3
+ class Wip::Auth
4
+ def self.api_key
5
+ ENV['WIP_API_KEY']
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ require "date"
2
+ require "thor"
3
+ require "wip"
4
+ require "wip/todo"
5
+
6
+ class Wip::CLI < Thor
7
+ class_option :verbose, :type => :boolean, :aliases => "-v"
8
+
9
+ desc "complete [ID]", "Mark a todo as completed"
10
+ def complete(todo_id)
11
+ todo = Wip::Todo.complete(todo_id)
12
+ puts todo.description
13
+ end
14
+
15
+ desc "done [BODY]", "Create a new todo and immediately mark it as completed"
16
+ def done(body)
17
+ todo = Wip::Todo.create(body: body, completed_at: DateTime.now)
18
+ puts todo.description
19
+ end
20
+
21
+ desc "todo [BODY]", "Create a new todo"
22
+ def todo(body)
23
+ todo = Wip::Todo.create(body: body)
24
+ puts todo.description
25
+ end
26
+ end
@@ -0,0 +1,41 @@
1
+ require "net/http"
2
+ require "uri"
3
+ require "json"
4
+ require "wip"
5
+ require "wip/auth"
6
+ require "byebug"
7
+ class Wip::Client
8
+ API_ENDPOINT = "https://wip.co/graphql"
9
+
10
+ attr_reader :api_key, :json, :response
11
+
12
+ def initialize(api_key: Wip::Auth.api_key)
13
+ @api_key = api_key
14
+ end
15
+
16
+ def request(query)
17
+ uri = URI.parse(API_ENDPOINT)
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+ http.use_ssl = true
20
+ request = Net::HTTP::Post.new(uri.request_uri, header)
21
+ request.body = { query: query }.to_json
22
+ @response = http.request(request)
23
+
24
+ @json = JSON.parse(@response.body)
25
+ if @json.has_key? "errors"
26
+ raise @json["errors"].first["message"]
27
+ end
28
+ @json
29
+ end
30
+
31
+ def header
32
+ {
33
+ "Authorization": "bearer #{@api_key}",
34
+ "Content-Type": "application/json"
35
+ }
36
+ end
37
+
38
+ def data(key)
39
+ json["data"][key] if json
40
+ end
41
+ end
@@ -0,0 +1,109 @@
1
+ require "date"
2
+ require "wip"
3
+ require "wip/client"
4
+
5
+ class Wip::Todo
6
+ attr_accessor :id, :body, :completed_at
7
+ attr_reader :client
8
+
9
+ def self.find(id)
10
+ client = Wip::Client.new
11
+ find_query = %{
12
+ {
13
+ todo(id: \"#{id}\") {
14
+ id
15
+ body
16
+ completed_at
17
+ }
18
+ }
19
+ }
20
+ client.request find_query
21
+ parse client.data("todo")
22
+ end
23
+
24
+ def self.create(body:, completed_at: nil)
25
+ new(body: body, completed_at: completed_at).tap &:save
26
+ end
27
+
28
+ def self.parse(data)
29
+ todo_id = data["id"].to_i
30
+ completed_at = DateTime.parse(data["completed_at"]) unless data["completed_at"].nil?
31
+ new id: todo_id, body: data["body"], completed_at: completed_at
32
+ end
33
+
34
+ def self.complete(id)
35
+ todo = find id
36
+ todo.complete
37
+ todo
38
+ end
39
+
40
+
41
+ def initialize(id: nil, body: nil, completed_at: nil)
42
+ @id = id
43
+ @body = body
44
+ @completed_at = completed_at
45
+ end
46
+
47
+
48
+ def client
49
+ @client ||= Wip::Client.new
50
+ end
51
+
52
+ def description
53
+ [icon, body, "##{id}"].join " "
54
+ end
55
+
56
+ def done?
57
+ !completed_at.nil?
58
+ end
59
+
60
+ def icon
61
+ done? ? "✅" : "🚧"
62
+ end
63
+
64
+ def complete
65
+ client.request complete_query
66
+ client.data("completeTodo").tap do |params|
67
+ @completed_at = DateTime.parse params["completed_at"]
68
+ end
69
+ end
70
+
71
+ def save
72
+ client.request create_query
73
+ client.data("createTodo").tap do |params|
74
+ @id = params["id"]&.to_i
75
+ end
76
+ end
77
+
78
+ private
79
+ def create_query
80
+ %{
81
+ mutation createTodo {
82
+ createTodo(input: {#{to_params}}) {
83
+ id
84
+ body
85
+ completed_at
86
+ }
87
+ }
88
+ }
89
+ end
90
+
91
+ def complete_query
92
+ %{
93
+ mutation completeTodo {
94
+ completeTodo(id: #{id}) {
95
+ id
96
+ body
97
+ completed_at
98
+ }
99
+ }
100
+ }
101
+ end
102
+
103
+ def to_params
104
+ [:body, :completed_at].collect do |key|
105
+ value = send(key).nil? ? "null" : "\"#{send(key)}\""
106
+ [key, value].join(": ")
107
+ end.join(", ")
108
+ end
109
+ end
@@ -0,0 +1,3 @@
1
+ module Wip
2
+ VERSION = "1.1.0"
3
+ end
@@ -0,0 +1,32 @@
1
+ require_relative 'lib/wip/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "wip-cli"
5
+ spec.version = Wip::VERSION
6
+ spec.authors = ["Arnaud Joubay"]
7
+
8
+ spec.summary = %q{A CLI for wip.co}
9
+ spec.description = %q{A simple gem to manage wip.co todos from the command line.}
10
+ spec.homepage = "https://github.com/sowenjub/wip-cli"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "https://github.com/sowenjub/wip-cli"
16
+ spec.metadata["changelog_uri"] = "https://github.com/sowenjub/wip-cli/CHANGELOG.md"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency 'byebug', "~> 11.0"
28
+ spec.add_development_dependency 'rake', "~> 13.0"
29
+ spec.add_development_dependency 'rspec', "~> 3.9"
30
+
31
+ spec.add_runtime_dependency "thor", "~> 1.0"
32
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wip-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Arnaud Joubay
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: byebug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '11.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '11.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ description: A simple gem to manage wip.co todos from the command line.
70
+ email:
71
+ executables:
72
+ - wip
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CHANGELOG.md
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - exe/wip
88
+ - lib/wip.rb
89
+ - lib/wip/auth.rb
90
+ - lib/wip/cli.rb
91
+ - lib/wip/client.rb
92
+ - lib/wip/todo.rb
93
+ - lib/wip/version.rb
94
+ - wip-cli.gemspec
95
+ homepage: https://github.com/sowenjub/wip-cli
96
+ licenses:
97
+ - MIT
98
+ metadata:
99
+ homepage_uri: https://github.com/sowenjub/wip-cli
100
+ source_code_uri: https://github.com/sowenjub/wip-cli
101
+ changelog_uri: https://github.com/sowenjub/wip-cli/CHANGELOG.md
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 2.3.0
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 3.1.4
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: A CLI for wip.co
121
+ test_files: []