slashjoin 0.0.2.1 → 0.0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/slashjoin.rb +2 -25
- data/lib/slashjoin/class.rb +44 -0
- data/lib/slashjoin/{nopatching.rb → nopatch.rb} +1 -1
- data/lib/slashjoin/patching.rb +8 -9
- data/lib/slashjoin/pathname.rb +2 -3
- data/lib/slashjoin/string.rb +2 -2
- data/lib/slashjoin/uri.rb +2 -2
- data/lib/slashjoin/use_pathname.rb +1 -1
- data/lib/slashjoin/version.rb +1 -1
- data/slashjoin.gemspec +7 -7
- data/spec/slashjoin_spec.rb +20 -19
- data/spec/spec_helper.rb +0 -1
- metadata +11 -16
- data/spec/regexp_spec.rb +0 -14
- data/spec/wcwidth_spec.rb +0 -66
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5348960e3159fc23f90930b1cfc403ed37ee9bda
|
4
|
+
data.tar.gz: 70da023d46c4c0c138e44e8267ccb329b13bfef2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 14b8b0d99746ac9f6f38fb025f006a1c68a980ff3ae92ee5c92035d389d9884a83ec1bc95db5fafde0796a3a4867b71a2ffd9acbce900336f4dfe28c5f62e231
|
7
|
+
data.tar.gz: 2135d8c342017dd1bd1f4fc6fae6dd9b6a3250e46ae6da9a92eb20bd3eb0addd1aac0a5177960e3be8e36f5ce74d493609138c0d08d129d185755dba0e692c28
|
data/lib/slashjoin.rb
CHANGED
@@ -1,30 +1,7 @@
|
|
1
|
-
require 'slashjoin/
|
2
|
-
|
3
|
-
module Slashjoin
|
4
|
-
@@no_patching ||= false
|
5
|
-
@@use_pathname ||= false
|
6
|
-
|
7
|
-
ALREADY_LOADED ||= {}
|
8
|
-
|
9
|
-
def self.no_patching?
|
10
|
-
@@no_patching
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.use_pathname
|
14
|
-
@@user_pathname = true
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.user_pathname= (arg)
|
18
|
-
@@user_pathname = arg
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.use_pathname?
|
22
|
-
@@use_pathname
|
23
|
-
end
|
24
|
-
end
|
1
|
+
require 'slashjoin/class'
|
25
2
|
|
26
3
|
require 'slashjoin/string'
|
27
4
|
require 'slashjoin/uri'
|
28
5
|
require 'slashjoin/pathname'
|
29
6
|
|
30
|
-
|
7
|
+
Slashjoin.patching
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'slashjoin/version'
|
2
|
+
|
3
|
+
module Slashjoin
|
4
|
+
@@no_patch = false
|
5
|
+
@@use_pathname = false
|
6
|
+
|
7
|
+
# @return [Slashjoin]
|
8
|
+
def self.no_patch
|
9
|
+
@@no_patch = true
|
10
|
+
return self
|
11
|
+
end
|
12
|
+
|
13
|
+
# return [Boolean]
|
14
|
+
def self.no_patch?
|
15
|
+
@@no_patch
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Slashjoin]
|
19
|
+
def self.use_pathname
|
20
|
+
@@user_pathname = true
|
21
|
+
return self
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Boolean]
|
25
|
+
def self.use_pathname?
|
26
|
+
@@use_pathname
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Hash]
|
30
|
+
def self.loaded_classes
|
31
|
+
@@loaded_classes ||= {}
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Boolean]
|
35
|
+
def self.already_loaded?
|
36
|
+
loaded_classes.any?
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Slashjoin]
|
40
|
+
def self.patching
|
41
|
+
require 'slashjoin/patching'
|
42
|
+
return self
|
43
|
+
end
|
44
|
+
end
|
data/lib/slashjoin/patching.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
raise
|
1
|
+
unless Slashjoin.already_loaded?
|
2
|
+
msg = 'Error when NOT loaded `slashjoin\', `slashjoin/{string, uri, pathname}\''
|
3
|
+
raise msg
|
4
|
+
end
|
4
5
|
|
5
6
|
patches = {
|
6
7
|
string: proc{
|
@@ -23,13 +24,12 @@ patches = {
|
|
23
24
|
}
|
24
25
|
|
25
26
|
no_lib = %w(string).map(&:to_sym)
|
26
|
-
loaded = Slashjoin
|
27
|
-
all = loaded.size == 0
|
27
|
+
loaded = Slashjoin.loaded_classes
|
28
|
+
all = (loaded.size == 0)
|
28
29
|
|
29
30
|
patches.each{ |key, patch|
|
30
|
-
if all || loaded[key]
|
31
|
-
|
32
|
-
#require key.to_s unless no_lib.include? key
|
31
|
+
if (all || loaded[key])
|
32
|
+
require(key.to_s) unless no_lib.include?(key)
|
33
33
|
case patch
|
34
34
|
when 'pathname'
|
35
35
|
patch.call if Slashjoin::use_pathname?
|
@@ -38,4 +38,3 @@ patches.each{ |key, patch|
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
}
|
41
|
-
|
data/lib/slashjoin/pathname.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
+
require 'slashjoin/class'
|
1
2
|
require 'pathname'
|
2
3
|
|
3
4
|
module Slashjoin
|
4
|
-
|
5
|
-
ALREADY_LOADED[:pathname] = true
|
5
|
+
loaded_classes[:pathname] = true
|
6
6
|
|
7
7
|
module Pathname
|
8
8
|
def / (other)
|
@@ -10,4 +10,3 @@ module Slashjoin
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
data/lib/slashjoin/string.rb
CHANGED
data/lib/slashjoin/uri.rb
CHANGED
data/lib/slashjoin/version.rb
CHANGED
data/slashjoin.gemspec
CHANGED
@@ -4,16 +4,16 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'slashjoin/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name =
|
7
|
+
gem.name = 'slashjoin'
|
8
8
|
gem.version = Slashjoin::VERSION
|
9
|
-
gem.authors = [
|
10
|
-
gem.email = [
|
11
|
-
gem.description =
|
12
|
-
gem.summary =
|
13
|
-
gem.homepage = '
|
9
|
+
gem.authors = ['USAMI Kenta']
|
10
|
+
gem.email = ['tadsan@zonu.me']
|
11
|
+
gem.description = 'add String#/ method, do {file|URI} path join'
|
12
|
+
gem.summary = "inspired by \(backslash) operator of MortScript."
|
13
|
+
gem.homepage = 'http://dt.zonu.me/'
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = [
|
18
|
+
gem.require_paths = ['lib']
|
19
19
|
end
|
data/spec/slashjoin_spec.rb
CHANGED
@@ -1,33 +1,34 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
|
3
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__)))
|
4
|
+
|
4
5
|
require 'spec_helper'
|
5
6
|
require 'slashjoin'
|
6
7
|
|
7
8
|
describe Slashjoin do
|
8
9
|
context String do
|
9
|
-
|
10
|
-
base
|
11
|
-
user
|
12
|
-
project
|
13
|
-
user_uri
|
14
|
-
user_uri.
|
15
|
-
proj_uri
|
16
|
-
proj_uri.
|
10
|
+
context "join to URI path name" do
|
11
|
+
let(:base){ "https://github.com/" }
|
12
|
+
let(:user){ "zonuexe/" }
|
13
|
+
let(:project){ "ruby-slashjoin" }
|
14
|
+
let(:user_uri){ base / user }
|
15
|
+
it{ expect(user_uri).to eq URI.parse("https://github.com/zonuexe/") }
|
16
|
+
let(:proj_uri){ user_uri / project }
|
17
|
+
it{ expect(proj_uri).to eq URI.parse("https://github.com/zonuexe/ruby-slashjoin") }
|
17
18
|
end
|
18
|
-
|
19
|
-
home
|
20
|
-
megurine_home
|
21
|
-
megurine_home.
|
22
|
-
megurine_home.
|
19
|
+
context "join to UNIX like path name" do
|
20
|
+
let(:home){ "/home" }
|
21
|
+
let(:megurine_home){ home / "megurine" }
|
22
|
+
it{ expect(megurine_home).to eq "/home/megurine" }
|
23
|
+
it{ expect(megurine_home).to be_a String }
|
23
24
|
end
|
24
25
|
end
|
25
26
|
context Pathname do
|
26
|
-
|
27
|
-
home
|
28
|
-
megurine_home
|
29
|
-
megurine_home.
|
30
|
-
megurine_home.
|
27
|
+
context "join to" do
|
28
|
+
let(:home){ Pathname.new("/home") }
|
29
|
+
let(:megurine_home){ home / "megurine" }
|
30
|
+
it{ expect(megurine_home).to eq Pathname.new("/home/megurine") }
|
31
|
+
it{ expect(megurine_home).to be_a Pathname }
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slashjoin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- USAMI Kenta
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-06-08 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: add String#/ method, do {file|URI} path join
|
15
14
|
email:
|
@@ -25,7 +24,8 @@ files:
|
|
25
24
|
- README.md
|
26
25
|
- Rakefile
|
27
26
|
- lib/slashjoin.rb
|
28
|
-
- lib/slashjoin/
|
27
|
+
- lib/slashjoin/class.rb
|
28
|
+
- lib/slashjoin/nopatch.rb
|
29
29
|
- lib/slashjoin/patching.rb
|
30
30
|
- lib/slashjoin/pathname.rb
|
31
31
|
- lib/slashjoin/string.rb
|
@@ -33,39 +33,34 @@ files:
|
|
33
33
|
- lib/slashjoin/use_pathname.rb
|
34
34
|
- lib/slashjoin/version.rb
|
35
35
|
- slashjoin.gemspec
|
36
|
-
- spec/regexp_spec.rb
|
37
36
|
- spec/slashjoin_nopatching.rb
|
38
37
|
- spec/slashjoin_spec.rb
|
39
38
|
- spec/spec_helper.rb
|
40
|
-
|
41
|
-
homepage: https://github.com/zonuexe/ruby-slashjoin
|
39
|
+
homepage: http://dt.zonu.me/
|
42
40
|
licenses: []
|
41
|
+
metadata: {}
|
43
42
|
post_install_message:
|
44
43
|
rdoc_options: []
|
45
44
|
require_paths:
|
46
45
|
- lib
|
47
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
-
none: false
|
49
47
|
requirements:
|
50
|
-
- -
|
48
|
+
- - '>='
|
51
49
|
- !ruby/object:Gem::Version
|
52
50
|
version: '0'
|
53
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
52
|
requirements:
|
56
|
-
- -
|
53
|
+
- - '>='
|
57
54
|
- !ruby/object:Gem::Version
|
58
55
|
version: '0'
|
59
56
|
requirements: []
|
60
57
|
rubyforge_project:
|
61
|
-
rubygems_version:
|
58
|
+
rubygems_version: 2.0.2
|
62
59
|
signing_key:
|
63
|
-
specification_version:
|
64
|
-
summary:
|
60
|
+
specification_version: 4
|
61
|
+
summary: inspired by (backslash) operator of MortScript.
|
65
62
|
test_files:
|
66
|
-
- spec/regexp_spec.rb
|
67
63
|
- spec/slashjoin_nopatching.rb
|
68
64
|
- spec/slashjoin_spec.rb
|
69
65
|
- spec/spec_helper.rb
|
70
|
-
- spec/wcwidth_spec.rb
|
71
66
|
has_rdoc:
|
data/spec/regexp_spec.rb
DELETED
data/spec/wcwidth_spec.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
$: << File.expand_path(File.dirname(__FILE__))
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe StringWidth::Tanasinn do
|
7
|
-
before(:all){ include StringWidth::Tanasinn }
|
8
|
-
describe "As single" do
|
9
|
-
context "Ascii" do
|
10
|
-
it "large A" do
|
11
|
-
StringWidth::Tanasinn::wcwidth_amb_as_single("A").should == 1
|
12
|
-
end
|
13
|
-
it "large Z" do
|
14
|
-
StringWidth::Tanasinn::wcwidth_amb_as_single("Z").should == 1
|
15
|
-
end
|
16
|
-
end
|
17
|
-
context "Japanese" do
|
18
|
-
it "Hiragana NU" do
|
19
|
-
StringWidth::Tanasinn::wcwidth_amb_as_single("ぬ").should == 2
|
20
|
-
end
|
21
|
-
it "Hiragana RU" do
|
22
|
-
StringWidth::Tanasinn::wcwidth_amb_as_single("る").should == 2
|
23
|
-
end
|
24
|
-
it "Hiragana PO" do
|
25
|
-
StringWidth::Tanasinn::wcwidth_amb_as_single("ぽ").should == 2
|
26
|
-
end
|
27
|
-
it "Half Katakana GA" do
|
28
|
-
->{
|
29
|
-
StringWidth::Tanasinn::wcwidth_amb_as_single("ガ")
|
30
|
-
}.should raise_error ArgumentError
|
31
|
-
end
|
32
|
-
it "Half Katakana Small TSU" do
|
33
|
-
StringWidth::Tanasinn::wcwidth_amb_as_single("ッ").should == 1
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
describe "As double" do
|
38
|
-
context "Ascii" do
|
39
|
-
it "large A" do
|
40
|
-
StringWidth::Tanasinn::wcwidth_amb_as_double("A").should == 1
|
41
|
-
end
|
42
|
-
it "large Z" do
|
43
|
-
StringWidth::Tanasinn::wcwidth_amb_as_double("Z").should == 1
|
44
|
-
end
|
45
|
-
end
|
46
|
-
context "Japanese" do
|
47
|
-
it "Hiragana NU" do
|
48
|
-
StringWidth::Tanasinn::wcwidth_amb_as_double("ぬ").should == 2
|
49
|
-
end
|
50
|
-
it "Hiragana RU" do
|
51
|
-
StringWidth::Tanasinn::wcwidth_amb_as_double("る").should == 2
|
52
|
-
end
|
53
|
-
it "Hiragana PO" do
|
54
|
-
StringWidth::Tanasinn::wcwidth_amb_as_double("ぽ").should == 2
|
55
|
-
end
|
56
|
-
it "Half Katakana GA" do
|
57
|
-
->{
|
58
|
-
StringWidth::Tanasinn::wcwidth_amb_as_double("ガ")
|
59
|
-
}.should raise_error ArgumentError
|
60
|
-
end
|
61
|
-
it "Half Katakana Small TSU" do
|
62
|
-
StringWidth::Tanasinn::wcwidth_amb_as_double("ッ").should == 1
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|