pa 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,142 @@
1
+ require "spec_helper"
2
+
3
+ describe Pa do
4
+ describe "#test" do
5
+ it "runs ok" do
6
+ pa = Pa('/home/guten/')
7
+ pd 'test: ', pa, pa.ok
8
+ end
9
+ end
10
+
11
+ describe "#dir2" do
12
+ it "runs ok" do
13
+ Pa('/home/foo').dir2.should be_an_instance_of Pa
14
+ end
15
+ end
16
+
17
+ describe "#absoulte2" do
18
+ it "runs ok" do
19
+ Pa('.').absolute2.should be_an_instance_of Pa
20
+ end
21
+ end
22
+
23
+ describe "pwd2" do
24
+ it "runs ok" do
25
+ Pa.pwd2.should be_an_instance_of Pa
26
+ end
27
+ end
28
+
29
+ describe ".shorten" do
30
+ it "short /home/usr/file into ~/file" do
31
+ ENV["HOME"] = "/home/foo"
32
+ Pa.shorten("/home/foo/file").should == "~/file"
33
+ end
34
+
35
+ it "not short /home/other-user/file" do
36
+ ENV["HOME"] = "/home/foo"
37
+ Pa.shorten("/home/bar/file").should == "/home/bar/file"
38
+ end
39
+ end
40
+
41
+ describe "NAME_EXT_PAT" do
42
+ it "matchs `foo.bar'" do
43
+ "foo.bar".match(Pa::NAME_EXT_PAT).captures.should == %w(foo bar)
44
+ end
45
+
46
+ it "matchs `foo'" do
47
+ "foo".match(Pa::NAME_EXT_PAT).captures.should == ["foo", nil]
48
+ end
49
+
50
+ end
51
+
52
+ describe "basename" do
53
+ it "get a basename of a path" do
54
+ Pa.basename("/home/foo").should == "foo"
55
+ end
56
+
57
+ it "get name, ext with :ext => true" do
58
+ Pa.basename("/home/foo.bar", ext: true).should == ["foo", "bar"]
59
+ end
60
+
61
+ end
62
+
63
+ describe '.parent' do
64
+ before :each do
65
+ @path = "/home/foo/a.txt"
66
+ end
67
+
68
+ it "return parent path" do
69
+ Pa.parent(@path).should == "/home/foo"
70
+ end
71
+
72
+ it "return parent upto 2 level path" do
73
+ Pa.parent(@path, 2).should == "/home"
74
+ end
75
+ end
76
+
77
+ describe "#==" do
78
+ it "runs ok" do
79
+ (Pa('/home') == Pa('/home')).should be_true
80
+ end
81
+ end
82
+
83
+ describe "#+" do
84
+ it "runs ok" do
85
+ (Pa('/home')+'~').should == Pa('/home~')
86
+ end
87
+ end
88
+
89
+ describe "#sub" do
90
+ it "runs ok" do
91
+ Pa('/home/foo').sub(/o/,'').should == Pa('/hme/foo')
92
+ end
93
+ end
94
+
95
+ describe "#sub!" do
96
+ it "runs ok" do
97
+ pa = Pa('/home/foo')
98
+ pa.sub!(/o/,'')
99
+ pa.should == Pa('/hme/foo')
100
+ end
101
+ end
102
+
103
+ describe "#gsub" do
104
+ it "runs ok" do
105
+ Pa('/home/foo').gsub(/o/,'').should == Pa('/hme/f')
106
+ end
107
+ end
108
+
109
+ describe "#gsub!" do
110
+ it "runs ok" do
111
+ pa = Pa('/home/foo')
112
+ pa.gsub!(/o/,'')
113
+ pa.should == Pa('/hme/f')
114
+ end
115
+ end
116
+
117
+ describe "#match" do
118
+ it "runs ok" do
119
+ Pa('/home/foo').match(/foo/)[0].should == 'foo'
120
+ end
121
+ end
122
+
123
+ describe "#start_with?" do
124
+ it "runs ok" do
125
+ Pa('/home/foo').start_with?('/home').should be_true
126
+ end
127
+ end
128
+
129
+ describe "#end_with?" do
130
+ it "runs ok" do
131
+ Pa('/home/foo').end_with?('foo').should be_true
132
+ end
133
+ end
134
+
135
+ describe "#=~" do
136
+ it "runs ok" do
137
+ (Pa('/home/foo') =~ /foo/).should be_true
138
+ end
139
+ end
140
+
141
+
142
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe Pa do
4
+ describe "#chmod" do
5
+ #Pa("path_doesn't_exists").chmod(777)
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ require "pa"
2
+
data/version.rb ADDED
@@ -0,0 +1,9 @@
1
+ class Pa
2
+ module VERSION
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ PATCH = 0
6
+
7
+ IS = [MAJOR, MINOR, PATCH].join(".")
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pa
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Guten
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-06-08 00:00:00 +08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ prerelease: false
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: watchr
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ version: "0"
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: *id002
46
+ description: |
47
+ a good lib
48
+
49
+ email: ywzhaifei@Gmail.com
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ extra_rdoc_files: []
55
+
56
+ files:
57
+ - .gitignore
58
+ - .rspec
59
+ - Gemfile
60
+ - Gemfile.lock
61
+ - LICENSE
62
+ - README.md
63
+ - Ragfile
64
+ - lib/pa.rb
65
+ - lib/pa/cmd.rb
66
+ - lib/pa/core.rb
67
+ - lib/pa/dir.rb
68
+ - lib/pa/path.rb
69
+ - lib/pa/state.rb
70
+ - pa.gemspec
71
+ - pa.watchr
72
+ - spec/pa/cmd_spec.rb
73
+ - spec/pa/dir_spec.rb
74
+ - spec/pa/path_spec.rb
75
+ - spec/pa/state_spec.rb
76
+ - spec/spec_helper.rb
77
+ - version.rb
78
+ has_rdoc: true
79
+ homepage: http://github.com/GutenLinux/pa
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options: []
84
+
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ requirements: []
104
+
105
+ rubyforge_project: xx
106
+ rubygems_version: 1.3.7
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: a good lib
110
+ test_files: []
111
+