space2underscore 0.2.2 → 0.3.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: 25a6f282a935995e862560165d9e8259883eecae
4
- data.tar.gz: de60139919b4af92edffc14b56ae4258aadd351a
3
+ metadata.gz: ec3c1733d395e2dab18477d8582ed5f3a25ca57c
4
+ data.tar.gz: dd4afc497bcc23a44627d68dfdcfa4f670386020
5
5
  SHA512:
6
- metadata.gz: c1f24efc4d8ed3dd078a23b2ccea7ca938235c48cef154969cb231faa7e309b0760a3d114737d1be3f0129223e5468693daf07b99a98812276975975fbe4b469
7
- data.tar.gz: 87baef2725de6d323a26b4ab4266c0d9df5288d84494ba08d2a45ceea752965ae0f804b277213ce1269a74a8b757038e830282f5080697f291553d81f453f387
6
+ metadata.gz: 034a24d052ff5e563631eff2e592de23433c961bede054bb88acc6d059f5a4b80365620a0dbad64e47eee9c3d44d1485ccf91ede047e2cd23822f5b53ecc6f3f
7
+ data.tar.gz: d72d3b41f4244a56dc91ff87fdd9650235bac8b9da749d590c30c34785f3337fbcca231a2e50a5009f7ebfa85fb76bd66b6291845de5e3a6a02ccc34eef103b0
data/README.md CHANGED
@@ -1,46 +1,24 @@
1
1
  # Space2underscore
2
2
  ## What is space2underscore
3
3
  Change the space into underscore.
4
-
5
4
  space2underscore is a useful command when you want to check out a branch.
6
5
 
7
6
  ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- gem 'space2underscore'
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
7
+ Install it yourself as:
18
8
 
19
9
  $ gem install space2underscore
20
10
 
21
- If your computer is Ubuntu then
22
-
23
- $ sudo apt-get install xsel
24
-
25
- If your computer is CentOS then
26
-
27
- $ sudo yum -y install xsel
28
-
29
11
  ## Usage
30
12
 
31
13
  From the terminal:
32
14
 
33
- $ space2underscore new branch
34
- => Do you create the new branch? [y/Y] # y
15
+ $ space2underscore new branch -c
35
16
  => Switched to the new branch 'new_branch’
36
17
  => Branch has been created.
37
18
 
38
19
  Or
39
20
 
40
- $ space2underscore new branch
41
- => Do you create the new branch? [y/Y/Yes, n/N/No] # n
42
- => Branch name has been copied to clipboard.
43
- $ git branch -m new_branch # Paste from clipboard
21
+ $ git branch -m $(space2underscore renamed branch) # Output to the standard output
44
22
 
45
23
  ## Contributing
46
24
 
data/bin/space2underscore CHANGED
@@ -1,6 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require 'space2underscore'
4
3
 
5
- result = Space2underscore.convert(ARGV)
6
- puts Space2underscore.create_new_branch(result)
4
+ CREATE_FLAGS = %w(-c --create)
5
+
6
+ args = ARGV.reject { |arg| CREATE_FLAGS.include?(arg) }
7
+ result = Space2underscore.convert(args)
8
+
9
+ if ARGV.include?('-c') || ARGV.include?('--create')
10
+ Space2underscore.create_new_branch(result)
11
+ else
12
+ print result
13
+ end
@@ -6,36 +6,8 @@ module Space2underscore
6
6
  argv.length == 1 ? argv[0].strip.gsub(/\s/, '_') : argv.join('_')
7
7
  end
8
8
 
9
- def generate_command(underscore_include_sentence)
10
- "echo #{underscore_include_sentence} | ruby -pe 'chomp' | #{copy_cmd}"
11
- end
12
-
13
- def execute_command(command)
14
- system command
15
- end
16
-
17
- def copy_cmd
18
- if system("type pbcopy > /dev/null 2>&1")
19
- "pbcopy"
20
- elsif system("type xsel > /dev/null 2>&1")
21
- "xsel --input --clipboard"
22
- elsif system("type xclip > /dev/null 2>&1")
23
- "xclip"
24
- end
25
- end
26
-
27
9
  def create_new_branch(underscore_include_sentence)
28
- print "Do you create the new branch? [y/Y/Yes, n/N/No]"
29
- flag = $stdin.gets.chomp
30
-
31
- if !!(flag =~ /^y(es)?$/i) || flag == ''
32
- system "git checkout -b #{underscore_include_sentence}"
33
- "Branch has been created."
34
- else
35
- execute_command(generate_command(underscore_include_sentence))
36
-
37
- "Branch name has been copied to clipboard."
38
- end
10
+ system "git checkout -b #{underscore_include_sentence}"
39
11
  end
40
12
  end
41
13
  end
@@ -1,3 +1,3 @@
1
1
  module Space2underscore
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -5,8 +5,4 @@ describe Space2underscore do
5
5
  expect(Space2underscore.convert(['fuga hoge foo'])).to include('_') # String case
6
6
  expect(Space2underscore.convert(%w(fuga hoge foo))).to include('_') # Array case
7
7
  end
8
-
9
- it 'should be Successful copied' do
10
- expect(Space2underscore.generate_command('fuga_hoge_foo')).to eq("echo fuga_hoge_foo | ruby -pe 'chomp' | pbcopy")
11
- end
12
8
  end
data/spec/spec_helper.rb CHANGED
@@ -3,11 +3,7 @@ require 'space2underscore'
3
3
  Bundler.setup
4
4
 
5
5
  RSpec.configure do |config|
6
- config.treat_symbols_as_metadata_keys_with_true_values = true
7
- config.run_all_when_everything_filtered = true
8
- config.filter_run :focus
9
6
  config.order = 'random'
10
-
11
7
  config.expect_with :rspec do |rspec|
12
8
  rspec.syntax = :expect
13
9
  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.2.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sachin21
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-13 00:00:00.000000000 Z
11
+ date: 2015-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.4.5
110
+ rubygems_version: 2.2.3
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: change the space into underscore