wo 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b92a452b772a87a0d21c1a15a9aa0ed62ed0e559
4
- data.tar.gz: db02358fec1f64f5f1e3db29e25f498962d04c92
3
+ metadata.gz: 9b326d8f66bd632e93e302c4fefde6a01b4bd14d
4
+ data.tar.gz: 0813e65ec3072f0db08fab711cda12f2e96ab645
5
5
  SHA512:
6
- metadata.gz: 02a861504ad00e29d7d56b6277b25b3f2ad6695bf0d2e8870727625326aeaf8c3dccd9ff8331be4d6058c9ea3f14456a8e04ec65fbf8f40f4fa1337cedd03f77
7
- data.tar.gz: e45a843a6dd036b10ba432de665c7642b8392a86d4b93e6454ccb4934c325c1b5bb0e82fd6a4fa642635ab8f4332510a62008880e34392554d657f734fa416e4
6
+ metadata.gz: 1d88122203da9ec79b815e1c029a7cd5900943c1ad53887bb8454db35dfbadd87d904a2e8ec394e7d3c38facb987b6d76ae99081bd5097e77bff014ec89d016d
7
+ data.tar.gz: 80b60796291f2046e48716cbd53274904ce05f48bc1dcf1b98f881f8dededd95c8d7667bbad363b6477f9ec354cb024de8bcfa8d1582101d58444cd447dc29d8
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # wo
2
2
 
