see 0.0.17 → 0.0.18

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: 1d093edd84bc933822b73dfd09f3525e28853120
4
- data.tar.gz: a2d074d9228321f52c34ef5acff8b8ac277d6ae4
3
+ metadata.gz: 6fc1306fce1ef8f89fa0b52530fbc82aff7a2c53
4
+ data.tar.gz: 8c7faa2c59a0b29377c8d462248734a549dc102d
5
5
  SHA512:
6
- metadata.gz: 55499fc29349126cab6ab1ef67b77f42f71b8bff63c40101930184148c25db5f30230de41fa0fd9f74b2bc7ac38eb2b47524ae74defe21c800783186777e2a95
7
- data.tar.gz: bae96acfe1d4febb1567deadbf1599519484060c217a3765899e1d04b1c6d26c04931fd4795d2e9b17bafd32530094119a14d1c4541b0f9e8f2c4a028f3edd2d
6
+ metadata.gz: 5abb94324a05d965ed219007999038d9574e8883ca5c41341519e43577535dff250b8ab307bb24e04403222717f1348bd7e38bb5f05df6dcf584d1f9d9b46073
7
+ data.tar.gz: d32de757c172c7f6693612802d521cb08519726e44d8b9b174ef9a7943b52a6e29023b958d8cb871b594ba8c64668637923a5fadbdaaaa598d0368d1f19a1fc9
@@ -1,36 +1,39 @@
1
1
  require 'json'
2
+ require 'circleci'
2
3
 
3
4
  module See
4
5
  module Plugins
5
6
  class Circle
7
+ def display_name
8
+ 'CircleCi'
9
+ end
10
+
6
11
  def config_name
7
12
  'circle'
8
13
  end
9
14
 
10
- def run(config)
11
- info = []
15
+ def run(config, plugin_config)
16
+ lines = []
12
17
  token = ENV['CIRCLE_CI_ACCESS_TOKEN']
13
18
  unless token
14
- info << "\nCircle CI".light_red
15
- info << " You must set CIRCLE_CI_ACCESS_TOKEN env variable".red
16
- return info
19
+ lines << " You must set CIRCLE_CI_ACCESS_TOKEN env variable".red
20
+ return lines
17
21
  end
18
22
 
19
23
  CircleCi.configure do |cfg|
20
24
  cfg.token = token
21
25
  end
22
26
 
23
- response = CircleCi::Project.recent_builds(config['circle']['account'], config['circle']['repository'])
27
+ response = CircleCi::Project.recent_builds(plugin_config['account'], plugin_config['repository'])
24
28
  if response.errors.length > 0
25
- info << "\nCircle CI - " + "Errors encountered:".red
29
+ lines << " Errors encountered:".red
26
30
  response.errors.each do |error|
27
- info << " - " + "Error #{error.code}:".red + " #{JSON.parse(error.message)['message'].strip}"
31
+ lines << " - " + "Error #{error.code}:".red + " #{JSON.parse(error.message)['message'].strip}"
28
32
  end
29
- return info
33
+ return lines
30
34
  end
31
35
 
32
- info << "\nCircle CI".light_magenta
33
- info << " Latest Builds:".light_blue
36
+ lines << " Latest Builds:".light_blue
34
37
  response.body[0..4].each do |thing|
35
38
  if thing['committer_date']
36
39
  time = "- #{Date.parse(thing['committer_date']).strftime("%b %e,%l:%M %p")}".black
@@ -45,9 +48,9 @@ module See
45
48
  else
46
49
  name = ""
47
50
  end
48
- info << " - #{status.capitalize} #{thing["vcs_revision"][0..8].light_yellow} #{("#"+thing['build_num'].to_s).light_green} #{thing['subject']} #{name} #{time}"
51
+ lines << " - #{status.capitalize} #{thing["vcs_revision"][0..8].light_yellow} #{("#"+thing['build_num'].to_s).light_green} #{thing['subject']} #{name} #{time}"
49
52
  end
50
- info
53
+ lines
51
54
  end
52
55
  end
53
56
  end
@@ -3,26 +3,28 @@ require 'octokit'
3
3
  module See
4
4
  module Plugins
5
5
  class GitHub
6
+ def display_name
7
+ 'GitHub'
8
+ end
9
+
6
10
  def config_name
7
11
  'github'
8
12
  end
9
13
 
10
- def run(config)
14
+ def run(config, plugin_config)
11
15
  info = []
12
16
  token = ENV['GITHUB_ACCESS_TOKEN']
13
17
  unless token
14
- info << "\nGitHub".light_red
15
18
  info << " You must set GITHUB_ACCESS_TOKEN env variable".red
16
19
  return info
17
20
  end
18
21
 
19
22
  client = Octokit::Client.new :access_token => token
20
- account = config['github']['account']
21
- repository = config['github']['repository']
23
+ account = plugin_config['account']
24
+ repository = plugin_config['repository']
22
25
  github_name = [account, repository].join '/'
23
26
 
24
27
  pull_requests = client.pull_requests(github_name)
25
- info << "\nGitHub".light_magenta
26
28
  if pull_requests.count > 0
27
29
  info << " Open pull requests:".light_blue
28
30
  pull_requests.each do |pull_request|
@@ -3,21 +3,24 @@ require 'pivotal-tracker'
3
3
  module See
4
4
  module Plugins
5
5
  class Pivotal
6
+ def display_name
7
+ 'Pivotal Tracker'
8
+ end
9
+
6
10
  def config_name
