git-check-ci 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git-check-ci (0.1.1)
4
+ git-check-ci (0.1.2)
5
5
  daemons (~> 1.1)
6
6
  httparty
7
7
  json
data/README.md CHANGED
@@ -36,11 +36,11 @@ Run the setup command:
36
36
  Setup is now complete. Doing a test run.
37
37
  All good! Now the 'check' and 'fast-check' commands should work.
38
38
 
39
- Add it to your prompt:
39
+ Add it to your prompt (simplistic example):
40
40
 
41
41
  --- add me to e.g. ~/.profile ---
42
42
  eval "$(git check-ci init)"
43
- export PS1="\$(GitCheckCI) \u\$"
43
+ export PS1="\[\$(_git_ci_color)\]\$(_git_ci_status) \u@\h\$"
44
44
 
45
45
  Reload your shell:
46
46
 
@@ -79,5 +79,5 @@ The `GitCheckCI` shell helper does two things:
79
79
 
80
80
  The spawned server check the CI status over HTTP every minute and stores the response in the Git configuration (used as an IPC of sorts).
81
81
 
82
- It's done that way because `GitCheckCI` needs to be really, really fast---anything slower than 30ms will make your prompt feel unresponsive.
82
+ It's done that way because the `_git_ci_*` shell functions need to be really, really fast---anything slower than 30ms will make your prompt feel unresponsive.
83
83
 
@@ -51,9 +51,11 @@ module GitCheckCI
51
51
 
52
52
  # save the CI result to the Git config
53
53
  def save(code_and_response)
54
+ color, icon = Formatter.handle_response(code_and_response)
54
55
  @config.ci.last_checked = Time.now.strftime('%s')
55
56
  @config.ci.response = code_and_response.to_json
56
- @config.ci.status = Formatter.handle_response(code_and_response)
57
+ @config.ci.color = color
58
+ @config.ci.status = icon
57
59
  nil
58
60
  end
59
61
 
@@ -6,10 +6,10 @@ module GitCheckCI
6
6
 
7
7
  def handle_response(data)
8
8
  case data[:body]
9
- when /failed/ then build_string(:red, '✗')
10
- when /(pending|building)/ then build_string(:gray, '')
11
- when /[0-9a-f]{40}/ then build_string(:green, '✔')
12
- else build_string(:yellow, '!')
9
+ when /failed/ then [ color_code(:red), '✗' ]
10
+ when /(pending|building)/ then [ color_code(:gray), '' ]
11
+ when /[0-9a-f]{40}/ then [ color_code(:green), '✔' ]
12
+ else [ color_code(:yellow), '!' ]
13
13
  end
14
14
  end
15
15
 
@@ -17,7 +17,7 @@ module GitCheckCI
17
17
  private
18
18
 
19
19
 
20
- def build_string(color, symbol)
20
+ def color_code(color)
21
21
  reset = "\033[0m"
22
22
  color_code = case color
23
23
  when :red then "\033[31m"
@@ -26,8 +26,6 @@ module GitCheckCI
26
26
  when :gray then "\033[37m"
27
27
  else ""
28
28
  end
29
-
30
- "#{color_code}#{symbol}#{reset}"
31
29
  end
32
30
 
33
31
 
@@ -65,7 +65,10 @@ module GitCheckCI
65
65
  desc "init", "Output shell config."
66
66
  def init
67
67
  puts %q[
68
- GitCheckCI() {
68
+ _git_ci_color() {
69
+ git config ci.color 2>&1 || true
70
+ }
71
+ _git_ci_status() {
69
72
  # exit early if not in a git repository
70
73
  git status > /dev/null 2>&1 || return
71
74
 
@@ -81,6 +84,10 @@ module GitCheckCI
81
84
  # try to return a status
82
85
  git config ci.status 2> /dev/null || echo '?'
83
86
  }
87
+ GitCheckCI() {
88
+ echo "*** GitCheckCI is deprecated, use _git_ci_status"
89
+ _git_ci_status
90
+ }
84
91
  ]
85
92
  end
86
93
 
@@ -1,3 +1,3 @@
1
1
  module GitCheckCI
2
- VERSION = '0.1.1' unless defined?(GitCheckCI::VERSION)
2
+ VERSION = '0.1.2' unless defined?(GitCheckCI::VERSION)
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-check-ci
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Julien Letessier
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-05 00:00:00 +01:00
18
+ date: 2012-07-09 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency