zenflow 0.8.0 → 0.8.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 +4 -4
- data/VERSION.yml +1 -1
- data/bin/zenflow +3 -1
- data/lib/zenflow.rb +0 -1
- data/lib/zenflow/cli.rb +3 -2
- data/lib/zenflow/helpers/github.rb +9 -7
- data/lib/zenflow/helpers/shell.rb +1 -1
- data/spec/zenflow/helpers/cli_spec.rb +41 -0
- data/spec/zenflow/helpers/github_spec.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6b5ec1c611f21f5487788d92b5befb16e679769
|
4
|
+
data.tar.gz: 91bd9a989c89cdbe14712829907157abfbfabaa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c5a484cf2e3b0b99a9ab72c52f73ba1b91aa723181ae44b626a9ca8e087b58fdb6b1f22aa3e0291092609ab825ac1c0c02800c21620b7bab41297faf99c851b
|
7
|
+
data.tar.gz: 8369252eaa940ddffa8d49313609335c4a53a2c11b6648bcf5d2ab72bae50394ec73f7b20f53127a69b269d6b9cb43c7273ba5075a8480ee507cf19ec117377b
|
data/VERSION.yml
CHANGED
data/bin/zenflow
CHANGED
@@ -3,10 +3,12 @@ $: << File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'zenflow'
|
5
5
|
|
6
|
+
ALLOWED_COMMANDS_BEFORE_CONFIG = ['init', '-h', '--help', '-v', '--version']
|
7
|
+
|
6
8
|
Zenflow::LogToFile("====== Zenflow #{Zenflow::VERSION}/#{Time.now.strftime('%c')} ======")
|
7
9
|
Zenflow::LogToFile("$ zenflow #{ARGV.join(' ')}\n")
|
8
10
|
|
9
|
-
if ARGV.first
|
11
|
+
if !ALLOWED_COMMANDS_BEFORE_CONFIG.include?(ARGV.first) && !Zenflow::Config.configured?
|
10
12
|
Zenflow::Log("This project has not been configured. Please run `zenflow init`.", :color => :red)
|
11
13
|
exit(1)
|
12
14
|
end
|
data/lib/zenflow.rb
CHANGED
data/lib/zenflow/cli.rb
CHANGED
@@ -50,8 +50,9 @@ module Zenflow
|
|
50
50
|
|
51
51
|
desc "set_up_github", "Set up GitHub user information"
|
52
52
|
def set_up_github
|
53
|
-
|
54
|
-
|
53
|
+
user = Zenflow::Github.user
|
54
|
+
if user.to_s != ''
|
55
|
+
if Zenflow::Ask("Your GitHub user is currently #{user}. Do you want to use that?", :options => ["y", "N"], :default => "Y") == "n"
|
55
56
|
Zenflow::Github.set_user
|
56
57
|
end
|
57
58
|
else
|
@@ -2,12 +2,14 @@ module Zenflow
|
|
2
2
|
|
3
3
|
module Github
|
4
4
|
def self.user
|
5
|
-
Zenflow::Shell.run('git config --get github.user', silent: true)
|
5
|
+
user = Zenflow::Shell.run('git config --get github.user', silent: true)
|
6
|
+
user = user.chomp unless user.nil?
|
7
|
+
user
|
6
8
|
end
|
7
9
|
|
8
10
|
def self.zenflow_token
|
9
|
-
zenflow_token = Zenflow::Shell.run('git config --get zenflow.token', silent: true)
|
10
|
-
zenflow_token =
|
11
|
+
zenflow_token = Zenflow::Shell.run('git config --get zenflow.token', silent: true)
|
12
|
+
zenflow_token = zenflow_token.chomp unless zenflow_token.nil?
|
11
13
|
zenflow_token
|
12
14
|
end
|
13
15
|
|
@@ -22,11 +24,11 @@ module Zenflow
|
|
22
24
|
return
|
23
25
|
end
|
24
26
|
end
|
25
|
-
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def self.set_user
|
29
|
+
username = Zenflow::Ask("What is your Github username?")
|
30
|
+
Zenflow::Shell.run("git config --global github.user #{username}", silent: true)
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
class GithubRequest
|
@@ -53,7 +53,7 @@ module Zenflow
|
|
53
53
|
def run_with_result_check(command, options={})
|
54
54
|
output = `#{command}`
|
55
55
|
Zenflow::LogToFile(output)
|
56
|
-
if last_exit_status.to_i > 0
|
56
|
+
if last_exit_status.to_i > 0 && !options[:silent]
|
57
57
|
if output.strip != ""
|
58
58
|
puts "#{output.strip}\n"
|
59
59
|
end
|
@@ -19,6 +19,47 @@ describe Zenflow::CLI do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
describe "#set_up_github" do
|
23
|
+
context "when a github user is already saved" do
|
24
|
+
before do
|
25
|
+
Zenflow::Github.should_receive(:user).and_return('user')
|
26
|
+
end
|
27
|
+
|
28
|
+
context "and the user decides to set a new one" do
|
29
|
+
before do
|
30
|
+
Zenflow.should_receive(:Ask).and_return('n')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "authorizes with Github" do
|
34
|
+
Zenflow::Github.should_receive(:set_user)
|
35
|
+
subject.set_up_github
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "and the user decides not to set a new one" do
|
40
|
+
before do
|
41
|
+
Zenflow.should_receive(:Ask).and_return('y')
|
42
|
+
end
|
43
|
+
|
44
|
+
it "does not authorize with Github" do
|
45
|
+
Zenflow::Github.should_not_receive(:set_user)
|
46
|
+
subject.set_up_github
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when a zenflow_token is not already saved" do
|
52
|
+
before do
|
53
|
+
Zenflow::Github.should_receive(:user).and_return(nil)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "authorizes with Github" do
|
57
|
+
Zenflow::Github.should_receive(:set_user)
|
58
|
+
subject.set_up_github
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
22
63
|
describe "#authorize_github" do
|
23
64
|
context "when a zenflow_token is already saved" do
|
24
65
|
before do
|
@@ -13,6 +13,16 @@ describe Zenflow::Github do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
describe '.set_user' do
|
17
|
+
let(:user){'github-user'}
|
18
|
+
|
19
|
+
it 'asks for the user name and sets it to github.user' do
|
20
|
+
Zenflow.should_receive(:Ask).and_return(user)
|
21
|
+
Zenflow::Shell.should_receive(:run).with(/github\.user #{user}/, silent: true)
|
22
|
+
Zenflow::Github.set_user
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
16
26
|
describe '.authorize' do
|
17
27
|
context "when authorization fails" do
|
18
28
|
before do
|