rspec_term 0.1.1 → 0.2.0

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: 4dc2ac7317a4fc8b7affcc9fd9c555e7c09ddbd8
4
- data.tar.gz: 83ab76c119e2caf44500d40d75d6dde16ca6a5dd
3
+ metadata.gz: 4aa2fd18efbc55a0012604dc1db4a29db0acdf8c
4
+ data.tar.gz: 959de5686f690486c6ad9835720d1f4efc088f39
5
5
  SHA512:
6
- metadata.gz: db8232915e4aa31818523707e3bcc3062c1e08ac8b0ab8772b208f3c11e2ef3abce4ba6b113c47ec9be1eb73e6e1ccfcd1cc21f5ba1f49f36242c3a5575d5d30
7
- data.tar.gz: 2834ed89265e28c6dd9b25ee5c3b160ee4b1a3bdd9fd5fa85f100d98f56d23a079f9412476b7ecd022e2408b0b9e66752654b563477d797c0a7a37eb6d0eec10
6
+ metadata.gz: 5fe7c7fec442adf0019dda38e000479b6c58f3db8628f0f3f4c888228aafbd3a13af587005f4006f2956bcb54e68b176bcbe1508ebf8a76ac3a1a9ac3c320417
7
+ data.tar.gz: f8f473afe1819367a2f245da59c25dcf20b353b75bd36d3cf932ffd3fb8be3844ffddd4e6c54f43b2151ed58ea57924aa8942f955464710d7d2b0e30f752b0f7
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # RspecTerm
2
- ###### ver 0.1.0
2
+ ###### ver 0.1.1
3
3
 
4
4
  RSpecの実行中や、テスト結果によってiTermの背景画像を変更する ruby gem です。
5
5
  RSpec2, RSpec3に対応しています。
@@ -9,10 +9,12 @@ class RSpecTerm::Configure
9
9
  :success_file, :success_url,
10
10
  :failure_file, :failure_url,
11
11
  :nothing_file, :nothing_url,
12
- :tmp_dir
12
+ :tmp_dir,
13
+ :process
13
14
 
14
15
  def self.configure &block
15
- block.call instance
16
+ block.call instance if block_given?
17
+ instance
16
18
  end
17
19
 
18
20
  end
@@ -45,6 +45,8 @@ class RSpecTerm::Formatters::BackgroundFormatter < RSpec::Core::Formatters::Base
45
45
  # if RSpec version is 3.0
46
46
  # then args are Notifications::StartNotification
47
47
  def start *args
48
+ return unless iterm?
49
+
48
50
  init
49
51
 
50
52
  unless @error_message
@@ -61,6 +63,8 @@ class RSpecTerm::Formatters::BackgroundFormatter < RSpec::Core::Formatters::Base
61
63
  # if RSpec version is 3.0
62
64
  # then args are Notifications::SummaryNotification
63
65
  def dump_summary *args
66
+ return unless iterm?
67
+
64
68
  if args.count == 4
65
69
  notification = Struct.new(:duration, :example_count, :failure_count, :pending_count).new *args
66
70
  else
@@ -109,6 +113,28 @@ class RSpecTerm::Formatters::BackgroundFormatter < RSpec::Core::Formatters::Base
109
113
  tmp
110
114
  end
111
115
 
116
+ def iterm?
117
+ return @iterm unless @iterm.nil?
118
+ (ret, pattern) = if @config.process
119
+ [`ps -e`, @config.process]
120
+ else
121
+ [`ps -e | grep "Term"`, /\/iTerm\z/]
122
+ end
123
+ @iterm = if ret.is_a? String
124
+ ret.each_line.any? do |line|
125
+ words = line.split(/\s+/)
126
+ next if words.count < 4
127
+ if pattern.is_a? String
128
+ words[3] == pattern
129
+ else
130
+ words[3] =~ pattern
131
+ end
132
+ end
133
+ else
134
+ false
135
+ end
136
+ end
137
+
112
138
  def change_background file
113
139
  cmd = <<-EOS
114
140
  /usr/bin/osascript <<-EOF
@@ -1,3 +1,3 @@
1
1
  module RspecTerm
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/rspec_term.rb CHANGED
@@ -7,13 +7,14 @@ module RSpecTerm
7
7
  autoload :Formatters, 'rspec_term/formatters'
8
8
 
9
9
  def self.configure &block
10
- Configure.configure &block
10
+ Configure.configure &block if block_given?
11
+ Configure.configure
11
12
  end
12
13
 
13
14
  end
14
15
 
15
16
  RSpec.configure do |config|
16
- formatter = RSpecTerm::Formatters::BackgroundFormatter.new RSpecTerm::Configure.instance
17
+ formatter = RSpecTerm::Formatters::BackgroundFormatter.new RSpecTerm.configure
17
18
  config.reporter.register_listener(formatter, :start, :dump_summary)
18
19
  end
19
20
 
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ module RSpecTerm
4
+
5
+ autoload :Configure, 'rspec_term/configure'
6
+
7
+ autoload :Formatters, 'rspec_term/formatters'
8
+
9
+ def self.configure &block
10
+ Configure.configure &block
11
+ end
12
+
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ formatter = RSpecTerm::Formatters::BackgroundFormatter.new RSpecTerm::Configure.instance
17
+ config.reporter.register_listener(formatter, :start, :dump_summary)
18
+ end
19
+
@@ -7,6 +7,7 @@ describe RSpecTerm do
7
7
  it "arguments" do
8
8
  expect{ RSpecTerm::Configure.new }.to raise_error
9
9
  expect(RSpecTerm::Configure.instance).not_to be_nil
10
+ expect(RSpecTerm.configure).to be RSpecTerm::Configure.instance
10
11
  methods = [
11
12
  :success_file, :success_file=,
12
13
  :success_url, :success_url=,
@@ -16,9 +17,11 @@ describe RSpecTerm do
16
17
  :failure_url, :failure_url=,
17
18
  :nothing_file, :nothing_file=,
18
19
  :nothing_url, :nothing_url=,
19
- :tmp_dir, :tmp_dir=
20
+ :tmp_dir, :tmp_dir=,
21
+ :process, :process=
20
22
  ]
21
23
  expect(methods - RSpecTerm::Configure.instance_methods).to eq []
24
+ expect(methods - RSpecTerm.configure.methods).to eq []
22
25
  end
23
26
  end
24
27
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_term
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - brightgenerous
@@ -55,6 +55,7 @@ files:
55
55
  - lib/rspec_term/formatters.rb
56
56
  - lib/rspec_term/formatters/background_formatter.rb
57
57
  - lib/rspec_term/version.rb
58
+ - lib/rspec_term_core.rb
58
59
  - rspec_term.gemspec
59
60
  - spec/pleasures/failure_spec_pleasure.rb
60
61
  - spec/pleasures/nothing_spec_pleasure.rb