3
+ [![Build Status](https://travis-ci.org/wo-app/wo.png)](https://travis-ci.org/wo-app/wo)
4
+ [![Code Climate](https://codeclimate.com/github/wo-app/wo/badges/gpa.svg)](https://codeclimate.com/github/wo-app/wo)
5
+ [![Test Coverage](https://codeclimate.com/github/wo-app/wo/badges/coverage.svg)](https://codeclimate.com/github/wo-app/wo)
6
+
3
7
  CLI and Ruby client for [wo server](https://github.com/wo-app/wo-server)
4
8
 
5
9
  Instration
@@ -2,6 +2,8 @@ module WO
2
2
  class Client
3
3
  API_URL = "https://wo-app.herokuapp.com"
4
4
 
5
+ attr_reader :api_url
6
+
5
7
  def initialize(options = {})
6
8
  @api_url = options[:url] ? options[:url] : API_URL
7
9
  end
@@ -1,5 +1,7 @@
1
1
  module WO
2
2
  class Configure
3
+ attr_reader :token, :repo, :branch, :user_name
4
+
3
5
  def initialize(options = {})
4
6
  [:token, :repo, :branch, :user_name].each do |key|
5
7
  next unless value = options[key]
@@ -9,10 +11,10 @@ module WO
9
11
 
10
12
  def to_h
11
13
  {
12
- "organization[token]": @token,
13
- "doing[repo]": @repo,
14
- "doing[branch]": @branch,
15
- "user[name]": @user_name,
14
+ "organization[token]" => @token,
15
+ "doing[repo]" => @repo,
16
+ "doing[branch]" => @branch,
17
+ "user[name]" => @user_name,
16
18
  }
17
19
  end
18
20
  end
@@ -13,7 +13,7 @@ module WO
13
13
  private
14
14
 
15
15
  def constantize
16
- Kernel.const_get("WO").const_get("Hook").const_get(@sh.capitalize)
16
+ Kernel.const_get("WO").const_get("Hook").const_get(@sh.to_s.capitalize)
17
17
  end
18
18
  end
19
19
  end
@@ -1,6 +1,6 @@
1
1
  module WO
2
2
  MAJOR = 0
3
3
  MINOR = 0
4
- PATCH = 2
4
+ PATCH = 3
5
5
  VERSION = [MAJOR, MINOR, PATCH].join('.').freeze
6
6
  end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe WO::Client do
4
+ let(:client) { described_class.new }
5
+
6
+ describe "#initialize" do
7
+ it "assigns default API url" do
8
+ expect(client.api_url).to eq WO::Client::API_URL
9
+ end
10
+
11
+ it "assigns API url" do
12
+ client = described_class.new(url: "http://test.com")
13
+
14
+ expect(client.api_url).to eq "http://test.com"
15
+ end
16
+ end
17
+
18
+ describe "#doings" do
19
+ it "returns WO::Response instance" do
20
+ options = {}
21
+
22
+ allow_any_instance_of(WO::Configure).to receive(:to_h) { {} }
23
+ allow(Faraday).to receive(:get) { double(Faraday::Response) }
24
+
25
+ expect(client.doings(options)).to be_a WO::Response
26
+ end
27
+ end
28
+
29
+ describe "#create_doing" do
30
+ it "returns WO::Response instance" do
31
+ options = {}
32
+
33
+ allow_any_instance_of(WO::Configure).to receive(:to_h) { {} }
34
+ allow(Faraday).to receive(:post) { double(Faraday::Response) }
35
+
36
+ expect(client.create_doing(options)).to be_a WO::Response
37
+ end
38
+ end
39
+
40
+ describe "#create_organization" do
41
+ it "returns WO::Response instance" do
42
+ allow_any_instance_of(WO::Configure).to receive(:to_h) { {} }
43
+ allow(Faraday).to receive(:post) { double(Faraday::Response) }
44
+
45
+ expect(client.create_organization).to be_a WO::Response
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe WO::Configure do
4
+ let(:configure) { described_class.new(token: "token", repo: "repo", branch: "branch", user_name: "user_name") }
5
+
6
+ describe "#initialize" do
7
+ it "assigns instance variables" do
8
+ expect(configure.token).to eq "token"
9
+ expect(configure.repo).to eq "repo"
10
+ expect(configure.branch).to eq "branch"
11
+ expect(configure.user_name).to eq "user_name"
12
+ end
13
+ end
14
+
15
+ describe "#to_h" do
16
+ it "returns WO::Response instance" do
17
+ configure_hash = {
18
+ "organization[token]" => "token",
19
+ "doing[repo]" => "repo",
20
+ "doing[branch]" => "branch",
21
+ "user[name]" => "user_name",
22
+ }
23
+
24
+ expect(configure.to_h).to eq configure_hash
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe WO::Hook::Zsh do
4
+ let(:zsh) { described_class.new }
5
+
6
+ describe "#hook" do
7
+ it "returns hook for zsh" do
8
+ hook = %(
9
+ _wo_hook() {
10
+ repo_path=`git rev-parse --show-toplevel 2>&1`
11
+
12
+ if [[ "$?" == 0 ]] ; then
13
+ token=`cat ${repo_path}/.wo 2>&1`
14
+
15
+ if [[ "$?" == 0 ]] ; then
16
+ repo=`basename ${repo_path}`
17
+ branch=`git rev-parse --abbrev-ref HEAD`
18
+ user_name=`git config user.name`
19
+
20
+ wo doing ${repo} ${branch} ${user_name}
21
+ fi
22
+ fi
23
+ }
24
+
25
+ _wo_hook_background() {
26
+ (_wo_hook &)
27
+ }
28
+
29
+ typeset -ag precmd_functions
30
+ if [[ -z $precmd_functions[(r)_wo_hook_background] ]]; then
31
+ precmd_functions+=_wo_hook_background;
32
+ fi
33
+ )
34
+
35
+ expect(zsh.hook).to eq hook
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe WO::Hook do
4
+ describe "#hook" do
5
+ let(:hook) { described_class.new("zsh") }
6
+
7
+ it "calls WO::Hook::Zsh#hook" do
8
+ expect_any_instance_of(WO::Hook::Zsh).to receive(:hook)
9
+
10
+ hook.hook
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe WO::Loader do
4
+ let(:loader) { described_class.new }
5
+
6
+ describe "#config" do
7
+ it "returns config hash" do
8
+ config_hash = { "url" => "https://wo-app.herokuapp.com",
9
+ "token" => "dfddda19-e44d-4f9f-8e51-8eeb9df9fa1e" }
10
+
11
+ expect(loader.config).to eq (config_hash)
12
+ end
13
+ end
14
+
15
+ describe "#to_h" do
16
+ it "returns config hash" do
17
+ config_hash = { url: "https://wo-app.herokuapp.com",
18
+ token: "dfddda19-e44d-4f9f-8e51-8eeb9df9fa1e" }
19
+
20
+ expect(loader.to_h).to eq config_hash
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe WO::Response::Format::Timeline do
4
+ class Timeline
5
+ include WO::Response::Format::Timeline
6
+ end
7
+
8
+ let(:timeline) { Timeline.new }
9
+
10
+ describe "#to_timeline" do
11
+ it "returns timeline" do
12
+ doings = { "users" => [ { "name" => "name",
13
+ "recent_repo" => "recent_repo",
14
+ "recent_branch" => "recent_branch",
15
+ "time_ago" => "time_ago" } ] }
16
+ allow(timeline).to receive(:to_json) { doings }
17
+
18
+ expect(timeline.to_timeline).to eq ["\e[1m\e[32mname: \e[37mrecent_repo/recent_branch \e[30mtime_ago\e[0m"]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe WO::Response do
4
+
5
+ describe "#to_json" do
6
+ it "returns response json" do
7
+ faraday_response = double(Faraday::Response, body: '{"repo":"test"}')
8
+ response = described_class.new(faraday_response)
9
+
10
+ expect(response.to_json).to eq ({ "repo" => "test" })
11
+ end
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Saito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-05 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -63,6 +63,13 @@ files:
63
63
  - lib/wo/response/format/timeline.rb
64
64
  - lib/wo/version.rb
65
65
  - spec/spec_helper.rb
66
+ - spec/wo/client_spec.rb
67
+ - spec/wo/configure_spec.rb
68
+ - spec/wo/hook/zsh_spec.rb
69
+ - spec/wo/hook_spec.rb
70
+ - spec/wo/loader_spec.rb
71
+ - spec/wo/response/format/timeline_spec.rb
72
+ - spec/wo/response_spec.rb
66
73
  - wo.gemspec
67
74
  homepage: https://github.com/wo-app/wo
68
75
  licenses: