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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a0a86e94828d1a8dc8cf6d84367463efcfd4a6c
4
- data.tar.gz: b3544bd8cb5bc89fc525ce06a72bf4853e7c36e2
3
+ metadata.gz: f6b5ec1c611f21f5487788d92b5befb16e679769
4
+ data.tar.gz: 91bd9a989c89cdbe14712829907157abfbfabaa2
5
5
  SHA512:
6
- metadata.gz: 70da301341826b7fb54e659722e231bbbf7656ce1291c699dc3ed973e20b2cdf8492a13b423f50bd5af00142dcb670bfca6c9ac3520b40f3018d83d8c93137a1
7
- data.tar.gz: b8e6fa22c96321a2b56ee1140e0ac4413472959844fba16f17c01d60597f7b944af50d5707e153c8f540b38464933e4ddbe517493780c6bde72dc24c4ae65e2b
6
+ metadata.gz: 7c5a484cf2e3b0b99a9ab72c52f73ba1b91aa723181ae44b626a9ca8e087b58fdb6b1f22aa3e0291092609ab825ac1c0c02800c21620b7bab41297faf99c851b
7
+ data.tar.gz: 8369252eaa940ddffa8d49313609335c4a53a2c11b6648bcf5d2ab72bae50394ec73f7b20f53127a69b269d6b9cb43c7273ba5075a8480ee507cf19ec117377b
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  major: 0
3
3
  minor: 8
4
- patch: 0
4
+ patch: 1
5
5
  pre:
@@ -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 != "init" && !Zenflow::Config.configured?
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
@@ -4,7 +4,6 @@ require 'colored'
4
4
  require 'terminal-table'
5
5
  require 'httparty'
6
6
  require 'json'
7
-
8
7
  require 'zenflow/helpers/version'
9
8
  require 'zenflow/version'
10
9
  require 'zenflow/helpers/log'
@@ -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
- if user = Zenflow::Github.user != ''
54
- if Zenflow::Ask("Your GitHub user is currently #{Zenflow::Github.user}. Do you want to use that?", :options => ["y", "N"], :default => "Y") == "n"
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).chomp
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).chomp
10
- zenflow_token = nil if zenflow_token.to_s.strip == ''
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
- def self.set_user
28
- username = Zenflow::Ask("What is your Github username?")
29
- Zenflow::Shell.run("git config --global github.user #{username}", silent: true)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zenflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Kittelson