octokom 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ class Cli
4
+ include Octokom::Shell
5
+ end
6
+
7
+ describe Octokom::Shell do
8
+ let(:stdout) { double }
9
+
10
+ subject(:cli) { Cli.new }
11
+
12
+ before do
13
+ allow(cli).to receive(:puts) do |msg|
14
+ stdout.puts(msg)
15
+ end
16
+
17
+ allow(cli).to receive(:print) do |msg|
18
+ stdout.print(msg)
19
+ end
20
+ end
21
+
22
+ describe '.info' do
23
+ it 'prints a message' do
24
+ expect(stdout).to receive(:puts).with('Info Test')
25
+ cli.info('Test')
26
+ end
27
+ end
28
+
29
+ describe '.error' do
30
+ it 'prints a message and returns with an error code' do
31
+ expect(stdout).to receive(:puts).with('Error Test')
32
+ expect { cli.error('Test') }.to raise_error(SystemExit)
33
+ end
34
+ end
35
+
36
+ describe '.task' do
37
+ before do
38
+ allow(stdout).to receive(:print)
39
+ allow(stdout).to receive(:puts)
40
+ end
41
+
42
+ it 'updates a message' do
43
+ expect(stdout).to receive(:print).with('Waiting Test')
44
+ expect(stdout).to receive(:print).with("\r")
45
+ expect(stdout).to receive(:print).with('Done Test')
46
+ expect(stdout).to receive(:puts).with(nil)
47
+ cli.task('Test') { 'Ok' }
48
+ end
49
+
50
+ it 'executes a task' do
51
+ expect { |block| cli.task('Test', &block) }.to yield_with_no_args
52
+ end
53
+ end
54
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,4 +2,10 @@ lib = File.expand_path('../../lib', __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  require 'octokom'
5
- require 'rspec/autorun'
5
+ require 'rspec'
6
+
7
+ ENV['HOME'] = './spec/support'
8
+
9
+ def load_example(file_name)
10
+ open("#{ENV['HOME']}/#{file_name}.txt", &:read)
11
+ end
@@ -0,0 +1,11 @@
1
+ # Please enter a title and optional a description below
2
+ # the comments. To continue, save end close the file.
3
+ # Comment lines starting with '#' will be ignored.
4
+
5
+ # Title
6
+ Chunky Bacon
7
+
8
+ # Description
9
+ Really
10
+ # comment
11
+ remarkable!
@@ -0,0 +1,5 @@
1
+ master fc7af5e [origin/master] Test 1
2
+ * test-1 38d59ea Test 3
3
+ remotes/origin/HEAD -> origin/master
4
+ remotes/origin/master fc7af5e Test 1
5
+ remotes/origin/test-1 38d59ea Test 3
@@ -0,0 +1,5 @@
1
+ master 5b09cf7 [origin/master] Initial commit
2
+ * test-1 8ece917 Test 1
3
+ remotes/origin/HEAD -> origin/master
4
+ remotes/origin/feature e7ef9da Test
5
+ remotes/origin/master 5b09cf7 Initial commit
@@ -0,0 +1,5 @@
1
+ master 5b09cf7 [origin/master] Initial commit
2
+ * test-1 8ece917 Test 1
3
+ remotes/origin/HEAD -> origin/master
4
+ remotes/origin/test-1 e7ef9da Test
5
+ remotes/origin/master 5b09cf7 Initial commit
@@ -0,0 +1 @@
1
+ aec653e Add all the features
metadata CHANGED
@@ -1,115 +1,126 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octokom
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
  - Martin Jagusch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-14 00:00:00.000000000 Z
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.1
19
+ version: 0.6.3
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.6.1
26
+ version: 0.6.3
27
27
  - !ruby/object:Gem::Dependency
28
- name: octokit
28
+ name: netrc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.0.rc2
33
+ version: 0.7.7
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: 2.0.0.rc2
40
+ version: 0.7.7
41
41
  - !ruby/object:Gem::Dependency
42
- name: security
42
+ name: octokit
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.2
47
+ version: 2.7.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.2
54
+ version: 2.7.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 10.1.0
61
+ version: 10.1.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 10.1.0
68
+ version: 10.1.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 2.14.1
75
+ version: 3.0.0.beta2
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 2.14.1
83
- description: Command line application for your every day GitHub workflow.
82
+ version: 3.0.0.beta2
83
+ description: GitHub For Your Command Line
84
84
  email: _@mj.io
85
85
  executables:
86
86
  - octokom
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .rspec
92
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
93
  - Gemfile
94
94
  - LICENSE.txt
95
95
  - README.md
96
96
  - Rakefile
97
97
  - bin/octokom
98
98
  - lib/octokom.rb
99
- - lib/octokom/authentication.rb
99
+ - lib/octokom/cli.rb
100
+ - lib/octokom/client.rb
100
101
  - lib/octokom/command.rb
102
+ - lib/octokom/command/issue.rb
101
103
  - lib/octokom/command/pull_request.rb
102
- - lib/octokom/keychain.rb
104
+ - lib/octokom/core_ext/blank.rb
105
+ - lib/octokom/editor.rb
103
106
  - lib/octokom/repository.rb
107
+ - lib/octokom/shell.rb
104
108
  - lib/octokom/version.rb
105
109
  - octokom.gemspec
106
- - spec/octokom/authentication_spec.rb
110
+ - spec/octokom/cli_spec.rb
111
+ - spec/octokom/client_spec.rb
112
+ - spec/octokom/command/issue_spec.rb
107
113
  - spec/octokom/command/pull_request_spec.rb
108
114
  - spec/octokom/command_spec.rb
109
- - spec/octokom/keychain_spec.rb
115
+ - spec/octokom/editor_spec.rb
110
116
  - spec/octokom/repository_spec.rb
111
- - spec/octokom_spec.rb
117
+ - spec/octokom/shell_spec.rb
112
118
  - spec/spec_helper.rb
119
+ - spec/support/OCTOKOM-123
120
+ - spec/support/git_branch_no_pending_commits.txt
121
+ - spec/support/git_branch_no_remote.txt
122
+ - spec/support/git_branch_pending_commits.txt
123
+ - spec/support/git_log_commits.txt
113
124
  homepage: https://github.com/mjio/octokom
114
125
  licenses:
115
126
  - MIT
@@ -120,26 +131,32 @@ require_paths:
120
131
  - lib
121
132
  required_ruby_version: !ruby/object:Gem::Requirement
122
133
  requirements:
123
- - - '>='
134
+ - - ">="
124
135
  - !ruby/object:Gem::Version
125
- version: '0'
136
+ version: 1.9.3
126
137
  required_rubygems_version: !ruby/object:Gem::Requirement
127
138
  requirements:
128
- - - '>='
139
+ - - ">="
129
140
  - !ruby/object:Gem::Version
130
141
  version: '0'
131
142
  requirements: []
132
143
  rubyforge_project:
133
- rubygems_version: 2.0.3
144
+ rubygems_version: 2.2.0
134
145
  signing_key:
135
146
  specification_version: 4
136
- summary: octokom-0.0.2
147
+ summary: octokom-0.0.3
137
148
  test_files:
138
- - spec/octokom/authentication_spec.rb
149
+ - spec/octokom/cli_spec.rb
150
+ - spec/octokom/client_spec.rb
151
+ - spec/octokom/command/issue_spec.rb
139
152
  - spec/octokom/command/pull_request_spec.rb
140
153
  - spec/octokom/command_spec.rb
141
- - spec/octokom/keychain_spec.rb
154
+ - spec/octokom/editor_spec.rb
142
155
  - spec/octokom/repository_spec.rb
143
- - spec/octokom_spec.rb
156
+ - spec/octokom/shell_spec.rb
144
157
  - spec/spec_helper.rb
145
- has_rdoc:
158
+ - spec/support/OCTOKOM-123
159
+ - spec/support/git_branch_no_pending_commits.txt
160
+ - spec/support/git_branch_no_remote.txt
161
+ - spec/support/git_branch_pending_commits.txt
162
+ - spec/support/git_log_commits.txt
@@ -1,42 +0,0 @@
1
- require 'io/console'
2
-
3
- module Octokom
4
- module Authentication
5
- OCTOKIT_ERRORS = [
6
- Octokit::BadRequest,
7
- Octokit::Unauthorized,
8
- Octokit::Forbidden,
9
- Octokit::NotFound,
10
- Octokit::NotAcceptable,
11
- Octokit::UnprocessableEntity,
12
- Octokit::InternalServerError,
13
- Octokit::NotImplemented,
14
- Octokit::BadGateway,
15
- Octokit::ServiceUnavailable
16
- ]
17
-
18
- def authenticate(&block)
19
- begin
20
- yield Octokit::Client.new(login: login, password: password)
21
- rescue *OCTOKIT_ERRORS => e
22
- puts "Unable to authenticate user '#{login}' (#{e.class})"
23
- # TODO print message about how to reenter credentials
24
- # TODO use custom method instead of puts
25
- end
26
- end
27
-
28
- private
29
-
30
- def login
31
- keychain[:login]
32
- end
33
-
34
- def password
35
- keychain[:password]
36
- end
37
-
38
- def keychain
39
- Octokom::Keychain.create
40
- end
41
- end
42
- end
@@ -1,54 +0,0 @@
1
- module Octokom
2
- class Keychain
3
- def self.create
4
- new.find_or_create_keychain
5
- end
6
-
7
- def find_or_create_keychain
8
- if keychain
9
- {login: keychain.attributes['acct'], password: keychain.password}
10
- else
11
- create_octokom_keychain
12
- find_or_create_keychain
13
- end
14
- end
15
-
16
- private
17
-
18
- def keychain
19
- # TODO make sure this happens only once
20
- @keychain ||= octokom_keychain || github_keychain
21
- end
22
-
23
- def octokom_keychain
24
- Security::GenericPassword.find(service: 'octokom')
25
- end
26
-
27
- def github_keychain
28
- Security::InternetPassword.find(server: 'github.com')
29
- end
30
-
31
- def create_octokom_keychain
32
- login = ask_for_login
33
- password = ask_for_password
34
-
35
- puts
36
-
37
- save_octokom_keychain(login, password)
38
- end
39
-
40
- def ask_for_login
41
- print 'GitHub Login: '
42
- STDIN.gets.chomp
43
- end
44
-
45
- def ask_for_password
46
- print 'Password: '
47
- STDIN.noecho(&:gets).chomp
48
- end
49
-
50
- def save_octokom_keychain(login, password)
51
- Security::GenericPassword.add('octokom', login, password)
52
- end
53
- end
54
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class Cmd
4
- include Octokom::Authentication
5
- end
6
-
7
- describe Octokom::Authentication do
8
- let(:cmd) { Cmd.new }
9
- let(:keychain) { {login: 'fox', password: 'bacon'} }
10
-
11
- before do
12
- allow(cmd).to receive(:keychain) { keychain }
13
- end
14
-
15
- it 'authenticates the user' do
16
- credentials = {login: 'fox', password: 'bacon'}
17
- expect(Octokit::Client).to receive(:new).with(credentials)
18
- cmd.authenticate { }
19
- end
20
-
21
- it 'handels exceptions' do
22
- expect(STDOUT).to receive(:puts).with(/Unable to authenticate/)
23
- cmd.authenticate { raise Octokit::Unauthorized }
24
- end
25
- end
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Octokom::Keychain do
4
- let(:keychain) { double(attributes: {'acct' => 'fox'}, password: 'bacon') }
5
-
6
- before do
7
- allow(Security::GenericPassword).to receive(:find) { nil }
8
- allow(Security::GenericPassword).to receive(:add) { nil }
9
- allow(Security::InternetPassword).to receive(:find) { nil }
10
- end
11
-
12
- context 'using existing `octokom` keychain' do
13
- before do
14
- allow(Security::GenericPassword).to receive(:find).with(service: 'octokom') { keychain }
15
- end
16
-
17
- it 'finds the keychain' do
18
- expect(Octokom::Keychain.create).to eq(login: 'fox', password: 'bacon')
19
- end
20
- end
21
-
22
- context 'using existing `github` keychain' do
23
- before do
24
- allow(Security::InternetPassword).to receive(:find).with(server: 'github.com') { keychain }
25
- end
26
-
27
- it 'finds the keychain' do
28
- expect(Octokom::Keychain.create).to eq(login: 'fox', password: 'bacon')
29
- end
30
- end
31
-
32
- context 'creating new `github` keychain' do
33
- before do
34
- Octokom::Keychain.any_instance.stub(:ask_for_login).and_return('fox')
35
- Octokom::Keychain.any_instance.stub(:ask_for_password).and_return('bacon')
36
- allow(STDOUT).to receive(:puts)
37
- end
38
-
39
- it 'saves a keychain' do
40
- pending 'prevent retry'
41
- expect(Security::GenericPassword).to receive(:add).with('octokom', 'fox', 'bacon')
42
- Octokom::Keychain.create
43
- end
44
- end
45
- end