tbpgr_utils 0.0.100 → 0.0.101

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -136,6 +136,7 @@ Or install it yourself as:
136
136
  |[TbpgrUtils String#to_tab_heading](#stringto_tab_heading) |create tab-format heading string with Emmet-like grammar |
137
137
  |[TbpgrUtils String#unescape_double_quote](#stringunescape_double_quote) |unescape double quote |
138
138
  |[TbpgrUtils String#unescape_quote](#stringunescape_quote) |unescape single quote |
139
+ |[TbpgrUtils String#winpath_to_cygwinpath](#stringwinpath_to_cygwinpath) |convert windows path to cygwin path |
139
140
  |[TbpgrUtils Symbol#is_meta_variable?](#symbolis_meta_variable) |is meta variable. |
140
141
  |[Templatable module](#templatable) |get result from template + placeholder |
141
142
  |[TemplateMethodable module](#templatemethodable) |for Template Method Pattern |
@@ -3154,6 +3155,14 @@ require 'tbpgr_utils'
3154
3155
 
3155
3156
  [back to list](#list)
3156
3157
 
3158
+ ### String#winpath_to_cygwinpath
3159
+ ~~~ruby
3160
+ require 'tbpgr_utils'
3161
+ 'C:\hoge\hoge.txt'.winpath_to_cygwinpath # => '/cygdrive/c/hoge/hoge.txt'
3162
+ ~~~
3163
+
3164
+ [back to list](#list)
3165
+
3157
3166
  ### Symbol#is_meta_variable?
3158
3167
  ~~~ruby
3159
3168
  :foo.is_meta_variable? # => true
@@ -3264,7 +3273,8 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3264
3273
  https://github.com/tbpgr/tbpgr_utils_snippets
3265
3274
 
3266
3275
  ## History
3267
- * version 0.0.100 : add String.ascii_unicode_html_table
3276
+ * version 0.0.101 : add String#winpath_to_cygwinpath
3277
+ * version 0.0.100 : add String#ascii_unicode_html_table
3268
3278
  * version 0.0.99 : add Numeric.to_oct_html_table
3269
3279
  * version 0.0.98 : add Numeric.to_hex_html_table
3270
3280
  * version 0.0.97 : add Numeric.to_digit_html_table
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ class String
4
+ # convert windows path to cygwin path
5
+ #
6
+ # ==== Examples
7
+ #
8
+ # 'C:\hoge\hoge.txt'.winpath_to_cygwinpath # => '/cygdrive/c/hoge/hoge.txt'
9
+ #
10
+ def winpath_to_cygwinpath
11
+ return self unless match(/\w:\\/)
12
+ drive = scan(/(\w):\\/).first.first.downcase
13
+ dir_file = scan(/\w:\\(.*)/).first.first.gsub('\\', '/')
14
+ "/cygdrive/#{drive}/#{dir_file}"
15
+ end
16
+ end
@@ -20,3 +20,4 @@ require 'open_classes/string/to_space4_heading'
20
20
  require 'open_classes/string/to_tab_heading'
21
21
  require 'open_classes/string/unescape_double_quote'
22
22
  require 'open_classes/string/unescape_quote'
23
+ require 'open_classes/string/winpath_to_cygwinpath'
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.100'
5
+ VERSION = '0.0.101'
6
6
  end
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'open_classes/string/winpath_to_cygwinpath'
4
+
5
+ describe String do
6
+ context :winpath_to_cygwinpath do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'file case',
11
+ input: 'C:\hoge\hoge.txt',
12
+ expected: '/cygdrive/c/hoge/hoge.txt',
13
+ },
14
+ {
15
+ case_no: 2,
16
+ case_title: 'dir case',
17
+ input: 'D:\hoge',
18
+ expected: '/cygdrive/d/hoge',
19
+ },
20
+ ]
21
+
22
+ cases.each do |c|
23
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
24
+ begin
25
+ case_before c
26
+
27
+ # -- given --
28
+ # nothing
29
+
30
+ # -- when --
31
+ actual = c[:input].winpath_to_cygwinpath
32
+
33
+ # -- then --
34
+ expect(actual).to eq(c[:expected])
35
+ ensure
36
+ case_after c
37
+ end
38
+ end
39
+
40
+ def case_before(c)
41
+ # implement each case before
42
+ end
43
+
44
+ def case_after(c)
45
+ # implement each case after
46
+ end
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tbpgr_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.100
4
+ version: 0.0.101
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-17 00:00:00.000000000 Z
12
+ date: 2014-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &21875244 !ruby/object:Gem::Requirement
16
+ requirement: &21430032 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.0.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21875244
24
+ version_requirements: *21430032
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &21874500 !ruby/object:Gem::Requirement
27
+ requirement: &21429708 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.3'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *21874500
35
+ version_requirements: *21429708
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &21872964 !ruby/object:Gem::Requirement
38
+ requirement: &21429384 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *21872964
46
+ version_requirements: *21429384
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &21872436 !ruby/object:Gem::Requirement
49
+ requirement: &21428892 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.14.1
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *21872436
57
+ version_requirements: *21428892
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &21871812 !ruby/object:Gem::Requirement
60
+ requirement: &21428532 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 0.8.2
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *21871812
68
+ version_requirements: *21428532
69
69
  description: Utilities
70
70
  email:
71
71
  - tbpgr@tbpgr.jp
@@ -197,6 +197,7 @@ files:
197
197
  - lib/open_classes/string/to_tab_heading.rb
198
198
  - lib/open_classes/string/unescape_double_quote.rb
199
199
  - lib/open_classes/string/unescape_quote.rb
200
+ - lib/open_classes/string/winpath_to_cygwinpath.rb
200
201
  - lib/open_classes/symbol.rb
201
202
  - lib/open_classes/symbol/is_meta_variable.rb
202
203
  - lib/simple_tournament.rb
@@ -308,6 +309,7 @@ files:
308
309
  - spec/open_classes/string/to_tab_heading_spec.rb
309
310
  - spec/open_classes/string/unescape_double_quote_spec.rb
310
311
  - spec/open_classes/string/unescape_quote_spec.rb
312
+ - spec/open_classes/string/winpath_to_cygwinpath_spec.rb
311
313
  - spec/open_classes/symbol/is_meta_variable_spec.rb
312
314
  - spec/set_variables_code_spec.rb
313
315
  - spec/simple_tournament_spec.rb
@@ -443,6 +445,7 @@ test_files:
443
445
  - spec/open_classes/string/to_tab_heading_spec.rb
444
446
  - spec/open_classes/string/unescape_double_quote_spec.rb
445
447
  - spec/open_classes/string/unescape_quote_spec.rb
448
+ - spec/open_classes/string/winpath_to_cygwinpath_spec.rb
446
449
  - spec/open_classes/symbol/is_meta_variable_spec.rb
447
450
  - spec/set_variables_code_spec.rb
448
451
  - spec/simple_tournament_spec.rb