barkeep 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c1d538a93aa89e6669467682442091dd61eddc4
4
+ data.tar.gz: 02d2cd3bfb771bbbaa843051a39f47d81a3199a5
5
+ SHA512:
6
+ metadata.gz: f064783e33b5768021a3ab970b97c5bfc5f5df962fc3a14dd7c660aaab43a6e8b80d6752a9abce6095c925aee68cd7e046139b8f9be63e60278da3572e2f05e4
7
+ data.tar.gz: 48a15b47f101b868299ef12855b5c40c6facc5bc596fcf8bbbdcceaa7d202f74054af0cc2a7097f6734af9a2e70f3b1dfe60511d457636ba1a6142dc8427e18a
data/.gitignore CHANGED
@@ -11,32 +11,8 @@ doc
11
11
  # bundler
12
12
  .bundle
13
13
 
14
- # jeweler generated
14
+ # Built gem
15
15
  pkg
16
16
 
17
- # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
18
- #
19
- # * Create a file at ~/.gitignore
20
- # * Include files you want ignored
21
- # * Run: git config --global core.excludesfile ~/.gitignore
22
- #
23
- # After doing this, these files will be ignored in all your git projects,
24
- # saving you from having to 'pollute' every project you touch with them
25
- #
26
- # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
27
- #
28
- # For MacOS:
29
- #
30
- #.DS_Store
31
- #
32
- # For TextMate
33
- #*.tmproj
34
- #tmtags
35
- #
36
- # For emacs:
37
- #*~
38
- #\#*
39
- #.\#*
40
- #
41
- # For vim:
42
- #*.swp
17
+ # Shouldn't commit Gemfile.lock to gem repos
18
+ Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## Version 0.3.0 - February 20, 2014
2
+
3
+ * Drop the dependency on grit (which is abandoned) in favor of calling git on the command line
4
+ * Drop the dependency on rcov (which is also abandoned) in favor of nada
5
+ * Allow barkeep to be rendered from within controller or view context
6
+ * Allow partials to access Rails helpers if present
data/Rakefile CHANGED
@@ -7,13 +7,6 @@ Rake::TestTask.new(:test) do |test|
7
7
  test.verbose = true
8
8
  end
9
9
 
10
- require 'rcov/rcovtask'
11
- Rcov::RcovTask.new do |test|
12
- test.libs << 'test'
13
- test.pattern = 'test/**/test_*.rb'
14
- test.verbose = true
15
- end
16
-
17
10
  task :default => :test
18
11
 
19
12
  require 'rdoc/task'
data/barkeep.gemspec CHANGED
@@ -19,10 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_runtime_dependency "grit"
23
22
  spec.add_runtime_dependency "json"
24
23
  spec.add_development_dependency "mocha", ">= 0.9.12"
25
24
  spec.add_development_dependency "shoulda"
26
- spec.add_development_dependency "rcov"
27
25
  spec.add_development_dependency "rake"
28
26
  end
data/lib/barkeep.rb CHANGED
@@ -1,15 +1,18 @@
1
1
  require 'json'
2
- require 'grit_wrapper'
2
+ require 'git_wrapper'
3
3
 
4
4
  module Barkeep
5
5
 
6
6
  def barkeep
7
7
  @@barkeep ||= Barkeeper.new
8
+ @@barkeep.dup.tap { |barkeep| barkeep.renderer = self }
8
9
  end
9
10
 
10
11
  end
11
12
 
12
13
  class Barkeeper
14
+
15
+ attr_accessor :renderer
13
16
 
14
17
  def config
15
18
  @config ||= JSON.parse(File.read("config/barkeep.json"))
@@ -37,7 +40,11 @@ class Barkeeper
37
40
  #{
38
41
  config['panes'].map do |name|
39
42
  if name =~ /^(p|partial) (.*)/
40
- renderer.send(:render_to_string, {:partial => $2})
43
+ if renderer.respond_to?(:render_to_string)
44
+ renderer.send(:render_to_string, {:partial => $2})
45
+ else
46
+ renderer.send(:render, {:partial => $2})
47
+ end
41
48
  else
42
49
  send(name)
43
50
  end
@@ -51,7 +58,7 @@ class Barkeeper
51
58
  end
52
59
 
53
60
  def renderer
54
- @@renderer ||= ApplicationController.new
61
+ @renderer ||= ApplicationController.new
55
62
  end
56
63
 
57
64
  def branch_info
@@ -82,7 +89,7 @@ class Barkeeper
82
89
  end
83
90
 
84
91
  def grit_info
85
- GritWrapper.instance
92
+ GitWrapper.instance
86
93
  end
87
94
 
88
95
  def branch_link_attributes
@@ -1,3 +1,3 @@
1
1
  module Barkeep
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,44 +1,45 @@
1
- require 'grit'
2
-
3
1
  # A singleton refreshes on every request in development but
4
2
  # caches in environments where class caching is enabled.
5
3
  require 'singleton'
6
4
  require 'ostruct'
7
5
 
8
- class GritWrapper
6
+ class GitWrapper
9
7
  include Singleton
