id2path 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/id2path.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "id2path"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["zhuzhe"]
data/lib/id2path.rb CHANGED
@@ -2,9 +2,10 @@ module Id2path
2
2
 
3
3
  def create_path root
4
4
  dir1, dir2, file = self.id.to_s.rjust(9, '0').scan(/\d{3}/)
5
- Dir.mkdir(root.join(dir1)) unless File.directory?(root.join(dir1))
6
- Dir.mkdir(root.join(dir1, dir2)) unless File.directory?(root.join(dir1, dir2))
5
+ Dir.mkdir(File.join(root, dir1)) unless File.directory?(File.join(root, dir1))
6
+ Dir.mkdir(File.join(root, dir1, dir2)) unless File.directory?(File.join(root, dir1, dir2))
7
7
  File.join(root, dir1, dir2, file)
8
8
  end
9
9
 
10
+
10
11
  end
data/test/test_id2path.rb CHANGED
@@ -1,7 +1,23 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestId2path < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
4
+
5
+ context 'a object with a id attribute' do
6
+ setup do
7
+ C = Class.new {
8
+ include Id2path
9
+
10
+ def id
11
+ @id = '123456'
12
+ end
13
+ }
14
+ @object_with_id = C.new
15
+ end
16
+
17
+ should "create dir and file for id" do
18
+ path = @object_with_id.create_path(File.expand_path('~'))
19
+ assert_equal File.expand_path(path, '~'), path
20
+ end
21
+ end
22
+
7
23
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: id2path
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - zhuzhe