hairballs 0.1.0 → 0.1.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: d253d151df5fdf784c216a8785627d1f0881cb01
4
- data.tar.gz: 45bce4a52cd3d2e01f48a3765b9fef39fffb36bc
3
+ metadata.gz: d1465ffb77e5a3cca642251d686e9a764ece6c02
4
+ data.tar.gz: 5cb9166c6199254d83dab384669178216a554680
5
5
  SHA512:
6
- metadata.gz: 0ca0f9c162b224b218184fd8afd15731ed52d220ff24032e75896cca7ed3bae272e6da15016f2556cbdcf7ec251e0dddbc01361b5dfd2f6fe1db076dadf1d3ff
7
- data.tar.gz: baff3f4a22ebfe513bba046a54486bf67da351bee1b8ea7f4365a7a21d9ef7e7f8c63f74775cb0c109b756fce5d28aae93389e368647dee838bb8e00fe38e8a1
6
+ metadata.gz: 2653b127751f63dd739dc0fe08fe088b89fe5f798c7d0658ea29aefb73278647ad2bd8ea5eea7d1088c5bb5e66c88c6ea48ff6cd75346ba6f59e8dee144c1ef8
7
+ data.tar.gz: 27bdc77f19a8737921fd7f0e6649b24d33beb67c140a2a250b56539a130122e7f7a40994c64ef85f942a10fd6ab949711d988ea370f86c6d520d5fc473e91b03
data/History.md CHANGED
@@ -1,13 +1,21 @@
1
+ ### 0.1.1 / 2015-04-06
2
+
3
+ * Bug Fixes
4
+ * Fixed #root_by_git when not in a git director. This would result in
5
+ `NoMethodError: undefined method 'strip' for nil:NilClass`.
6
+ * Plugin: *irb_history* Fixed IRB history for non-project sessions. All IRB
7
+ sessions that don't belong to a project are saved to `~/.irb_history`.
8
+
1
9
  ### 0.1.0 / 2015-02-18
2
10
 
3
11
  * Improvements
4
12
  * Added `Hairballs.project_root`, which tries to determine the root
5
13
  directory for the project you're working in.
6
- * Refactored configuration to Hairballs::Configuration.
14
+ * Refactored configuration to `Hairballs::Configuration`.
7
15
  * Bug Fixes
8
- * Fixed nested file completion for the `tab_completion_for_files` plugin.
9
16
  * Fixed `Hairballs::LibraryHelpers#find_latest_gem` to find the latest
10
17
  instead of the earliest.
18
+ * Plugin: *tab_completion_for_files* Fixed nested file completion.
11
19
 
12
20
  ### 0.0.1 / 2014-12-19
13
21
 
@@ -35,9 +35,6 @@ class Hairballs
35
35
  # @return [String]
36
36
  attr_reader :project_name
37
37
 
38
- # @return [String]
39
- attr_reader :project_root
40
-
41
38
  def initialize
42
39
  @themes = []
43
40
  @current_theme = nil
@@ -53,24 +50,27 @@ class Hairballs
53
50
  Hairballs::VERSION
54
51
  end
55
52
 
56
- # Is IRB getting loaded for a rails console?
53
+ # Is IRB getting loaded for a Rails console?
57
54
  #
58
55
  # @return [Boolean]
59
56
  def rails?
60
57
  ENV.has_key?('RAILS_ENV') || !!defined?(Rails)
61
58
  end
62
59
 
63
- # Name of the relative directory.
60
+ # Name of the project, if it can be determined. If not, defaults to "irb".
64
61
  #
65
62
  # @return [String]
66
63
  def project_name
67
- @project_name ||= File.basename(project_root)
64
+ @project_name ||= project_root ? project_root.basename : nil
68
65
  end
69
66
 
67
+ # @return [Pathname]
70
68
  def project_root
71
69
  @project_root ||= find_project_root
72
70
  end
73
71
 
72
+ # @param [String] path
73
+ # @return [Boolean]
74
74
  def project_root?(path)
75
75
  File.expand_path(path) == project_root
76
76
  end
@@ -137,6 +137,7 @@ class Hairballs
137
137
 
138
138
  private
139
139
 
140
+ # @return [Pathname]
140
141
  def find_project_root
141
142
  if rails?
142
143
  ::Rails.root
@@ -145,12 +146,15 @@ class Hairballs
145
146
  end
146
147
  end
147
148
 
149
+ # @return [Pathname, nil]
148
150
  def root_by_git
149
151
  _stdin, stdout, _stderr = Open3.popen3('git rev-parse --show-toplevel')
150
-
151
- stdout.gets.strip
152
+ result = stdout.gets
153
+
154
+ result.nil? ? nil : Pathname.new(result.strip)
152
155
  end
153
156
 
157
+ # @return [Pathname, nil]
154
158
  def root_by_lib_dir
155
159
  cwd = Pathname.new(Dir.pwd)
156
160
  root = nil
@@ -159,7 +163,7 @@ class Hairballs
159
163
  lib_dir = File.join(dir.to_s, 'lib')
160
164
 
161
165
  if dir.children.find { |c| c.to_s =~ /#{lib_dir}/ && File.exist?(lib_dir) }
162
- root = dir.to_s
166
+ root = Pathname.new(dir.to_s)
163
167
  break
164
168
  end
165
169
  end
@@ -7,8 +7,12 @@ Hairballs.add_plugin(:irb_history, save_history: 1000, eval_history: 20, global_
7
7
  IRB.conf[:SAVE_HISTORY] = plugin.save_history
8
8
  IRB.conf[:EVAL_HISTORY] = plugin.eval_history
9
9
 
10
- unless plugin.global_history_file
11
- IRB.conf[:HISTORY_FILE] = "#{Dir.home}/.irb_history-#{Hairballs.project_name}"
10
+ unless plugin.global_history_file && Hairballs.project_name
11
+ IRB.conf[:HISTORY_FILE] = "#{Dir.home}/.irb_history"
12
+
13
+ if Hairballs.project_name
14
+ IRB.conf[:HISTORY_FILE] << Hairballs.project_name.to_s
15
+ end
12
16
  end
13
17
 
14
18
  Object.class_eval do
@@ -21,7 +21,11 @@ Hairballs.add_theme(:turboladen) do |theme|
21
21
 
22
22
  theme.prompt do |prompt|
23
23
  preface = proc do |status = ' '|
24
- "⟪#{Hairballs.project_name.light_blue}⟫#{status}%03n"
24
+ if Hairballs.project_name
25
+ "⟪#{Hairballs.project_name.to_s.light_blue}⟫#{status}%03n"
26
+ else
27
+ "❨#{'irb'.light_blue}❩#{status}%03n"
28
+ end
25
29
  end
26
30
 
27
31
  prompt.auto_indent = true
@@ -1,3 +1,3 @@
1
1
  class Hairballs
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hairballs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Loveless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-19 00:00:00.000000000 Z
11
+ date: 2015-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.2.2
116
+ rubygems_version: 2.4.6
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Like oh-my-zsh, but for IRB.
@@ -124,4 +124,3 @@ test_files:
124
124
  - spec/hairballs/theme_spec.rb
125
125
  - spec/hairballs_spec.rb
126
126
  - spec/spec_helper.rb
127
- has_rdoc: