space2underscore 0.5.2 → 0.5.3
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 +5 -5
- data/.rubocop.yml +8 -0
- data/.travis.yml +5 -4
- data/README.md +6 -9
- data/lib/space2underscore.rb +2 -1
- data/lib/space2underscore/cli.rb +33 -12
- data/lib/space2underscore/executor.rb +7 -7
- data/lib/space2underscore/printer.rb +1 -1
- data/lib/space2underscore/underscore.rb +2 -0
- data/lib/space2underscore/usage.rb +4 -2
- data/lib/space2underscore/version.rb +1 -1
- data/space2underscore.gemspec +2 -1
- data/spec/space2underscore/underscore_spec.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5405706c2105ac418843695f1d7afd044b9564ed685af0c6f8fa154553eb206e
|
4
|
+
data.tar.gz: 706848adbf574a43e1d99627e00e09fbd207e504dd516b25ccbea5e62f71d69e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 868566a30e93b631a124e6493f9b7016db45975097ce2c0d6aa17bc14b420208d31dc84bdeea91fe96084117c3a6025576f214782aedbf21668266471d4f9ce3
|
7
|
+
data.tar.gz: a19420ddb6a53121649889f839f537a793193ffddea28e8b84706c110287de23f40c2f5ed14141cf405eaacfd37a68d24881f51f57d8f55737b918f29db7cd73
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
rvm:
|
4
|
-
-
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
-
|
4
|
+
- 2.3.7
|
5
|
+
- 2.4.4
|
6
|
+
- 2.5.1
|
7
|
+
- ruby-head
|
8
8
|
|
9
9
|
before_install:
|
10
10
|
- gem install bundler
|
@@ -13,4 +13,5 @@ before_install:
|
|
13
13
|
script: "bundle exec rake spec:with_coveralls"
|
14
14
|
|
15
15
|
notifications:
|
16
|
+
email: false
|
16
17
|
slack: sachin21dev:3pEyff2UFnoCgl4NI0uxbsER
|
data/README.md
CHANGED
@@ -3,10 +3,12 @@
|
|
3
3
|
 [](https://travis-ci.org/sachin21/space2underscore) [](https://codeclimate.com/github/sachin21/space2underscore) [](https://coveralls.io/github/sachin21/space2underscore?branch=master) [](https://rubygems.org/gems/space2underscore)
|
4
4
|
|
5
5
|
## What is space2underscore
|
6
|
+
|
6
7
|
Change the space into underscore.
|
7
8
|
space2underscore is a useful command when you want to check out a branch.
|
8
9
|
|
9
10
|
## Installation
|
11
|
+
|
10
12
|
Install it yourself as:
|
11
13
|
|
12
14
|
```
|
@@ -14,6 +16,7 @@ $ gem install space2underscore
|
|
14
16
|
```
|
15
17
|
|
16
18
|
## Usage
|
19
|
+
|
17
20
|
From the command line:
|
18
21
|
|
19
22
|
### 1. e.g. Create the new branch
|
@@ -32,16 +35,10 @@ $ git branch -m $(s2u renamed branch)
|
|
32
35
|
```
|
33
36
|
|
34
37
|
## !! Cation !!
|
35
|
-
|
38
|
+
|
39
|
+
This is a command line tool. So DO NOT include space2underscore's module in other Ruby application because it uses `system` command.
|
40
|
+
If you include this module to your application, there is a possibility of crackers attacking.
|
36
41
|
|
37
42
|
## Credits
|
38
43
|
- Help information based on [@motemen's ghq](https://github.com/motemen/ghq)
|
39
44
|
- Installed information based on [Tmuxinator](https://github.com/tmuxinator/tmuxinator)
|
40
|
-
|
41
|
-
## Contributing
|
42
|
-
|
43
|
-
1. Fork it
|
44
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
-
5. Create new Pull Request
|
data/lib/space2underscore.rb
CHANGED
data/lib/space2underscore/cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Space2underscore
|
2
4
|
class Cli
|
3
5
|
CREATE_FLAGS = %w[-c --create].freeze
|
@@ -5,27 +7,30 @@ module Space2underscore
|
|
5
7
|
|
6
8
|
FLAGS = [CREATE_FLAGS, RAW_FLAGS].flatten.freeze
|
7
9
|
|
10
|
+
ERROR_MSG = 'Option is invalid format. It is only avaliable for `-c --create -d --downcase`'
|
11
|
+
|
8
12
|
OptionParseError = Class.new(ArgumentError)
|
9
13
|
|
10
14
|
def initialize(argv)
|
11
15
|
@argv = argv
|
12
16
|
@underscore_include_branch = Underscore.new(branch).convert
|
17
|
+
@executer = Executor.instance
|
18
|
+
@printer = Printer.instance
|
13
19
|
end
|
14
20
|
|
15
21
|
def start
|
16
|
-
$stdout.puts Usage.new.content
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
Printer.instance.run_with_downcase(@underscore_include_branch)
|
22
|
+
return $stdout.puts Usage.new.content if @argv.empty?
|
23
|
+
|
24
|
+
if with_all_flags?
|
25
|
+
@executer.run_with_raw(@underscore_include_branch)
|
26
|
+
elsif create_flags_without_raw_flags?
|
27
|
+
@executer.run_with_downcase(@underscore_include_branch)
|
28
|
+
elsif raw_flags_without_create_flags?
|
29
|
+
@printer.run_with_raw(@underscore_include_branch)
|
30
|
+
elsif without_any_flags?
|
31
|
+
@printer.run_with_downcase(@underscore_include_branch)
|
27
32
|
else
|
28
|
-
raise OptionParseError,
|
33
|
+
raise OptionParseError, ERROR_MSG
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
@@ -42,5 +47,21 @@ module Space2underscore
|
|
42
47
|
def not_included?(flags)
|
43
48
|
!included?(flags)
|
44
49
|
end
|
50
|
+
|
51
|
+
def without_any_flags?
|
52
|
+
not_included?(CREATE_FLAGS) && not_included?(RAW_FLAGS)
|
53
|
+
end
|
54
|
+
|
55
|
+
def with_all_flags?
|
56
|
+
included?(CREATE_FLAGS) && included?(RAW_FLAGS)
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_flags_without_raw_flags?
|
60
|
+
included?(CREATE_FLAGS) && not_included?(RAW_FLAGS)
|
61
|
+
end
|
62
|
+
|
63
|
+
def raw_flags_without_create_flags?
|
64
|
+
included?(RAW_FLAGS) && not_included?(CREATE_FLAGS)
|
65
|
+
end
|
45
66
|
end
|
46
67
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Space2underscore
|
2
4
|
class Executor
|
3
|
-
|
4
|
-
@underscore_include_sentence = underscore_include_sentence
|
5
|
-
end
|
5
|
+
include Singleton
|
6
6
|
|
7
|
-
def run_with_raw
|
8
|
-
run
|
7
|
+
def run_with_raw(underscore_include_sentence)
|
8
|
+
run underscore_include_sentence
|
9
9
|
end
|
10
10
|
|
11
|
-
def run_with_downcase
|
12
|
-
run
|
11
|
+
def run_with_downcase(underscore_include_sentence)
|
12
|
+
run underscore_include_sentence.downcase
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Space2underscore
|
2
4
|
class Usage
|
3
5
|
MESSAGE = <<-EOF.chomp
|
@@ -5,12 +7,12 @@ module Space2underscore
|
|
5
7
|
space2underscore - Change the space into underscore
|
6
8
|
|
7
9
|
USAGE:
|
8
|
-
$
|
10
|
+
$ s2u new branch -c
|
9
11
|
=> Switched to the new branch 'new_branch’
|
10
12
|
|
11
13
|
Or
|
12
14
|
|
13
|
-
$ git branch -m $(
|
15
|
+
$ git branch -m $(s2u renamed branch)
|
14
16
|
|
15
17
|
VERSION:
|
16
18
|
#{Space2underscore::VERSION}
|
data/space2underscore.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = 'space2underscore'
|
9
9
|
spec.version = Space2underscore::VERSION
|
10
10
|
spec.authors = ['sachin21']
|
11
|
-
spec.email = ['
|
11
|
+
spec.email = ['sachin21dev@gmail.com']
|
12
12
|
spec.description = 'Change the space into underscore'
|
13
13
|
spec.summary = 'Change the space into underscore'
|
14
14
|
spec.homepage = 'https://github.com/sachin21/space2underscore'
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
|
+
spec.required_ruby_version = '>= 2.3.0'
|
21
22
|
|
22
23
|
spec.post_install_message = File.read('post_install_message.txt')
|
23
24
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: space2underscore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sachin21
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
version: 0.49.0
|
83
83
|
description: Change the space into underscore
|
84
84
|
email:
|
85
|
-
-
|
85
|
+
- sachin21dev@gmail.com
|
86
86
|
executables:
|
87
87
|
- s2u
|
88
88
|
- space2underscore
|
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
143
|
requirements:
|
144
144
|
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
146
|
+
version: 2.3.0
|
147
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
149
|
- - ">="
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.6
|
154
|
+
rubygems_version: 2.7.6
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: Change the space into underscore
|