10
8
 
11
9
  def repository
12
- @repository ||= Grit::Repo.new('.')
13
- rescue Grit::InvalidGitRepositoryError
14
- # not in a directory that contains .git
15
- @repository = :invalid
10
+ @repository = (Dir.new('./.git') rescue :invalid)
16
11
  end
17
12
 
18
13
  def repository?
19
14
  !repository.nil? && repository != :invalid
20
15
  end
21
16
 
22
- def head
23
- @head ||= repository.head
24
- end
25
-
26
17
  def last_commit_hash
27
- @last_commit_hash ||= head.commit.to_s
18
+ @last_commit_hash ||= `git rev-parse HEAD`.strip
28
19
  end
29
20
 
30
21
  def last_commit
31
- @last_commit ||= repository.commit(last_commit_hash) || OpenStruct.new
22
+ @last_commit ||= begin
23
+ if repository?
24
+ OpenStruct.new(
25
+ author: `git show -s --format='format:%an <%ae>'`.strip,
26
+ message: `git show -s --format='%s'`.strip,
27
+ authored_date: Time.at(`git show -s --format='format:%at'`.to_i)
28
+ )
29
+ else
30
+ OpenStruct.new()
31
+ end
32
+ end
32
33
  end
33
34
 
34
35
  def to_hash
