vim_printer 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5db6c8f84609703178fb48f9917034197fe3a0f3
4
- data.tar.gz: 7e764609c4a0860849ac65cfb9e57e2195886439
3
+ metadata.gz: 8e112f2fc25ae31c97cc8df1dc09168fa5934bd5
4
+ data.tar.gz: fb5772428a7b8868cf0ce7adce87c4c1107a3496
5
5
  SHA512:
6
- metadata.gz: ee03cbf46d41b1e06a9d3d0c92532471f663de84fd06c038f72872e64c75d84a2078d0305a349c466895a486c065ae842d621f54a7c344b3f9a3d74f46fb3556
7
- data.tar.gz: 38485f6aec3fd9f5340804b71fcb9d370c258bc4ab6d07d6dd7adeb015abde08319912042f59a0d1b9d8ad29c9db6e9f13c810cbe53bc7efc6afca38ea200c73
6
+ metadata.gz: 6e8cdd0bfa89eba6960496219de7831f0c3bab4b418e3e6cbee24f631b40e255a35ae98766cba5f949cfba38c0655fbcdd700e299638ffac3874d84d915f05a0
7
+ data.tar.gz: bbb3ad595c2b44e1ed902c008450a9d707293fe9a7d06b0fe6271eaf96dd061ebc9ac924eb55649dd71a76b1f34d3f18263cb948a00c394d9538145858abc0e7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ### Changelog
2
2
 
3
+ #### 0.1.10
4
+
5
+ - Rename `--shell-command` to `--command` [Improvement]
6
+ - Move the logic to `code_lister` gem
7
+
3
8
  #### 0.1.9
4
9
 
5
10
  - Add advance `--shell_command` option to get the input file list from the the shell command [New]
data/README.md CHANGED
@@ -134,9 +134,9 @@ Usage:
134
134
  vim_printer
135
135
 
136
136
  Options:
137
- -b, [--base-dir=BASE_DIR] # Base directory (mandatory)
137
+ -b, [--base-dir=BASE_DIR] # Base directory
138
138
  # Default: . (current directory)
139
- -e, [--exts=one two three] # List of extension to search for (mandatory)
139
+ -e, [--exts=one two three] # List of extension to search for
140
140
  # e.g. -e rb md
141
141
  -f, [--non-exts=one two three] # List of file without extension to be included in the result (optional)
142
142
  # e.g. -f Gemfile LICENSE
@@ -151,16 +151,18 @@ Options:
151
151
  -r, [--recursive], [--no-recursive] # Search for files recursively (optional)
152
152
  # Default: --recursive
153
153
  -v, [--version] # Display version information
154
+ #
154
155
  -t, [--theme=THEME] # Vim colorscheme to use (optional)
155
156
  # Default: 'default'
156
157
  -c, [--index], [--no-index] # Generate the index.html file for the result (optional)
157
158
  # Default: --index
158
- -s, [--shell-command] # Use the input file list from the result of the given shell command (optional)
159
- # Note: the command must be result in the list of files
159
+ -s, [--command] # Use the input file list from the result of the given shell command
160
+ # Note: the command must return the list of file to be valid
160
161
  # This option ignore any of the following options -e, -f, -n, -x, -i if specified
161
- # e.g. --shell-command 'git diff --name-only HEAD~2 | grep -v test'
162
- # e.g. --shell-command 'find . -type f -iname "*.rb" | grep -v test'
162
+ # e.g. --command 'git diff --name-only HEAD~2 | grep -v test'
163
+ # e.g. --command 'find . -type f -iname "*.rb" | grep -v test | grep -v _spec'
163
164
  Print files to (x)html using Vim