7
11
  "pivotal"
8
12
  end
9
13
 
10
- def run(config)
14
+ def run(config, plugin_config)
11
15
  info = []
12
16
  token = ENV['PIVOTAL_TRACKER_ACCESS_TOKEN']
13
17
  unless token
14
- info << "\nPivotal Tracker".light_red
15
18
  info << " You must set PIVOTAL_TRACKER_ACCESS_TOKEN env variable".red
16
19
  return info
17
20
  end
18
21
 
19
22
  PivotalTracker::Client.token = token
20
- project = PivotalTracker::Project.find(config['pivotal']['project'])
23
+ project = PivotalTracker::Project.find(plugin_config['project'])
21
24
 
22
25
  next_unowned_story = nil
23
26
  has_current = false
@@ -36,7 +39,6 @@ module See
36
39
  end
37
40
  end
38
41
 
39
- info << "\nPivotal Tracker".light_magenta
40
42
  if stories.length > 0
41
43
  info << " Stories being worked on:".light_blue
42
44
  info << stories
@@ -3,13 +3,17 @@ require 'travis'
3
3
  module See
4
4
  module Plugins
5
5
  class TravisCI
6
+ def display_name
7
+ 'Travis CI'
8
+ end
9
+
6
10
  def config_name
7
11
  'travis'
8
12
  end
9
13
 
10
- def run(config)
14
+ def run(config, plugin_config)
11
15
  info = []
12
- repository = config["travis"]["repository"]
16
+ repository = plugin_config["repository"]
13
17
  builds = Travis::Repository.find(repository).recent_builds[0..4].map do |build|
14
18
  time = ( build.finished_at ? "- #{build.finished_at.strftime("%b %e,%l:%M %p")}" : "- running" ).black
15
19
  if build.pending?
@@ -22,11 +26,9 @@ module See
22
26
  end
23
27
 
24
28
  if builds.count > 0
25
- info << "\nTravis".light_magenta
26
29
  info << " Latest Builds:".light_blue
27
30
  info.concat(builds)
28
31
  else
29
- info << "Travis"
30
32
  info << "No available build status".yellow
31
33
  end
32
34
  info
data/lib/see/plugins.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  module See
2
2
  module Plugins
3
3
  require 'colorize'
4
- require 'circleci'
5
4
 
6
5
  def self.run_plugin(name, config)
7
6
  plugins = See::Plugins.constants.map do |const|
@@ -10,15 +9,17 @@ module See
10
9
  plugin.config_name == name
11
10
  end
12
11
 
13
- info = []
14
- plugins.each do |plugin|
15
- info.concat(plugin.run(config))
16
- end
17
-
12
+ lines = []
18
13
  if plugins.empty?
19
- puts "No plugin found with the name \"#{name}\"".light_red
14
+ lines << "\nNo plugin found with the name \"#{name}\"".light_red
15
+ else
16
+ plugins.each do |plugin|
17
+ lines << "\n"
18
+ lines << plugin.display_name.light_magenta
19
+ lines.concat(plugin.run(config, config[plugin.config_name]))
20
+ end
20
21
  end
21
- info
22
+ lines
22
23
  end
23
24
  end
24
25
  end
data/lib/see/runner.rb CHANGED
@@ -9,13 +9,13 @@ module See
9
9
  def run
10
10
  #
11
11
  # Whole thing happens in two major steps:
12
- # 1. load ./sights.yml
12
+ # 1. load ./see.yml
13
13
  # (fail if it doesn't exist)
14
14
  #
15
15
  # 2. provide information from each configured plugin
16
16
  # (provide content at the top and no content at the bottom)
17
17
  #
18
- config_path = "#{Dir.pwd}/sights.yml"
18
+ config_path = "#{Dir.pwd}/see.yml"
19
19
  begin
20
20
  config = YAML.load_file(config_path)
21
21
  rescue
@@ -26,7 +26,7 @@ module See
26
26
 
27
27
  progress = Thread.new do
28
28
  print "Pulling data from #{config.length} source#{config.length == 1 ? '' : 's'}"
29
- while true
29
+ loop do
30
30
  sleep 0.25
31
31
  print '.'
32
32
  end
@@ -35,17 +35,20 @@ module See
35
35
  threads = []
36
36
  config.each do |cfg|
37
37
  threads << Thread.new do
38
- Thread.current[:lines] = See::Plugins.run_plugin(cfg[0], config)
38
+ begin
39
+ Thread.current[:lines] = [See::Plugins.run_plugin(cfg[0], config)]
40
+ rescue => error
41
+ Thread.current[:lines] = ["Error running plugin: #{cfg[0]}".red]
42
+ Thread.current[:lines] << " #{error}".light_red
43
+ end
39
44
  end
40
45
  end
41
- puts
42
46
 
47
+ lines = threads.map { |t| t.join[:lines].flatten }
43
48
  progress.kill
44
49
 
45
- threads.each do |t|
46
- t.join
47
- t[:lines].each { |line| puts line }
48
- end
50
+ puts
51
+ lines.sort_by { |l| l[0] }.each { |l| puts l }
49
52
  puts
50
53
  end
51
54
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: see
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Avila
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-20 00:00:00.000000000 Z
11
+ date: 2014-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: faraday
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -28,14 +42,14 @@ dependencies:
28
42
  name: mime-types
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: 1.25.1
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: 1.25.1
41
55
  - !ruby/object:Gem::Dependency