35
36
  return {
36
37
  :branch => 'Not currently on a branch.',
37
38
  :commit => (File.read("REVISION").strip rescue nil)
38
- } if head.nil?
39
-
39
+ } unless repository?
40
+
40
41
  @hash ||= {
41
- :branch => head.name,
42
+ :branch => `git rev-parse --abbrev-ref HEAD`.strip,
42
43
  :commit => last_commit_hash,
43
44
  :last_author => last_commit.author,
44
45
  :message => last_commit.message,
data/test/helper.rb CHANGED
@@ -10,6 +10,7 @@ end
10
10
  require 'test/unit'
11
11
  require 'shoulda'
12
12
  require 'mocha'
13
+ require 'mocha/test_unit'
13
14
 
14
15
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
15
16
  $LOAD_PATH.unshift(File.dirname(__FILE__))
data/test/test_barkeep.rb CHANGED
@@ -15,11 +15,11 @@ class TestBarkeep < Test::Unit::TestCase
15
15
 
16
16
  should "render a style tag filled with css" do
17
17
  css = File.read(File.expand_path(File.dirname(__FILE__) + "/../lib/default.css"))
18
- assert_equal "<style>#{css}</style>", barkeep.styles
18
+ assert_equal "<style>#{css}</style>", @barkeep.styles
19
19
  end
20
20
 
21
21
  should "render the barkeep bar" do
22
- GritWrapper.instance.stubs(:repository? => true, :to_hash => {:branch => 'new_branch', :commit => 'abcdef', :last_author => 'Johnny', :date => '2/11/2012'})
22
+ GitWrapper.instance.stubs(:repository? => true, :to_hash => {:branch => 'new_branch', :commit => 'abcdef', :last_author => 'Johnny', :date => '2/11/2012'})
23
23
  expected = %(
24
24
  <dl id="barkeep">
25
25
  <dt>Branch:</dt>
@@ -29,7 +29,7 @@ class TestBarkeep < Test::Unit::TestCase
29
29
  <dd class="close"><a href="#" onclick="c = document.getElementById('barkeep'); c.parentNode.removeChild(c); return false" title="Close me!">&times;</a></dd>
30
30
  </dl>
31
31
  )
32
- assert_equal expected.gsub(/\s+/, ''), barkeep.render_toolbar.gsub(/\s+/, '')
32
+ assert_equal expected.gsub(/\s+/, ''), @barkeep.render_toolbar.gsub(/\s+/, '')
33
33
  end
34
34
  end
35
35
 
metadata CHANGED
@@ -1,112 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barkeep
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.2.3
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - PatientsLikeMe
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-06 00:00:00.000000000 Z
11
+ date: 2014-02-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ! '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- none: false
21
- name: grit
22
- type: :runtime
23
- prerelease: false
14
+ name: json
24
15
  requirement: !ruby/object:Gem::Requirement
25
16
  requirements:
26
- - - ! '>='
27
- - !ruby/object:Gem::Version
28
- version: '0'
29
- none: false
30
- - !ruby/object:Gem::Dependency
31
- version_requirements: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - ! '>='
17
+ - - ">="
34
18
  - !ruby/object:Gem::Version
35
19
  version: '0'
36
- none: false
37
- name: json
38
20
  type: :runtime
39
21
  prerelease: false
40
- requirement: !ruby/object:Gem::Requirement
22
+ version_requirements: !ruby/object:Gem::Requirement
41
23
  requirements:
42
- - - ! '>='
24
+ - - ">="
43
25
  - !ruby/object:Gem::Version
44
26
  version: '0'
45
- none: false
46
27
  - !ruby/object:Gem::Dependency
47
- version_requirements: !ruby/object:Gem::Requirement
28
+ name: mocha
29
+ requirement: !ruby/object:Gem::Requirement
48
30
  requirements:
49
- - - ! '>='
31
+ - - ">="
50
32
  - !ruby/object:Gem::Version
51
33
  version: 0.9.12
52
- none: false
53
- name: mocha
54
34
  type: :development
55
35
  prerelease: false
56
- requirement: !ruby/object:Gem::Requirement
36
+ version_requirements: !ruby/object:Gem::Requirement
57
37
  requirements:
58
- - - ! '>='
38
+ - - ">="
59
39
  - !ruby/object:Gem::Version
60
40
  version: 0.9.12
61
- none: false
62
41
  - !ruby/object:Gem::Dependency
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ! '>='
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- none: false
69
42
  name: shoulda
70
- type: :development
71
- prerelease: false
72
43
  requirement: !ruby/object:Gem::Requirement
73
44
  requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- none: false
78
- - !ruby/object:Gem::Dependency
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ! '>='
45
+ - - ">="
82
46
  - !ruby/object:Gem::Version
83
47
  version: '0'
84
- none: false
85
- name: rcov
86
48
  type: :development
87
49
  prerelease: false
88
- requirement: !ruby/object:Gem::Requirement
50
+ version_requirements: !ruby/object:Gem::Requirement
89
51
  requirements:
90
- - - ! '>='
52
+ - - ">="
91
53
  - !ruby/object:Gem::Version
92
54
  version: '0'
93
- none: false
94
55
  - !ruby/object:Gem::Dependency
95
- version_requirements: !ruby/object:Gem::Requirement
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
96
58
  requirements:
97
- - - ! '>='
59
+ - - ">="
98
60
  - !ruby/object:Gem::Version
99
61
  version: '0'
100
- none: false
101
- name: rake
102
62
  type: :development
103
63
  prerelease: false
104
- requirement: !ruby/object:Gem::Requirement
64
+ version_requirements: !ruby/object:Gem::Requirement
105
65
  requirements:
106
- - - ! '>='
66
+ - - ">="
107
67
  - !ruby/object:Gem::Version
108
68
  version: '0'
109
- none: false
110
69
  description: an extensible developer's status bar to track your current deployed commit
111
70
  & more
112
71
  email:
@@ -115,47 +74,46 @@ executables: []
115
74
  extensions: []
116
75
  extra_rdoc_files: []
117
76
  files:
118
- - .document
119
- - .gitignore
77
+ - ".document"
78
+ - ".gitignore"
79
+ - CHANGELOG.md
120
80
  - Gemfile
121
- - Gemfile.lock
122
81
  - LICENSE.txt
123
82
  - README.rdoc
124
83
  - Rakefile
125
- - VERSION
126
84
  - barkeep.gemspec
127
85
  - lib/barkeep.rb
128
86
  - lib/barkeep/version.rb
129
87
  - lib/default.css
130
- - lib/grit_wrapper.rb
88
+ - lib/git_wrapper.rb
131
89
  - test/helper.rb
132
90
  - test/test_barkeep.rb
133
91
  homepage: https://github.com/patientslikeme/barkeep
134
92
  licenses:
135
93
  - MIT
94
+ metadata: {}
136
95
  post_install_message:
137
96
  rdoc_options: []
138
97
  require_paths:
139
98
  - lib
140
99
  required_ruby_version: !ruby/object:Gem::Requirement
141
100
  requirements:
142
- - - ! '>='
101
+ - - ">="
143
102
  - !ruby/object:Gem::Version
144
103
  version: '0'
145
- none: false
146
104
  required_rubygems_version: !ruby/object:Gem::Requirement
147
105
  requirements:
148
- - - ! '>='
106
+ - - ">="
149
107
  - !ruby/object:Gem::Version
150
108
  version: '0'
151
- none: false
152
109
  requirements: []
153
110
  rubyforge_project:
154
- rubygems_version: 1.8.23
111
+ rubygems_version: 2.2.0
155
112
  signing_key:
156
- specification_version: 3
113
+ specification_version: 4
157
114
  summary: an extensible developer's status bar to track your current deployed commit
158
115
  & more
159
116
  test_files:
160
117
  - test/helper.rb
161
118
  - test/test_barkeep.rb
119
+ has_rdoc:
data/Gemfile.lock DELETED
@@ -1,32 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- barkeep (0.2.3)
5
- grit
6
- json
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- diff-lcs (1.2.4)
12
- grit (2.5.0)
13
- diff-lcs (~> 1.1)
14
- mime-types (~> 1.15)
15
- posix-spawn (~> 0.3.6)
16
- json (1.7.7)
17
- mime-types (1.23)
18
- mocha (0.9.12)
19
- posix-spawn (0.3.6)
20
- rake (10.0.4)
21
- rcov (0.9.9)
22
- shoulda (2.11.3)
23
-
24
- PLATFORMS
25
- ruby
26
-
27
- DEPENDENCIES
28
- barkeep!
29
- mocha (>= 0.9.12)
30
- rake
31
- rcov
32
- shoulda
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.2