shell_helpers 0.1.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  module ShellHelpers
2
2
  # shell_helpers version
3
- VERSION = "0.1.0"
3
+ VERSION = "0.6.0"
4
4
  end
@@ -24,6 +24,16 @@ Gem::Specification.new do |gem|
24
24
  glob = lambda { |patterns| gem.files & Dir[*patterns] }
25
25
 
26
26
  gem.files = `git ls-files`.split($/)
27
+
28
+ `git submodule --quiet foreach --recursive pwd`.split($/).each do |submodule|
29
+ submodule.sub!("#{Dir.pwd}/",'')
30
+
31
+ Dir.chdir(submodule) do
32
+ `git ls-files`.split($/).map do |subpath|
33
+ gem.files << File.join(submodule,subpath)
34
+ end
35
+ end
36
+ end
27
37
  gem.files = glob[gemspec['files']] if gemspec['files']
28
38
 
29
39
  gem.executables = gemspec.fetch('executables') do
@@ -38,7 +48,7 @@ Gem::Specification.new do |gem|
38
48
  %w[ext lib].select { |dir| File.directory?(dir) }
39
49
  })
40
50
 
41
- gem.requirements = gemspec['requirements']
51
+ gem.requirements = Array(gemspec['requirements'])
42
52
  gem.required_ruby_version = gemspec['required_ruby_version']
43
53
  gem.required_rubygems_version = gemspec['required_rubygems_version']
44
54
  gem.post_install_message = gemspec['post_install_message']
@@ -56,4 +66,6 @@ Gem::Specification.new do |gem|
56
66
  gem.add_development_dependency(name,split[versions])
57
67
  end
58
68
  end
69
+
70
+ gem.metadata['yard.run']='yri'
59
71
  end
data/test/helper.rb CHANGED
@@ -1,2 +1,13 @@
1
- require 'rubygems'
2
1
  require 'minitest/autorun'
2
+
3
+ ## Uncomment to launch pry on a failure
4
+ #require 'pry-rescue/minitest'
5
+
6
+ begin
7
+ require 'minitest/reporters'
8
+ Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new
9
+ #Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
10
+ #Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new
11
+ rescue LoadError => error
12
+ warn "minitest/reporters not found, not changing minitest reporter: #{error}"
13
+ end
@@ -0,0 +1,77 @@
1
+ require 'helper'
2
+ require 'shell_helpers'
3
+
4
+ describe SH::Export do
5
+ it "can export a value" do
6
+ SH.export_value("foo").must_equal "foo"
7
+ SH.export_value(["foo","bar"]).must_equal "(foo bar)"
8
+ SH.export_value(["foo","bar"]).must_equal "(foo bar)"
9
+ SH.export_value(Set.new(["foo","bar"])).must_equal "(foo bar)"
10
+ SH.export_value({foo:"bar"}).must_equal "(foo bar)"
11
+ end
12
+
13
+ it "can escape a shell name" do
14
+ #foo/bar get interpreted as FOO_BAR
15
+ SH.escape_name("foo/bar").must_equal("FOO_BAR")
16
+ SH.escape_name("foo",prefix:"ploum",upcase:false).must_equal("ploumfoo")
17
+ end
18
+
19
+ it "can export a variable" do
20
+ SH.export_variable("foo","baz").must_equal "FOO=baz\n"
21
+ SH.export_variable("foo","baz",local:true,export:true).must_equal "local FOO\nFOO=baz\nexport FOO\n"
22
+ SH.export_variable("foo",{bar:"baz"}).must_equal "typeset -A FOO\nFOO=(bar baz)\n"
23
+ end
24
+
25
+ it "can export a hash" do
26
+ SH.export_variables({foo:"bar",ploum:"plam"}).must_equal "FOO=bar\nPLOUM=plam\n"
27
+ end
28
+
29
+ it "can select which keys to export" do
30
+ h={ploum: "plam", foo: {a: 1, b:2}}
31
+ SH.export_parse(h,"ploum").must_equal "PLOUM=plam\n"
32
+ SH.export_parse(h,:ploum).must_equal "PLOUM=plam\n"
33
+ #can select a hash in a hash
34
+ SH.export_parse(h,"foo/a").must_equal "FOO_A=1\n"
35
+ #can export severable variables
36
+ SH.export_parse(h,"ploum,foo/a").must_equal "PLOUM=plam\nFOO_A=1\n"
37
+ #can name the variables
38
+ SH.export_parse(h,"var:ploum").must_equal "VAR=plam\n"
39
+ SH.export_parse(h,"var2:foo/a").must_equal "VAR2=1\n"
40
+ SH.export_parse(h,"var:ploum,foo/a").must_equal "VAR=plam\nFOO_A=1\n"
41
+ #can export values by ending with /
42
+ SH.export_parse(h,"foo/").must_equal "A=1\nB=2\n"
43
+ #can select a prefix for the values
44
+ SH.export_parse(h,"prefix_:foo/").must_equal "prefix_A=1\nprefix_B=2\n"
45
+ #use '/' to select the whole hash
46
+ SH.export_parse(h,"/").must_equal "typeset -A ALL\nALL=(ploum plam foo \\{:a\\=\\>1,\\ :b\\=\\>2\\})\n"
47
+ #use '//' to export values in the whole hash
48
+ SH.export_parse(h,"//").must_equal "PLOUM=plam\ntypeset -A FOO\nFOO=(a 1 b 2)\n"
49
+ SH.export_parse(h,"prefix_://").must_equal "prefix_PLOUM=plam\ntypeset -A prefix_FOO\nprefix_FOO=(a 1 b 2)\n"
50
+ #can have options
51
+ SH.export_parse(h,"ploum!local!export").must_equal "local PLOUM\nPLOUM=plam\nexport PLOUM\n"
52
+ #use !! for global options
53
+ SH.export_parse(h,"ploum!local,var:foo/a!!export").must_equal "local PLOUM\nPLOUM=plam\nexport PLOUM\nVAR=1\nexport VAR\n"
54
+ end
55
+
56
+ it "can import a value" do
57
+ SH.import_value("foo").must_equal "foo"
58
+ SH.import_value("foo", type: Symbol).must_equal :foo
59
+ SH.import_value("(foo bar)", type: Array).must_equal %w(foo bar)
60
+ SH.import_value("(foo bar)", type: Hash).must_equal({"foo"=>"bar"})
61
+ end
62
+
63
+ it "can import a variable" do
64
+ SH.import_variable("foo=bar").must_equal ["foo","bar"]
65
+ SH.import_variable("foo='bar'").must_equal ["foo","bar"]
66
+ SH.import_variable("foo=(bar baz)").must_equal ["foo",%w(bar baz)]
67
+ end
68
+
69
+ it "can import instructions" do
70
+ SH.import_parse("foo=bar,ploum=plim").must_equal({foo: "bar", ploum: "plim"})
71
+ SH.import_parse(<<EOS).must_equal({foo: "bar", ploum: %w(plim plam)})
72
+ foo=bar
73
+ ploum=(plim plam)
74
+ EOS
75
+ SH.import_parse("foo/bar=baz,ploum=plim").must_equal({foo: {bar: "baz"}, ploum: "plim"})
76
+ end
77
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shell_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Robert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-24 00:00:00.000000000 Z
11
+ date: 2018-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: drain
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: '0.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.1'
26
+ version: '0.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rubygems-tasks
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,35 +84,46 @@ description: 'Collection of script to ease working with the shell with ruby.
70
84
 
