thor-zsh_completion 0.1.1 → 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd91ee306a415b0689fcdb5f58ad3c52f1d049e1
4
+ data.tar.gz: 692e2d425ff2779550b3d2b5e0edd13de418262b
5
+ SHA512:
6
+ metadata.gz: 638a502306f9c061ee9f1d3689a497709e414227829430341aa7c66a73f9bca56a038d8882b947d3498f7d89d775f942b3914b21255de240466d4f28052e9910
7
+ data.tar.gz: d17f7a4fd9339fec15f08951af2cecbef1af08147febc75e89a4c9aa1cdcc9858bff8787a30a939cab9b45a6deb8e2cd9dd2dd8d4a149954cb46def2c840b81b
data/README.md CHANGED
@@ -69,6 +69,11 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
69
69
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
70
70
 
71
71
 
72
+ ### Testing completion script
73
+
74
+ source spec/thor/zsh_completion/generator_spec.zsh
75
+ generator_spec [TAB]
76
+
72
77
  ## Contributing
73
78
 
74
79
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/thor-zsh_completion. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
@@ -93,6 +93,23 @@ class Thor
93
93
  description: option.description,
94
94
  }
95
95
  end
96
+
97
+ def quote(s)
98
+ escaped = s.gsub(/'/, "''")
99
+ %('#{escaped}')
100
+ end
101
+
102
+ def bracket(s)
103
+ %([#{s}])
104
+ end
105
+
106
+ def escape_option_names(names)
107
+ if names.size == 1
108
+ names.first
109
+ else
110
+ "{" + names.join(",") + "}"
111
+ end
112
+ end
96
113
  end
97
114
  end
98
115
  end
@@ -6,7 +6,7 @@
6
6
  $DEPTH)
7
7
  _arguments \
8
8
  <%- subcommand[:options].each do |option| -%>
9
- {<%= option[:names].join(",") %>}<%= option[:description].gsub(/'/, "''") if option[:description] %> \
9
+ <%= escape_option_names(option[:names]) %><%= quote(bracket(option[:description])) if option[:description] %> \
10
10
  <%- end -%>
11
11
  '*: :->subcommands'
12
12
 
@@ -15,7 +15,7 @@
15
15
  _values \
16
16
  'subcommand' \
17
17
  <%- subcommand[:subcommands].each do |subcommand| -%>
18
- '<%= subcommand[:name] %>[<%= subcommand[:description].gsub(/'/, "''") %>]' \
18
+ <%= quote(subcommand[:name] + bracket(subcommand[:description])) %> \
19
19
  <%- end -%>
20
20
  ;
21
21
  ;;
@@ -41,7 +41,7 @@
41
41
  <%= function_name %>() {
42
42
  _arguments \
43
43
  <%- subcommand[:options].each do |option| -%>
44
- {<%= option[:names].join(",") %>}<%= option[:description].gsub(/'/, "''") if option[:description] %> \
44
+ <%= escape_option_names(option[:names]) %><%= quote(bracket(option[:description])) if option[:description] %> \
45
45
  <%- end -%>
46
46
  '*: :->rest'
47
47
 
@@ -1,5 +1,5 @@
1
1
  class Thor
2
2
  module ZshCompletion
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thor-zsh_completion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - labocho
9
8
  autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2016-01-28 00:00:00.000000000 Z
11
+ date: 2017-03-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.10'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.10'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '10.0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '10.0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: Create zsh completion script for Thor subclass
@@ -66,9 +59,9 @@ executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
- - .gitignore
70
- - .rspec
71
- - .travis.yml
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
72
65
  - CODE_OF_CONDUCT.md
73
66
  - Gemfile
74
67
  - LICENSE.txt
@@ -86,26 +79,25 @@ files:
86
79
  homepage: https://github.com/labocho/thor-zsh_completion
87
80
  licenses:
88
81
  - MIT
82
+ metadata: {}
89
83
  post_install_message:
90
84
  rdoc_options: []
91
85
  require_paths:
92
86
  - lib
93
87
  required_ruby_version: !ruby/object:Gem::Requirement
94
- none: false
95
88
  requirements:
96
- - - ! '>='
89
+ - - ">="
97
90
  - !ruby/object:Gem::Version
98
91
  version: '0'
99
92
  required_rubygems_version: !ruby/object:Gem::Requirement
100
- none: false
101
93
  requirements:
102
- - - ! '>='
94
+ - - ">="
103
95
  - !ruby/object:Gem::Version
104
96
  version: '0'
105
97
  requirements: []
106
98
  rubyforge_project:
107
- rubygems_version: 1.8.23.2
99
+ rubygems_version: 2.6.10
108
100
  signing_key:
109
- specification_version: 3
101
+ specification_version: 4
110
102
  summary: Create zsh completion script for Thor subclass
111
103
  test_files: []