tryrb 1.1.1 → 1.1.2
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 +4 -4
- data/lib/tryrb/cli.rb +2 -4
- data/lib/tryrb/config.rb +5 -1
- data/lib/tryrb/version.rb +1 -1
- data/spec/config_spec.rb +10 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b3bbd8910a8e4891582adbddb650f4b6a68057a
|
4
|
+
data.tar.gz: 8bc050a0aaf2a21a5fa0f74b55dea1f71abee20d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baaee8ab40decd8fae34d8b87fcf02777f0aa397c5c4c2efdb036b67b732a9eec656df4c00c9366a8437a8a65c53ca5a113f38bf4f3e58e4ec0fefb0d37acf57
|
7
|
+
data.tar.gz: ba2e32d12e7146972d13dfdda3f1d84263470302b1264e03ae602d40ad50b08126cb0150332d286cd0eb9841e46428ca1d948bf45f939d14d685f0a29bebe296
|
data/lib/tryrb/cli.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'thor'
|
3
3
|
require 'tryrb/config'
|
4
|
+
require 'yaml'
|
4
5
|
|
5
6
|
module TryRb
|
6
7
|
class CLI < Thor
|
7
|
-
def initialize(*)
|
8
|
-
super
|
9
|
-
end
|
10
|
-
|
11
8
|
no_commands do
|
12
9
|
def conf
|
13
10
|
TryRb::Config.instance
|
@@ -56,6 +53,7 @@ module TryRb
|
|
56
53
|
filename = options[:filename]
|
57
54
|
last_n = options[:last_n] || 1
|
58
55
|
names = Dir[File.join(conf.expanded_tmp_dir, '*.rb')]
|
56
|
+
.select { |n| n =~ /\d{14}/ }
|
59
57
|
names = names.select { |n| n =~ /#{filename}\.rb$/ } if filename
|
60
58
|
names[-last_n]
|
61
59
|
end
|
data/lib/tryrb/config.rb
CHANGED
@@ -18,7 +18,7 @@ module TryRb
|
|
18
18
|
require 'yaml'
|
19
19
|
YAML.load_file(expanded_rc_path)
|
20
20
|
rescue Errno::ENOENT
|
21
|
-
|
21
|
+
print_red("Please run `tryrb config` to configure.")
|
22
22
|
abort
|
23
23
|
end
|
24
24
|
|
@@ -30,5 +30,9 @@ module TryRb
|
|
30
30
|
File.expand_path(tmp_dir)
|
31
31
|
end
|
32
32
|
|
33
|
+
private
|
34
|
+
def print_red(str)
|
35
|
+
puts "\e[31m#{str}\e[0m"
|
36
|
+
end
|
33
37
|
end
|
34
38
|
end
|
data/lib/tryrb/version.rb
CHANGED
data/spec/config_spec.rb
CHANGED
@@ -28,7 +28,7 @@ describe TryRb::Config do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
describe 'load_file' do
|
31
|
+
describe '#load_file' do
|
32
32
|
context 'when file exists at path' do
|
33
33
|
it 'loads data from the file' do
|
34
34
|
config = TryRb::Config.instance
|
@@ -37,13 +37,20 @@ describe TryRb::Config do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
context 'when file does not exist' do
|
40
|
-
it '
|
40
|
+
it 'reminds to config and abort' do
|
41
41
|
config = TryRb::Config.instance
|
42
42
|
config.stub(:expanded_rc_path) { fixture_file_path('foorc') }
|
43
43
|
expect(config).to receive(:abort)
|
44
|
-
|
44
|
+
expect(config).to receive(:puts).with("\e[31mPlease run `tryrb config` to configure.\e[0m")
|
45
45
|
config.load_file
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
describe '#expanded_rc_path' do
|
51
|
+
it 'returns right tryrbrc' do
|
52
|
+
expect(File).to receive(:expand_path).with('~/.tryrbrc')
|
53
|
+
TryRb::Config.instance.expanded_rc_path
|
54
|
+
end
|
55
|
+
end
|
49
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tryrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Han
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|