confinicky 0.1.6 → 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 +4 -4
- data/README.md +2 -2
- data/confinicky.gemspec +14 -6
- data/lib/confinicky/commands/clean.rb +26 -8
- data/lib/confinicky/commands/duplicates.rb +31 -9
- data/lib/confinicky/commands/inspect.rb +26 -0
- data/lib/confinicky/commands/list.rb +21 -16
- data/lib/confinicky/commands/remove.rb +27 -13
- data/lib/confinicky/commands/set.rb +27 -16
- data/lib/confinicky/commands/setup.rb +25 -0
- data/lib/confinicky/commands.rb +2 -1
- data/lib/confinicky/config.rb +15 -2
- data/lib/confinicky/configuration_file.rb +89 -0
- data/lib/confinicky/controllers/aliases.rb +23 -0
- data/lib/confinicky/controllers/commands.rb +182 -0
- data/lib/confinicky/controllers/exports.rb +35 -0
- data/lib/confinicky/parsers/command.rb +98 -0
- data/lib/confinicky/parsers/expression.rb +93 -0
- data/lib/confinicky/shell_file.rb +28 -75
- data/lib/confinicky/version.rb +2 -2
- data/lib/confinicky.rb +7 -1
- data/test/test_command_parser.rb +44 -0
- data/test/test_controllers.rb +64 -0
- data/test/{test_confinicky.rb → test_shell_file_parsing.rb} +5 -5
- metadata +13 -5
- data/lib/confinicky/commands/use.rb +0 -27
- data/test/test_file_writing.rb +0 -41
@@ -1,15 +1,11 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestShellFileParsing < MiniTest::Test
|
4
4
|
|
5
5
|
def setup
|
6
6
|
@shell_file = Confinicky::ShellFile.new(file_path: 'test/sample_bash_file.sh')
|
7
7
|
end
|
8
8
|
|
9
|
-
def test_shell_file_duplicates
|
10
|
-
assert_equal 1, @shell_file.find_duplicates.length
|
11
|
-
end
|
12
|
-
|
13
9
|
def test_exports_without_assignments
|
14
10
|
assert_includes @shell_file.lines, "export DISPLAY\n"
|
15
11
|
end
|
@@ -18,4 +14,8 @@ class TestConfinicky < MiniTest::Test
|
|
18
14
|
assert_equal 18, @shell_file.exports.length
|
19
15
|
end
|
20
16
|
|
17
|
+
def test_detects_aliases_with_assignment
|
18
|
+
assert_equal 32, @shell_file.aliases.length
|
19
|
+
end
|
20
|
+
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confinicky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Jeffers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -131,17 +131,25 @@ files:
|
|
131
131
|
- lib/confinicky/commands.rb
|
132
132
|
- lib/confinicky/commands/clean.rb
|
133
133
|
- lib/confinicky/commands/duplicates.rb
|
134
|
+
- lib/confinicky/commands/inspect.rb
|
134
135
|
- lib/confinicky/commands/list.rb
|
135
136
|
- lib/confinicky/commands/remove.rb
|
136
137
|
- lib/confinicky/commands/set.rb
|
137
|
-
- lib/confinicky/commands/
|
138
|
+
- lib/confinicky/commands/setup.rb
|
138
139
|
- lib/confinicky/config.rb
|
140
|
+
- lib/confinicky/configuration_file.rb
|
141
|
+
- lib/confinicky/controllers/aliases.rb
|
142
|
+
- lib/confinicky/controllers/commands.rb
|
143
|
+
- lib/confinicky/controllers/exports.rb
|
144
|
+
- lib/confinicky/parsers/command.rb
|
145
|
+
- lib/confinicky/parsers/expression.rb
|
139
146
|
- lib/confinicky/shell_file.rb
|
140
147
|
- lib/confinicky/version.rb
|
141
148
|
- test/helper.rb
|
142
149
|
- test/sample_bash_file.sh
|
143
|
-
- test/
|
144
|
-
- test/
|
150
|
+
- test/test_command_parser.rb
|
151
|
+
- test/test_controllers.rb
|
152
|
+
- test/test_shell_file_parsing.rb
|
145
153
|
homepage: http://github.com/jimjeffers/confinicky
|
146
154
|
licenses:
|
147
155
|
- MIT
|
@@ -1,27 +0,0 @@
|
|
1
|
-
command :use do |c|
|
2
|
-
c.syntax = 'confinicky use'
|
3
|
-
c.summary = 'Appends the confinicky file path shell variable to your configuration.'
|
4
|
-
c.description = ''
|
5
|
-
c.example 'description', 'cfy use /User/[YOUR_USER_NAME]/.bashrc'
|
6
|
-
|
7
|
-
c.action do |args, options|
|
8
|
-
@file_path = args.first
|
9
|
-
|
10
|
-
if @file_path.nil?
|
11
|
-
say_error "You must specify a path. See example:"
|
12
|
-
puts 'cfy use /User/[YOUR_USER_NAME]/.bashrc'
|
13
|
-
abort
|
14
|
-
end
|
15
|
-
|
16
|
-
say_error "Could not locate '#{@file_path}'." and abort if !File.exist?(@file_path)
|
17
|
-
|
18
|
-
open(@file_path, 'a') { |f|
|
19
|
-
f.puts "export #{Confinicky::FILE_PATH_VAR}=#{@file_path}"
|
20
|
-
}
|
21
|
-
|
22
|
-
say_ok "Set #{Confinicky::FILE_PATH_VAR} to #{@file_path}"
|
23
|
-
if ENV[Confinicky::FILE_PATH_VAR].nil?
|
24
|
-
puts "Run 'source #{@file_path}' or open a new terminal/shell window."
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/test/test_file_writing.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
class TestFileWriting < MiniTest::Test
|
5
|
-
|
6
|
-
def setup
|
7
|
-
FileUtils.cp 'test/sample_bash_file.sh', 'test/sample_bash_file.sh.tmp'
|
8
|
-
@shell_file = Confinicky::ShellFile.new(file_path: 'test/sample_bash_file.sh.tmp')
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_clean_file
|
12
|
-
@shell_file.clean!
|
13
|
-
assert_equal 17, @shell_file.exports.length
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_add_var
|
17
|
-
@shell_file.set!("NEW_VAR=12345")
|
18
|
-
assert_equal 19, @shell_file.exports.length
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_remove_var
|
22
|
-
@shell_file.remove!("PATH")
|
23
|
-
assert_equal 16, @shell_file.exports.length
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_add_var_should_not_duplicate
|
27
|
-
@shell_file.set!("NEW_VAR=12345")
|
28
|
-
@shell_file.set!("NEW_VAR=123456")
|
29
|
-
assert_equal 19, @shell_file.exports.length
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_whitespace
|
33
|
-
@shell_file.set!("NEW_STRING=A String")
|
34
|
-
assert_equal 1, @shell_file.exports.delete_if{|i| i[1] != "\'A String\'"}.length
|
35
|
-
end
|
36
|
-
|
37
|
-
def teardown
|
38
|
-
FileUtils.rm 'test/sample_bash_file.sh.tmp'
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|