core_extended 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ class File
2
+
3
+ if OS.windows? && RUBY_PLATFORM == 'java'
4
+ def size
5
+ lstat.size
6
+ end
7
+ end
8
+
9
+ end
@@ -0,0 +1,33 @@
1
+ class OS
2
+
3
+ def self.name
4
+ RbConfig::CONFIG['host_os']
5
+ end
6
+
7
+ def self.linux?
8
+ is? /linux/
9
+ end
10
+
11
+ def self.mac?
12
+ is? /darwin|mac os/
13
+ end
14
+
15
+ def self.windows?
16
+ is? /mswin|msys|mingw|cygwin|bccwin|wince|emc/
17
+ end
18
+
19
+ def self.unix?
20
+ is? /solaris|sunos|bsd/
21
+ end
22
+
23
+ def self.unknown?
24
+ !linux? && !mac? && !windows? && !unix?
25
+ end
26
+
27
+ private
28
+
29
+ def self.is?(regex)
30
+ !regex.match(name).nil?
31
+ end
32
+
33
+ end
@@ -1,3 +1,3 @@
1
1
  module CoreExtended
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
data/lib/core_extended.rb CHANGED
@@ -1 +1,6 @@
1
- Dir["#{File.dirname(__FILE__)}/#{File.basename(__FILE__, '.rb')}/*.rb"].each { |file| require file }
1
+ require 'core_extended/version'
2
+ require 'core_extended/os'
3
+ require 'core_extended/marshal'
4
+ require 'core_extended/file'
5
+ require 'core_extended/string'
6
+
data/spec/file_spec.rb ADDED
@@ -0,0 +1,10 @@
1
+ RbConfig::CONFIG['host_os'] = 'mswin'
2
+ require 'minitest_helper'
3
+
4
+ describe File do
5
+
6
+ it 'Fix size for windows and jruby' do
7
+ File.open(__FILE__, 'r') { |f| f.size.must_equal 193 }
8
+ end
9
+
10
+ end
data/spec/os_spec.rb ADDED
@@ -0,0 +1,40 @@
1
+ require 'minitest_helper'
2
+
3
+ describe OS do
4
+
5
+ def stub_os(name)
6
+ RbConfig::CONFIG['host_os'] = name
7
+ end
8
+
9
+ it 'Linux' do
10
+ stub_os 'linux-gnu'
11
+ OS.must_be :linux?
12
+ end
13
+
14
+ it 'Mac' do
15
+ ['darwin', 'mac os'].each do |name|
16
+ stub_os name
17
+ OS.must_be :mac?
18
+ end
19
+ end
20
+
21
+ it 'Windows' do
22
+ %w(mswin msys mingw cygwin bccwin wince emc).each do |name|
23
+ stub_os name
24
+ OS.must_be :windows?
25
+ end
26
+ end
27
+
28
+ it 'Unix' do
29
+ %w(solaris sunos bsd).each do |name|
30
+ stub_os name
31
+ OS.must_be :unix?
32
+ end
33
+ end
34
+
35
+ it 'Unkonw' do
36
+ stub_os 'invalid_so'
37
+ OS.must_be :unknown?
38
+ end
39
+
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core_extended
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-03 00:00:00.000000000 Z
12
+ date: 2013-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -107,12 +107,16 @@ files:
107
107
  - Rakefile
108
108
  - core_extended.gemspec
109
109
  - lib/core_extended.rb
110
+ - lib/core_extended/file.rb
110
111
  - lib/core_extended/marshal.rb
112
+ - lib/core_extended/os.rb
111
113
  - lib/core_extended/string.rb
112
114
  - lib/core_extended/version.rb
113
115
  - spec/coverage_helper.rb
116
+ - spec/file_spec.rb
114
117
  - spec/marshal_spec.rb
115
118
  - spec/minitest_helper.rb
119
+ - spec/os_spec.rb
116
120
  - spec/string_spec.rb
117
121
  homepage: https://github.com/gabynaiman/core_extended
118
122
  licenses:
@@ -141,7 +145,9 @@ specification_version: 3
141
145
  summary: Ruby core extensions
142
146
  test_files:
143
147
  - spec/coverage_helper.rb
148
+ - spec/file_spec.rb
144
149
  - spec/marshal_spec.rb
145
150
  - spec/minitest_helper.rb
151
+ - spec/os_spec.rb
146
152
  - spec/string_spec.rb
147
153
  has_rdoc: