irep 0.1.0 → 0.1.1

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: 4005baa72a957f7853bff71888934e4ae7d0c847
4
- data.tar.gz: 6b176c486806eff73de640603beac48f5f2f5d43
3
+ metadata.gz: 3c63f5fea943cedefdde0959f35b308e3779e124
4
+ data.tar.gz: ffaa7b26938f4aea6107b1a9b44be17fb62b9b21
5
5
  SHA512:
6
- metadata.gz: fac2b782bcf6b62569be486a330291dcf449c84b444e80c84d4fe112eee80ea711823cde0e530bdbb820c927e089be3991627d9ee9079bc822f702c9224a0738
7
- data.tar.gz: e735dcc4e556fec768dca48aa266829e23047b723556b8d42ccb95303d9fb5a66495e3c6b4375f053ee5fd269ea97875a93da1a73aad7a8f0f8aac3d7e58bab4
6
+ metadata.gz: 764d0c1932a8eadceffb5bdeff0d5459784c1a35f3095ce9cffda1546423bf42bfbd3d523620371933f188b93ffa5c3dd4d4bcb14ab53fe39001eee956e208ee
7
+ data.tar.gz: 0c0835d41a0624e3bb8bc1f626dc7d6628817121512fd90e7410973c544f80458aea05a852ac60c42b39fc0217b13b2797877d6a25767942d642770037118781
data/README.md CHANGED
@@ -1,23 +1,36 @@
1
1
  # Irep
2
2
 
3
- *This project is under development...*
3
+ A code searching and interactive replacing tool on CLI.
4
4
 
5
- ## Installation
5
+ <!--
6
+ TODO: Write Features.
7
+ ## Features
8
+ -->
6
9
 
7
- Install it yourself as:
10
+ ## Installation
8
11
 
9
12
  $ gem install irep
10
13
 
11
14
  ## Usage
12
15
 
13
- TODO: Write usage instructions here
14
-
15
- ## Development
16
+ # Search and interactive replace text from current directory recursively.
17
+ $ irep before after
16
18
 
17
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
19
+ # Search and replace text with some options.
20
+ $ irep OPTIONs before after
18
21
 
19
- 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).
22
+ # Display help.
23
+ $ irep --help
24
+ Usage: irep [options]
25
+ --[no-]replace
26
+ --path VAL
20
27
 
21
28
  ## Contributing
22
29
 
23
30
  Bug reports and pull requests are welcome on GitHub at https://github.com/shuuuuun/irep.
31
+
32
+ ## License
33
+
34
+ Copyright (c) 2017 shuuuuun
35
+ Released under the MIT license
36
+ http://opensource.org/licenses/mit-license.php
data/bin/console CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "irep"
3
+ require 'bundler/setup'
4
+ require 'pry'
5
+ require 'irep'
5
6
 
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
7
+ def irep(argv='')
8
+ Irep::CLI.execute(STDOUT, argv)
9
+ end
8
10
 
9
- require "pry"
10
11
  Pry.start
data/irep.gemspec CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["motoki-shun"]
10
10
  spec.email = ["shuuuuuny@gmail.com"]
11
11
 
12
- spec.summary = "" # %q{TODO: Write a short summary, because Rubygems requires one.}
13
- spec.description = "" # %q{TODO: Write a longer description or delete this line.}
14
- spec.homepage = "" # "TODO: Put your gem's website or public repo URL here."
12
+ spec.summary = 'A code searching and interactive replacing tool on CLI.'
13
+ spec.homepage = 'https://github.com/shuuuuun/irep'
14
+ spec.license = 'MIT'
15
15
 
16
16
  if spec.respond_to?(:metadata)
17
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
data/lib/irep/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'optparse'
2
+ require 'irep/version'
2
3
  require 'irep/search'
3
4
  require 'irep/replace'
4
5
  require 'irep/interface'
@@ -6,16 +7,16 @@ require 'irep/interface'
6
7
  module Irep
7
8
  class CLI
8
9
  def self.execute(stdout, argv = [])
9
- # puts "argv: #{argv}"
10
10
  opts, args = parse_options argv
11
- # stdout.print parser.help
12
- Interface.info "opts: #{opts}"
13
- Interface.info "args: #{args}"
11
+ # TODO: implement log level
12
+ # Interface.debug "argv: #{argv}"
13
+ # Interface.debug "opts: #{opts}"
14
+ # Interface.debug "args: #{args}"
14
15
 
15
16
  search_text = args[0]
16
17
  replace_text = args[1]
17
- unless search_text
18
- usage 'invalid args.'
18
+ unless search_text && !search_text.empty?
19
+ display_error 'invalid args.'
19
20
  end
20
21
 
21
22
  search = Search.new path: opts[:path], search_text: search_text
@@ -30,12 +31,16 @@ module Irep
30
31
  Replace.replace_by_search_results_interactively search.results, search_text, replace_text
31
32
  end
32
33
 
34
+ private
35
+
33
36
  def self.parse_options(argv = [])
34
37
  options = {
35
38
  path: '.',
36
39
  replace: true
37
40
  }
38
41
 
42
+ parser.version = Irep::VERSION
43
+
39
44
  parser.on('--[no-]replace') { |v| options[:replace] = v }
40
45
  parser.on('--path VAL') { |v| options[:path] = v }
41
46
  # parser.on('--only-search') { |v| options[:replace] = false }
@@ -53,18 +58,27 @@ module Irep
53
58
  # parser.on('--show-hidden-files') { |v| options[:show_hidden_files] = true }
54
59
  # parser.on('--dry-run') { |v| options[:dry_run] = true }
55
60
  # parser.on('--verbose') { |v| options[:verbose] = true }
61
+ # parser.on('--debug') { |v| options[:debug] = true }
62
+ parser.on_tail('--version', 'Show version') do
63
+ puts parser.version
64
+ exit
65
+ end
66
+ parser.on_tail('-h', '--help', 'Show this message') do
67
+ puts parser
68
+ exit
69
+ end
56
70
 
57
71
  begin
58
72
  # parser.parse!(argv)
59
73
  arguments = parser.parse(argv)
60
74
  rescue OptionParser::InvalidOption => e
61
- usage e.message
75
+ display_error e.message
62
76
  end
63
77
 
64
78
  [options, arguments]
65
79
  end
66
80
 
67
- def self.usage(msg = nil)
81
+ def self.display_error(msg = nil)
68
82
  Interface.error "Error: #{msg}" if msg
69
83
  puts parser.help
70
84
  exit 1
data/lib/irep/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Irep
2
- VERSION = "0.1.0"
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - motoki-shun
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: ''
97
+ description:
98
98
  email:
99
99
  - shuuuuuny@gmail.com
100
100
  executables:
@@ -118,8 +118,9 @@ files:
118
118
  - lib/irep/replace.rb
119
119
  - lib/irep/search.rb
120
120
  - lib/irep/version.rb
121
- homepage: ''
122
- licenses: []
121
+ homepage: https://github.com/shuuuuun/irep
122
+ licenses:
123
+ - MIT
123
124
  metadata:
124
125
  allowed_push_host: https://rubygems.org
125
126
  post_install_message:
@@ -141,5 +142,5 @@ rubyforge_project:
141
142
  rubygems_version: 2.6.11
142
143
  signing_key:
143
144
  specification_version: 4
144
- summary: ''
145
+ summary: A code searching and interactive replacing tool on CLI.
145
146
  test_files: []