71
85
  '
72
86
  email: Damien.Olivier.Robert+gems@gmail.com
73
- executables: []
87
+ executables:
88
+ - abs_to_rel.rb
89
+ - mv_and_ln.rb
74
90
  extensions: []
75
91
  extra_rdoc_files:
76
92
  - ChangeLog.md
77
93
  - LICENSE.txt
78
94
  - README.md
79
95
  files:
80
- - ".document"
81
96
  - ".gitignore"
97
+ - ".travis.yml"
82
98
  - ".yardopts"
83
99
  - ChangeLog.md
100
+ - Gemfile
84
101
  - LICENSE.txt
85
102
  - README.md
86
103
  - Rakefile
104
+ - TODO
105
+ - bin/abs_to_rel.rb
106
+ - bin/mv_and_ln.rb
87
107
  - gemspec.yml
88
108
  - lib/shell_helpers.rb
109
+ - lib/shell_helpers/export.rb
89
110
  - lib/shell_helpers/logger.rb
111
+ - lib/shell_helpers/options.rb
90
112
  - lib/shell_helpers/pathname.rb
91
113
  - lib/shell_helpers/run.rb
92
114
  - lib/shell_helpers/sh.rb
115
+ - lib/shell_helpers/sysutils.rb
93
116
  - lib/shell_helpers/utils.rb
94
117
  - lib/shell_helpers/version.rb
95
118
  - shell_helpers.gemspec
96
119
  - test/helper.rb
120
+ - test/test_export.rb
97
121
  - test/test_shell_helpers.rb
98
122
  homepage: https://github.com/DamienRobert/shell_helpers#readme
99
123
  licenses:
100
124
  - MIT
101
- metadata: {}
125
+ metadata:
126
+ yard.run: yri
102
127
  post_install_message:
103
128
  rdoc_options: []
104
129
  require_paths:
@@ -115,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
140
  version: '0'
116
141
  requirements: []
117
142
  rubyforge_project:
118
- rubygems_version: 2.4.5
143
+ rubygems_version: 2.7.7
119
144
  signing_key:
120
145
  specification_version: 4
121
146
  summary: Shell Helpers
data/.document DELETED
@@ -1,3 +0,0 @@
1
- -
2
- ChangeLog.md
3
- LICENSE.txt