temppath 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.simplecov ADDED
@@ -0,0 +1,7 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start {add_filter 'test'}
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - "2.0.0"
6
+ - jruby-19mode # JRuby in 1.9 mode
7
+ - rbx-19mode
8
+ script: rake test
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in temppath.gemspec
3
+ # Specify your gem's dependencies in forwardablex.gemspec
4
4
  gemspec
5
+
6
+ gem 'simplecov', :require => false, :group => :test
7
+ gem 'coveralls', :require => false, :group => :test
data/README.md CHANGED
@@ -5,6 +5,8 @@ from standard tempfile.rb are that this library generates Pathname objects with
5
5
  no files and filenames are based on UUID. Files in paths generated by this are
6
6
  deleted when Ruby exits.
7
7
 
8
+ [![Gem Version](https://badge.fury.io/rb/temppath.png)](http://badge.fury.io/rb/temppath) [![Build Status](https://travis-ci.org/keita/temppath.png?branch=master)](https://travis-ci.org/keita/temppath) [![Coverage Status](https://coveralls.io/repos/keita/temppath/badge.png?branch=master)](https://coveralls.io/r/keita/temppath) [![Code Climate](https://codeclimate.com/github/keita/temppath.png)](https://codeclimate.com/github/keita/temppath)
9
+
8
10
  ## Installation
9
11
 
10
12
  $ gem install temppath
@@ -17,9 +19,13 @@ path = Temppath.create
17
19
  path.exist? #=> false
18
20
  ```
19
21
 
20
- ## Licence
22
+ ## Documentation
23
+
24
+ - [API Documentation](http://www.rubydoc.info/gems/temppath/)
25
+
26
+ ## License
21
27
 
22
- Temppath is free software distributed under MIT licence.
28
+ Temppath is free software distributed under MIT license.
23
29
 
24
30
  ## Contributing
25
31
 
data/lib/temppath.rb CHANGED
@@ -13,9 +13,6 @@ require 'fileutils'
13
13
  # #=> #<Pathname:/tmp/ruby-temppath-20130407-5775-w5k77l/f41bd6c5-fc99-4b7a-8f68-95b7ae4a6b22>
14
14
  # path.exist? #=> false
15
15
  module Temppath
16
- @dir = Pathname.new(Dir.mktmpdir("ruby-temppath-"))
17
- @unlink = true
18
-
19
16
  class << self
20
17
  # @return [Pathname]
21
18
  # defalut temporary directory for paths created by Temppath
@@ -39,6 +36,33 @@ module Temppath
39
36
  return path
40
37
  end
41
38
 
39
+ # Remove curren temporary directory and create a new temporary directory and
40
+ # use it.
41
+ #
42
+ # @return [Pathname]
43
+ # new temporary directory
44
+ def update_tempdir
45
+ remove_tempdir
46
+ @dir = create_tempdir
47
+ end
48
+
49
+ # Remove current temporary directory.
50
+ #
51
+ # @return [void]
52
+ def remove_tempdir
53
+ FileUtils.remove_entry_secure(@dir) if @dir.exist?
54
+ end
55
+
56
+ private
57
+
58
+ # Create a new temporary directory.
59
+ #
60
+ # @return [Pathname]
61
+ # temporary directory
62
+ def create_tempdir
63
+ Pathname.new(Dir.mktmpdir("ruby-temppath-"))
64
+ end
65
+
42
66
  # Generate random UUID for filename of temporary path.
43
67
  #
44
68
  # @return [String]
@@ -46,13 +70,15 @@ module Temppath
46
70
  def generate_uuid
47
71
  UUIDTools::UUID.random_create.to_s
48
72
  end
49
- private :generate_uuid
50
73
  end
74
+
75
+ @dir = create_tempdir
76
+ @unlink = true
51
77
  end
52
78
 
53
79
  # Remove Temppath's temporary directory.
54
80
  Kernel.at_exit do
55
81
  if Temppath.unlink
56
- FileUtils.remove_entry_secure(Temppath.dir) rescue Errno::ENOENT
82
+ Temppath.remove_tempdir rescue Errno::ENOENT
57
83
  end
58
84
  end
@@ -1,4 +1,4 @@
1
1
  module Temppath
2
2
  # version of temppath gem
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
data/temppath.gemspec CHANGED
@@ -18,9 +18,9 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency "uuidtools", "~> 2.1.3"
22
- gem.add_development_dependency "bacon", "~> 1.2.0"
21
+ gem.add_dependency "uuidtools"
22
+ gem.add_development_dependency "bacon"
23
23
  gem.add_development_dependency "yard"
24
- gem.add_development_dependency "redcarpet"
24
+ gem.add_development_dependency "redcarpet" unless RUBY_PLATFORM == 'java'
25
25
  gem.add_development_dependency "rake"
26
26
  end
@@ -1,6 +1,11 @@
1
+ require 'simplecov'
1
2
  require 'temppath'
2
3
 
3
4
  describe 'Temppath' do
5
+ before do
6
+ Temppath.update_tempdir
7
+ end
8
+
4
9
  it 'should get temporary path' do
5
10
  Temppath.create.should.kind_of Pathname
6
11
  Temppath.create.should != Temppath.create
@@ -19,6 +24,19 @@ describe 'Temppath' do
19
24
  Temppath.create.dirname.should == Temppath.dir
20
25
  end
21
26
 
27
+ it 'should update current temporary directory' do
28
+ old_dir = Temppath.dir
29
+ new_dir = Temppath.update_tempdir
30
+ old_dir.should != new_dir
31
+ old_dir.should.not.exist
32
+ end
33
+
34
+ it 'should remove current temporary directory' do
35
+ dir = Temppath.dir
36
+ Temppath.remove_tempdir
37
+ dir.should.not.exist
38
+ end
39
+
22
40
  it 'should get unlink mode' do
23
41
  Temppath.unlink.should == true
24
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: temppath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,40 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-07 00:00:00.000000000 Z
12
+ date: 2013-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: uuidtools
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.1.3
21
+ version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 2.1.3
29
+ version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bacon
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 1.2.0
37
+ version: '0'
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 1.2.0
45
+ version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: yard
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +99,8 @@ extensions: []
99
99
  extra_rdoc_files: []
100
100
  files:
101
101
  - .gitignore
102
+ - .simplecov
103
+ - .travis.yml
102
104
  - Gemfile
103
105
  - LICENSE.txt
104
106
  - README.md
@@ -119,21 +121,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
121
  - - ! '>='
120
122
  - !ruby/object:Gem::Version
121
123
  version: '0'
122
- segments:
123
- - 0
124
- hash: 3842158434666347241
125
124
  required_rubygems_version: !ruby/object:Gem::Requirement
126
125
  none: false
127
126
  requirements:
128
127
  - - ! '>='
129
128
  - !ruby/object:Gem::Version
130
129
  version: '0'
131
- segments:
132
- - 0
133
- hash: 3842158434666347241
134
130
  requirements: []
135
131
  rubyforge_project:
136
- rubygems_version: 1.8.24
132
+ rubygems_version: 1.8.25
137
133
  signing_key:
138
134
  specification_version: 3
139
135
  summary: temppath provides the method to create temporary path