165
+
164
166
  ```
165
167
 
166
168
  ### Customization for output options
@@ -26,10 +26,9 @@ module VimPrinter
26
26
  desc: "Generate the index.html file for the result",
27
27
  type: :boolean,
28
28
  default: true
29
- method_option :shell_command,
29
+ method_option :command,
30
30
  aliases: "-s",
31
- desc: "Use input file list from the result of the given shell command",
32
- type: :string
31
+ desc: "Use input file list from the result of the given shell command"
33
32
  def print
34
33
  opts = options.symbolize_keys
35
34
  if opts[:version]
@@ -46,9 +45,9 @@ Usage:
46
45
  vim_printer
47
46
 
48
47
  Options:
49
- -b, [--base-dir=BASE_DIR] # Base directory (mandatory)
48
+ -b, [--base-dir=BASE_DIR] # Base directory
50
49
  # Default: . (current directory)
51
- -e, [--exts=one two three] # List of extension to search for (mandatory)
50
+ -e, [--exts=one two three] # List of extension to search for
52
51
  # e.g. -e rb md
53
52
  -f, [--non-exts=one two three] # List of file without extension to be included in the result (optional)
54
53
  # e.g. -f Gemfile LICENSE
@@ -63,15 +62,16 @@ Options:
63
62
  -r, [--recursive], [--no-recursive] # Search for files recursively (optional)
64
63
  # Default: --recursive
65
64
  -v, [--version] # Display version information
65
+ #
66
66
  -t, [--theme=THEME] # Vim colorscheme to use (optional)
67
67
  # Default: 'default'
68
68
  -c, [--index], [--no-index] # Generate the index.html file for the result (optional)
69
69
  # Default: --index
70
- -s, [--shell-command] # Use the input file list from the result of the given shell command (optional)
71
- # Note: the command must be result in the list of files
70
+ -s, [--command] # Use the input file list from the result of the given shell command
71
+ # Note: the command must return the list of file to be valid
72
72
  # This option ignore any of the following options -e, -f, -n, -x, -i if specified
73
- # e.g. --shell-command 'git diff --name-only HEAD~2 | grep -v test'
74
- # e.g. --shell-command 'find . -type f -iname "*.rb" | grep -v test | grep -v _spec'
73
+ # e.g. --command 'git diff --name-only HEAD~2 | grep -v test'
74
+ # e.g. --command 'find . -type f -iname "*.rb" | grep -v test | grep -v _spec'
75
75
  Print files to (x)html using Vim
76
76
  EOS
77
77
  end
@@ -81,49 +81,20 @@ Print files to (x)html using Vim
81
81
 
82
82
  private
83
83
 
84
- # Get the appropriate input from the options
84
+ # Get the list of input file
85
85
  #
86
86
  # @param [Hash<Symbol, Object>] args the input options
87
- # @option args [String] :shell_input the shell input string if any
87
+ # @option args [String] :command the shell command to be used to get list of files
88
88
  # @return [Array<String>] list of files in the format
89
- #
90
- # ["./Gemfile", "./lib/vim_printer/cli.rb", ..]
89
+ # ["./Gemfile", "./lib/vim_printer/cli.rb", ..]
91
90
  def get_input_files(args = {})
92
- shell_command = args.fetch(:shell_command, nil)
93
- if shell_command.nil?
94
- # use other options if we don't use the '--shell-input' option
91
+ command = args.fetch(:command, nil)
92
+ base_dir = args[:base_dir]
93
+ if command.nil?
95
94
  CodeLister.files(args)
96
95
  else
97
- files_from_shell_command(shell_command, args[:base_dir])
98
- end
99
- end
100
-
101
- # Execute the command in the shell and return the output list for use
102
- # e.g. `git diff --name-only HEAD~1` is getting the list of files that have been
103
- # updated in the last commit
104
- #
105
- # @param [String] shell_input the input command to be executed in the shell
106
- # @param [String] base_dir the starting directory
107
- # @return [Array<String>] file list or empty list if the shell command is not valid
108
- def files_from_shell_command(command, base_dir)
109
- files = AgileUtils::Helper.shell(command.split(" ")).split(/\n/)
110
- # Adapt the result and make sure that it start with "./"
111
- # like the result from 'CodeLister.files()' method
112
- files.map! do |file|
113
- if file =~ /^\.\//
114
- # skip if the file start with './' string
115
- file
116
- else
117
- # add './' to the one that does not already have one
118
- "./#{file}"
119
- end
96
+ CodeLister.files_from_command(command, base_dir)
120
97
  end
121
- # Note: this make sure that it work with deleted file when use
122
- # this with 'git diff --name-only HEAD~2'
123
- files.delete_if { |file| !File.exist?(file.gsub(/^\./, base_dir)) }
124
- rescue RuntimeError => e
125
- # just return the empty list, if the user specified invalid command for 'shell_input' option
126
- return []
127
98
  end
128
99
 
129
100
  # Main entry point to export the code
@@ -1,3 +1,3 @@
1
1
  module VimPrinter
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
data/vim_printer.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.test_files = Dir.glob("{test}/**/*")
25
25
  spec.require_paths = ["lib"]
26
26
  spec.add_runtime_dependency "thor", "~> 0.19"
27
- spec.add_runtime_dependency "code_lister", "~> 0.1"
27
+ spec.add_runtime_dependency "code_lister", "~> 0.1.3"
28
28
  spec.add_runtime_dependency "index_html", "~> 0.1"
29
29
  spec.add_runtime_dependency "agile_utils", "~> 0.1"
30
30
  spec.add_development_dependency "bundler", "~> 1.3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vim_printer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burin Choomnuan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-13 00:00:00.000000000 Z
11
+ date: 2014-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.1'
33
+ version: 0.1.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.1'
40
+ version: 0.1.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: index_html
43
43
  requirement: !ruby/object:Gem::Requirement