wo 0.0.1
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 +7 -0
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/.wo +2 -0
- data/Gemfile +13 -0
- data/README.md +53 -0
- data/bin/wo +55 -0
- data/lib/wo.rb +13 -0
- data/lib/wo/client.rb +28 -0
- data/lib/wo/configure.rb +19 -0
- data/lib/wo/hook.rb +19 -0
- data/lib/wo/hook/zsh.rb +34 -0
- data/lib/wo/loader.rb +26 -0
- data/lib/wo/response.rb +14 -0
- data/lib/wo/response/format/timeline.rb +58 -0
- data/lib/wo/version.rb +6 -0
- data/spec/spec_helper.rb +11 -0
- data/wo.gemspec +20 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0231e2df6888b01ab099ea0209ae957033e22fa3
|
4
|
+
data.tar.gz: 5c1d24eef720dee589091603cdf3df32d95959e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 98d58568e99218faf9c5a36aaf4c724ba992fc655889ff4c0aff9eaf59b5259acf0cc31ff37d62ecea25f7417402e3a8f7acb403f527c372acf2c45530bfd9b4
|
7
|
+
data.tar.gz: ae51e8edead3291519c8a0dd211f55d173ee00ef441102c231a8a032ff95961dd2c7051c8a60f32cfadac34802f902473922f8e6d8a4ad991856595aa0e1d8e7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/.wo
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# wo
|
2
|
+
|
3
|
+
CLI and Ruby client for [wo server](https://github.com/wo-app/wo-server)
|
4
|
+
|
5
|
+
Instration
|
6
|
+
----------
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'wo'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install wo
|
19
|
+
|
20
|
+
Also, copy following
|
21
|
+
|
22
|
+
#### case of zsh
|
23
|
+
|
24
|
+
```
|
25
|
+
eval "$(wo hook zsh)"
|
26
|
+
```
|
27
|
+
|
28
|
+
#### case of bash
|
29
|
+
|
30
|
+
TODO
|
31
|
+
|
32
|
+
Usage
|
33
|
+
-----
|
34
|
+
|
35
|
+
```sh
|
36
|
+
# Create a .wo file in current repository
|
37
|
+
wo init
|
38
|
+
|
39
|
+
# Print doings in organization
|
40
|
+
wo doings
|
41
|
+
```
|
42
|
+
|
43
|
+
Screen shot
|
44
|
+
-----------
|
45
|
+
|
46
|
+

|
47
|
+
|
48
|
+
Test
|
49
|
+
----
|
50
|
+
|
51
|
+
```
|
52
|
+
bundle exec rspec
|
53
|
+
```
|
data/bin/wo
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "wo"
|
3
|
+
|
4
|
+
module WO
|
5
|
+
class Command < Thor
|
6
|
+
desc "init", "Initialize configure file"
|
7
|
+
def init(url = nil)
|
8
|
+
url = url || WO::Client::API_URL
|
9
|
+
token = Client.new(url: url).create_organization.to_json["organization"]["token"]
|
10
|
+
|
11
|
+
File.open(loader.file_full_path, "w") do |f|
|
12
|
+
f.puts "url: #{url}"
|
13
|
+
f.puts "token: #{token}"
|
14
|
+
end
|
15
|
+
|
16
|
+
puts "Created #{loader.file_full_path}"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "hook", "Print hook sh"
|
20
|
+
def hook(sh)
|
21
|
+
puts Hook.new(sh).hook
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "doing", "Update working on"
|
25
|
+
def doing(repo, branch, user_name)
|
26
|
+
Client.new(url: url).create_doing(
|
27
|
+
token: token,
|
28
|
+
user_name: user_name,
|
29
|
+
repo: repo,
|
30
|
+
branch: branch,
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "doings", "Show working on in organization"
|
35
|
+
def doings
|
36
|
+
puts Client.new(url: url).doings(token: token).to_timeline
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def url
|
42
|
+
loader.to_h[:url]
|
43
|
+
end
|
44
|
+
|
45
|
+
def token
|
46
|
+
loader.to_h[:token]
|
47
|
+
end
|
48
|
+
|
49
|
+
def loader
|
50
|
+
@loader ||= Loader.new(ENV["WO_FILE_PATH"])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
WO::Command.start(ARGV)
|
data/lib/wo.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
require 'yaml'
|
4
|
+
require 'thor'
|
5
|
+
|
6
|
+
require 'wo/client'
|
7
|
+
require 'wo/configure'
|
8
|
+
require 'wo/response/format/timeline'
|
9
|
+
require 'wo/response'
|
10
|
+
require 'wo/loader'
|
11
|
+
require 'wo/hook'
|
12
|
+
require 'wo/hook/zsh'
|
13
|
+
require 'wo/version'
|
data/lib/wo/client.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module WO
|
2
|
+
class Client
|
3
|
+
API_URL = "http://wo-app.herokuapp.com"
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
@api_url = options[:url] ? options[:url] : API_URL
|
7
|
+
end
|
8
|
+
|
9
|
+
def doings(options = {})
|
10
|
+
request(:get, "#{@api_url}/users", Configure.new(options).to_h)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_doing(options = {})
|
14
|
+
request(:post, "#{@api_url}/doings", Configure.new(options).to_h)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_organization
|
18
|
+
request(:post, "#{@api_url}/organizations")
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def request(method, path, options = {})
|
24
|
+
faraday_response = Faraday.send(method, *[path, options])
|
25
|
+
Response.new(faraday_response)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/wo/configure.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module WO
|
2
|
+
class Configure
|
3
|
+
def initialize(options = {})
|
4
|
+
[:token, :repo, :branch, :user_name].each do |key|
|
5
|
+
next unless value = options[key]
|
6
|
+
instance_variable_set(:"@#{key}", value)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_h
|
11
|
+
{
|
12
|
+
"organization[token]": @token,
|
13
|
+
"doing[repo]": @repo,
|
14
|
+
"doing[branch]": @branch,
|
15
|
+
"user[name]": @user_name,
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/wo/hook.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module WO
|
2
|
+
class Hook
|
3
|
+
attr_reader :sh
|
4
|
+
|
5
|
+
def initialize(sh)
|
6
|
+
@sh = sh
|
7
|
+
end
|
8
|
+
|
9
|
+
def hook
|
10
|
+
constantize.new.hook
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def constantize
|
16
|
+
Kernel.const_get("WO").const_get("Hook").const_get(@sh.capitalize)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/wo/hook/zsh.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module WO
|
2
|
+
class Hook
|
3
|
+
class Zsh
|
4
|
+
def hook
|
5
|
+
%(
|
6
|
+
_wo_hook() {
|
7
|
+
repo_path=`git rev-parse --show-toplevel 2>&1`
|
8
|
+
|
9
|
+
if [[ "$?" == 0 ]] ; then
|
10
|
+
token=`cat ${repo_path}/.wo 2>&1`
|
11
|
+
|
12
|
+
if [[ "$?" == 0 ]] ; then
|
13
|
+
repo=`basename ${repo_path}`
|
14
|
+
branch=`git rev-parse --abbrev-ref HEAD`
|
15
|
+
user_name=`git config user.name`
|
16
|
+
|
17
|
+
wo doing ${repo} ${branch} ${user_name}
|
18
|
+
fi
|
19
|
+
fi
|
20
|
+
}
|
21
|
+
|
22
|
+
_wo_hook_background() {
|
23
|
+
(_wo_hook &)
|
24
|
+
}
|
25
|
+
|
26
|
+
typeset -ag precmd_functions
|
27
|
+
if [[ -z $precmd_functions[(r)_wo_hook_background] ]]; then
|
28
|
+
precmd_functions+=_wo_hook_background;
|
29
|
+
fi
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/wo/loader.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module WO
|
2
|
+
class Loader
|
3
|
+
WO_FILE_NAME = ".wo"
|
4
|
+
|
5
|
+
attr_reader :file_path, :file_full_path
|
6
|
+
|
7
|
+
def initialize(wo_file_path = nil)
|
8
|
+
@file_path = wo_file_path || repo_path
|
9
|
+
@file_full_path = "#{@file_path}/#{WO_FILE_NAME}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def config
|
13
|
+
@config ||= YAML.load_file(@file_full_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_h
|
17
|
+
{ url: config["url"], token: config["token"] }
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def repo_path
|
23
|
+
`git rev-parse --show-toplevel`.chomp
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/wo/response.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module WO
|
2
|
+
class Response
|
3
|
+
module Format
|
4
|
+
module Timeline
|
5
|
+
# TODO: refactor
|
6
|
+
# TODO: handle colorize
|
7
|
+
|
8
|
+
def to_timeline
|
9
|
+
to_json["users"].map do |user|
|
10
|
+
user_name = user["name"]
|
11
|
+
repo_branch = "#{user["recent_repo"]}/#{user["recent_branch"]}"
|
12
|
+
time = user["time_ago"]
|
13
|
+
|
14
|
+
sprintf(format, user_name, repo_branch, time)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def format
|
21
|
+
"#{bold}#{green}%#{max_length_user_name}s: #{white}%#{max_length_branch}s #{black}%#{max_length_time_ago}s#{clear}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def max_length_user_name
|
25
|
+
@max_length_user_name ||= to_json["users"].map { |user| user["name"].length }.max
|
26
|
+
end
|
27
|
+
|
28
|
+
def max_length_branch
|
29
|
+
@max_length_branch ||= to_json["users"].map { |user| "#{user["recent_repo"]}/#{user["recent_branch"]}".length }.max
|
30
|
+
end
|
31
|
+
|
32
|
+
def max_length_time_ago
|
33
|
+
@max_length_time_ago ||= to_json["users"].map { |user| "#{user["time_ago"]}".length }.max
|
34
|
+
end
|
35
|
+
|
36
|
+
def bold
|
37
|
+
"\e[1m"
|
38
|
+
end
|
39
|
+
|
40
|
+
def green
|
41
|
+
"\e[32m"
|
42
|
+
end
|
43
|
+
|
44
|
+
def white
|
45
|
+
"\e[37m"
|
46
|
+
end
|
47
|
+
|
48
|
+
def black
|
49
|
+
"\e[30m"
|
50
|
+
end
|
51
|
+
|
52
|
+
def clear
|
53
|
+
"\e[0m"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/wo/version.rb
ADDED
data/spec/spec_helper.rb
ADDED
data/wo.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'wo/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'wo'
|
6
|
+
s.version = WO::VERSION
|
7
|
+
s.authors = ['Masahiro Saito']
|
8
|
+
s.email = ['camelmasa@gmail.com']
|
9
|
+
s.summary = 'Ruby client for wo server'
|
10
|
+
s.description = 'Ruby client for wo server'
|
11
|
+
s.homepage = 'https://github.com/wo-app/wo'
|
12
|
+
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split($/)
|
15
|
+
s.executables = %w(wo)
|
16
|
+
s.require_paths = ['lib']
|
17
|
+
|
18
|
+
s.add_runtime_dependency 'faraday', '~> 0.9.0'
|
19
|
+
s.add_runtime_dependency 'thor', '~> 0.19.1'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masahiro Saito
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.19.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.19.1
|
41
|
+
description: Ruby client for wo server
|
42
|
+
email:
|
43
|
+
- camelmasa@gmail.com
|
44
|
+
executables:
|
45
|
+
- wo
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rspec"
|
51
|
+
- ".travis.yml"
|
52
|
+
- ".wo"
|
53
|
+
- Gemfile
|
54
|
+
- README.md
|
55
|
+
- bin/wo
|
56
|
+
- lib/wo.rb
|
57
|
+
- lib/wo/client.rb
|
58
|
+
- lib/wo/configure.rb
|
59
|
+
- lib/wo/hook.rb
|
60
|
+
- lib/wo/hook/zsh.rb
|
61
|
+
- lib/wo/loader.rb
|
62
|
+
- lib/wo/response.rb
|
63
|
+
- lib/wo/response/format/timeline.rb
|
64
|
+
- lib/wo/version.rb
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
- wo.gemspec
|
67
|
+
homepage: https://github.com/wo-app/wo
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.4.5
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Ruby client for wo server
|
91
|
+
test_files: []
|