space2underscore 0.5.2 → 0.5.3

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
- SHA1:
3
- metadata.gz: 47e87d5fef3cbf63b644d8718f6b5b4a6ac600b8
4
- data.tar.gz: 3b93e888a49904995689e2eeacc17f552aacfc86
2
+ SHA256:
3
+ metadata.gz: 5405706c2105ac418843695f1d7afd044b9564ed685af0c6f8fa154553eb206e
4
+ data.tar.gz: 706848adbf574a43e1d99627e00e09fbd207e504dd516b25ccbea5e62f71d69e
5
5
  SHA512:
6
- metadata.gz: 8044f50d77379b6c448c545e34a5d80d4939bd40b1527d34b5d50d45c4e794cd64334cd14ab78a1d270014392b33a3761cc01a59116203aeaac18e4e63884233
7
- data.tar.gz: 0f6dc1b4eae1536a67a9ee18fce5e8e666cfe09c7f68f3e63a797ec3bed32ed6522fd2f4cd8ae3e36cb7d73aa9c817bdf0dfb06aeefbdbe2515ceef023717dd9
6
+ metadata.gz: 868566a30e93b631a124e6493f9b7016db45975097ce2c0d6aa17bc14b420208d31dc84bdeea91fe96084117c3a6025576f214782aedbf21668266471d4f9ce3
7
+ data.tar.gz: a19420ddb6a53121649889f839f537a793193ffddea28e8b84706c110287de23f40c2f5ed14141cf405eaacfd37a68d24881f51f57d8f55737b918f29db7cd73
@@ -4,5 +4,13 @@ AllCops:
4
4
  Exclude:
5
5
  - 'vendor/bundle/**/*'
6
6
 
7
+ DisplayCopNames: true
8
+
7
9
  Style/Documentation:
8
10
  Enabled: false
11
+
12
+ Metrics/LineLength:
13
+ Max: 100
14
+
15
+ Metrics/MethodLength:
16
+ Max: 15
@@ -1,10 +1,10 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - ruby-2.3.0
5
- - 2.1.2
6
- - 2.1.1
7
- - 2.1.0
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
  ![Gem Version](https://badge.fury.io/rb/space2underscore.svg) [![Build Status](https://travis-ci.org/sachin21/space2underscore.svg?branch=master)](https://travis-ci.org/sachin21/space2underscore) [![Code Climate](https://codeclimate.com/github/sachin21/space2underscore/badges/gpa.svg)](https://codeclimate.com/github/sachin21/space2underscore) [![Coverage Status](https://coveralls.io/repos/sachin21/space2underscore/badge.svg?branch=master&service=github)](https://coveralls.io/github/sachin21/space2underscore?branch=master) [![Gem](https://img.shields.io/gem/dt/space2underscore.svg)](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
- This is a command line tool. So DO NOT include all modules because it uses `system` command. So crackers will be attacking your application.
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
@@ -4,8 +4,9 @@
4
4
  module Space2underscore
5
5
  end
6
6
 
7
- require 'space2underscore/version'
7
+ require 'singleton'
8
8
 
9
+ require 'space2underscore/version'
9
10
  require 'space2underscore/executor'
10
11
  require 'space2underscore/printer'
11
12
  require 'space2underscore/underscore'
@@ -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 && exit if @argv.empty?
17
-
18
- case
19
- when included?(CREATE_FLAGS) && included?(RAW_FLAGS)
20
- Executor.new(@underscore_include_branch).run_with_raw
21
- when included?(CREATE_FLAGS) && not_included?(RAW_FLAGS)
22
- Executor.new(@underscore_include_branch).run_with_downcase
23
- when not_included?(CREATE_FLAGS) && included?(RAW_FLAGS)
24
- Printer.instance.run_with_raw(@underscore_include_branch)
25
- when not_included?(CREATE_FLAGS) && not_included?(RAW_FLAGS)
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, 'Option is invalid format. It is only avaliable for `-c --create -d --downcase`'
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
- def initialize(underscore_include_sentence)
4
- @underscore_include_sentence = underscore_include_sentence
5
- end
5
+ include Singleton
6
6
 
7
- def run_with_raw
8
- run @underscore_include_sentence
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 @underscore_include_sentence.downcase
11
+ def run_with_downcase(underscore_include_sentence)
12
+ run underscore_include_sentence.downcase
13
13
  end
14
14
 
15
15
  private
@@ -1,4 +1,4 @@
1
- require 'singleton'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Space2underscore
4
4
  class Printer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Space2underscore
2
4
  class Underscore
3
5
  def initialize(sentence)
@@ -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
- $ space2underscore new branch -c
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 $(space2underscore renamed branch)
15
+ $ git branch -m $(s2u renamed branch)
14
16
 
15
17
  VERSION:
16
18
  #{Space2underscore::VERSION}
@@ -2,5 +2,5 @@
2
2
 
3
3
  # This module holds the Space2underscore version information.
4
4
  module Space2underscore
5
- VERSION = '0.5.2'
5
+ VERSION = '0.5.3'
6
6
  end
@@ -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 = ['sachin21.developer@gmail.com']
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
 
@@ -14,7 +14,7 @@ describe Space2underscore::Underscore do
14
14
  end
15
15
 
16
16
  context 'when number of argument is many' do
17
- let(:argument) { %w(foo bar) }
17
+ let(:argument) { %w[foo bar] }
18
18
 
19
19
  it { is_expected.to include('_') }
20
20
  end
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.2
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: 2017-12-23 00:00:00.000000000 Z
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
- - sachin21.developer@gmail.com
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: '0'
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.13
154
+ rubygems_version: 2.7.6
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: Change the space into underscore