simply_useful 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bbd88d007d989efbf973824277509e1ae98fd7b5
4
+ data.tar.gz: 762de8ab1ba560756bcd15a3698fc9a310600d98
5
+ SHA512:
6
+ metadata.gz: 88586ead1142b059376e44371378decd7ab9816958121d015f61f296f765845baf2e9f3e6181393cba99d3c0b336ecec302aa9688fe8faa00e64b5f8e763a233
7
+ data.tar.gz: e12ed12a71309f546ae302dc24f314380b21dda0fe1b00da7e9fa94b8c3e2709865e2d8cc0943c4d8efcf1d30f1f1ad24282a9bea60138f95159ac19b586c2c1
data/Gemfile CHANGED
@@ -1,16 +1,11 @@
1
1
  source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
2
 
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
3
  group :development do
9
- gem "rspec", "~> 2.12.0"
10
- gem "rdoc", "~> 3.12"
11
- gem "bundler", "~> 1.2.0"
12
- gem "jeweler", "~> 1.8.4"
13
- gem "simplecov", ">= 0", :require => false
4
+ gem 'rspec', '~> 2.14'
5
+ gem 'rdoc', '~> 3.12'
6
+ gem 'bundler', '~> 1.5.0'
7
+ gem 'jeweler', '~> 1.8.4'
8
+ gem 'simplecov', '>= 0', :require => false
14
9
 
15
- gem "activesupport", "~> 3"
10
+ gem 'activesupport', '~> 4'
16
11
  end
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 1
4
+ :patch: 2
5
5
  :build:
@@ -1,3 +1,6 @@
1
1
  module SimplyUseful
2
2
  # Just a placeholder
3
- end
3
+ module All
4
+
5
+ end
6
+ end
@@ -1,3 +1,7 @@
1
+ #
2
+ # DEPRECATED. Ruby now has a binary search built in
3
+ #
4
+
1
5
  #
2
6
  # Ruby/Bsearch - a binary search library for Ruby.
3
7
  #
@@ -75,8 +79,6 @@ module SimplyUseful
75
79
  end
76
80
  end
77
81
 
78
- alias bsearch bsearch_first
79
-
80
82
  #
81
83
  # Return the upper boundary. (outside)
82
84
  #
@@ -124,7 +126,7 @@ module SimplyUseful
124
126
  end
125
127
 
126
128
  def bfind(range = 0 ... self.length, &block)
127
- pos = self.bsearch(range, &block)
129
+ pos = self.bsearch_first(range, &block)
128
130
  return nil if pos.nil?
129
131
  self[pos]
130
132
  end
@@ -0,0 +1,15 @@
1
+ # CLI utilities
2
+
3
+ module SimplyUseful
4
+ module Cli
5
+ def run(cmd, env = nil, opts = {})
6
+ args = []
7
+ args << env unless env.nil?
8
+ args << cmd
9
+
10
+ puts("Running #{opts[:orig_cmd] || cmd}...")
11
+ system(*args)
12
+ end
13
+
14
+ end
15
+ end
@@ -2,14 +2,15 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: simply_useful 0.2.2 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "simply_useful"
8
- s.version = "0.2.1"
9
+ s.version = "0.2.2"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
12
  s.authors = ["Maciej Bilas"]
12
- s.date = "2012-12-18"
13
+ s.date = "2014-03-07"
13
14
  s.description = "A set of simply useful classes. Contains extensions to core Ruby classes."
14
15
  s.email = "maciej.bilas@gmail.com"
15
16
  s.extra_rdoc_files = [
@@ -26,18 +27,18 @@ Gem::Specification.new do |s|
26
27
  "lib/simply_useful.rb",
27
28
  "lib/simply_useful/all.rb",
28
29
  "lib/simply_useful/bsearch.rb",
30
+ "lib/simply_useful/cli.rb",
29
31
  "lib/simply_useful/core_ext.rb",
30
32
  "lib/simply_useful/core_ext/hash.rb",
31
33
  "lib/simply_useful/core_ext/module/property_delegation.rb",
32
34
  "lib/simply_useful/format.rb",
33
35
  "lib/simply_useful/has_attributes.rb",
34
- "lib/simply_useful/java_native2ascii.rb",
35
36
  "simply_useful.gemspec",
36
37
  "spec/bsearch_spec.rb",
38
+ "spec/cli_runner.rb",
37
39
  "spec/core_ext/hash_spec.rb",
38
40
  "spec/core_ext/property_delegation_spec.rb",
39
41
  "spec/has_attributes_spec.rb",
40
- "spec/java_native2ascii_spec.rb",
41
42
  "spec/simply_useful_all_spec.rb",
42
43
  "spec/simply_useful_spec.rb",
43
44
  "spec/spec.opts",
@@ -47,34 +48,34 @@ Gem::Specification.new do |s|
47
48
  s.licenses = ["MIT"]
48
49
  s.require_paths = ["lib"]
49
50
  s.rubyforge_project = "simply_useful"
50
- s.rubygems_version = "1.8.24"
51
+ s.rubygems_version = "2.1.10"
51
52
  s.summary = "A set of simply useful classes"
52
53
 
53
54
  if s.respond_to? :specification_version then
54
- s.specification_version = 3
55
+ s.specification_version = 4
55
56
 
56
57
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
- s.add_development_dependency(%q<rspec>, ["~> 2.12.0"])
58
+ s.add_development_dependency(%q<rspec>, ["~> 2.14"])
58
59
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
59
- s.add_development_dependency(%q<bundler>, ["~> 1.2.0"])
60
+ s.add_development_dependency(%q<bundler>, ["~> 1.5.0"])
60
61
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
61
62
  s.add_development_dependency(%q<simplecov>, [">= 0"])
62
- s.add_development_dependency(%q<activesupport>, ["~> 3"])
63
+ s.add_development_dependency(%q<activesupport>, ["~> 4"])
63
64
  else
64
- s.add_dependency(%q<rspec>, ["~> 2.12.0"])
65
+ s.add_dependency(%q<rspec>, ["~> 2.14"])
65
66
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
66
- s.add_dependency(%q<bundler>, ["~> 1.2.0"])
67
+ s.add_dependency(%q<bundler>, ["~> 1.5.0"])
67
68
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
68
69
  s.add_dependency(%q<simplecov>, [">= 0"])
69
- s.add_dependency(%q<activesupport>, ["~> 3"])
70
+ s.add_dependency(%q<activesupport>, ["~> 4"])
70
71
  end
71
72
  else
72
- s.add_dependency(%q<rspec>, ["~> 2.12.0"])
73
+ s.add_dependency(%q<rspec>, ["~> 2.14"])
73
74
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
74
- s.add_dependency(%q<bundler>, ["~> 1.2.0"])
75
+ s.add_dependency(%q<bundler>, ["~> 1.5.0"])
75
76
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
76
77
  s.add_dependency(%q<simplecov>, [">= 0"])
77
- s.add_dependency(%q<activesupport>, ["~> 3"])
78
+ s.add_dependency(%q<activesupport>, ["~> 4"])
78
79
  end
79
80
  end
80
81
 
data/spec/bsearch_spec.rb CHANGED
@@ -30,10 +30,10 @@ describe SimplyUseful::Bsearch do
30
30
 
31
31
  describe ".bsearch" do
32
32
  it "should return the first position of an object" do
33
- @array_with_duplicates.bsearch{|x| x <=> 1}.should == 0
34
- @array_with_duplicates.bsearch{|x| x <=> 3}.should == 3
35
- @array_with_duplicates.bsearch{|x| x <=> 4}.should == 4
36
- @array_with_duplicates.bsearch{|x| x <=> 14}.should == @array_with_duplicates.length-3
33
+ @array_with_duplicates.bsearch_first{|x| x <=> 1}.should == 0
34
+ @array_with_duplicates.bsearch_first{|x| x <=> 3}.should == 3
35
+ @array_with_duplicates.bsearch_first{|x| x <=> 4}.should == 4
36
+ @array_with_duplicates.bsearch_first{|x| x <=> 14}.should == @array_with_duplicates.length-3
37
37
  end
38
38
  end
39
39
 
@@ -0,0 +1,8 @@
1
+ # Breaks IntelliJ code completion.
2
+ #$:.unshift(File.dirname(__FILE__) + '/../lib')
3
+
4
+ require '../lib/simply_useful/cli'
5
+
6
+ include SimplyUseful::Cli
7
+
8
+ run('ls')
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,6 @@
1
- require 'rubygems'
2
1
  require 'rspec'
3
2
 
4
3
  require "simplecov"
5
4
  SimpleCov.start if ENV['COVERAGE']
6
5
 
7
- $:.unshift(File.dirname(__FILE__) + '/../lib')
6
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simply_useful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.2.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Maciej Bilas
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-18 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 2.12.0
19
+ version: '2.14'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 2.12.0
26
+ version: '2.14'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rdoc
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,23 +41,20 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: 1.2.0
47
+ version: 1.5.0
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: 1.2.0
54
+ version: 1.5.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: jeweler
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,35 +69,31 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: simplecov
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: activesupport
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
101
- version: '3'
89
+ version: '4'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
109
- version: '3'
96
+ version: '4'
110
97
  description: A set of simply useful classes. Contains extensions to core Ruby classes.
111
98
  email: maciej.bilas@gmail.com
112
99
  executables: []
@@ -124,18 +111,18 @@ files:
124
111
  - lib/simply_useful.rb
125
112
  - lib/simply_useful/all.rb
126
113
  - lib/simply_useful/bsearch.rb
114
+ - lib/simply_useful/cli.rb
127
115
  - lib/simply_useful/core_ext.rb
128
116
  - lib/simply_useful/core_ext/hash.rb
129
117
  - lib/simply_useful/core_ext/module/property_delegation.rb
130
118
  - lib/simply_useful/format.rb
131
119
  - lib/simply_useful/has_attributes.rb
132
- - lib/simply_useful/java_native2ascii.rb
133
120
  - simply_useful.gemspec
134
121
  - spec/bsearch_spec.rb
122
+ - spec/cli_runner.rb
135
123
  - spec/core_ext/hash_spec.rb
136
124
  - spec/core_ext/property_delegation_spec.rb
137
125
  - spec/has_attributes_spec.rb
138
- - spec/java_native2ascii_spec.rb
139
126
  - spec/simply_useful_all_spec.rb
140
127
  - spec/simply_useful_spec.rb
141
128
  - spec/spec.opts
@@ -143,29 +130,25 @@ files:
143
130
  homepage: http://github.com/maciej/simply_useful
144
131
  licenses:
145
132
  - MIT
133
+ metadata: {}
146
134
  post_install_message:
147
135
  rdoc_options: []
148
136
  require_paths:
149
137
  - lib
150
138
  required_ruby_version: !ruby/object:Gem::Requirement
151
- none: false
152
139
  requirements:
153
- - - ! '>='
140
+ - - '>='
154
141
  - !ruby/object:Gem::Version
155
142
  version: '0'
156
- segments:
157
- - 0
158
- hash: 4481099966841840911
159
143
  required_rubygems_version: !ruby/object:Gem::Requirement
160
- none: false
161
144
  requirements:
162
- - - ! '>='
145
+ - - '>='
163
146
  - !ruby/object:Gem::Version
164
147
  version: '0'
165
148
  requirements: []
166
149
  rubyforge_project: simply_useful
167
- rubygems_version: 1.8.24
150
+ rubygems_version: 2.1.10
168
151
  signing_key:
169
- specification_version: 3
152
+ specification_version: 4
170
153
  summary: A set of simply useful classes
171
154
  test_files: []
@@ -1,47 +0,0 @@
1
- require('iconv')
2
-
3
- # Mimics Java's native2ascii tool
4
- module SimplyUseful
5
- class JavaNative2Ascii
6
- def self.ascii2native str
7
- str.gsub(/\\u[0-9a-f]{4}/i) do |s|
8
- out = ""
9
- i = s[2, 4].hex
10
- out << (i & 0xFF)
11
- out << (i >> 8)
12
- # Tested on MacOS 10.6
13
- # The UNICODE encoding name apparently disappeared from Iconv
14
- # I've changed it to UCS-2LE, which makes the Specs pass.
15
- out = Iconv.conv("UTF-8", "UCS-2LE", out)
16
- end
17
- end
18
-
19
- def self.native2ascii str
20
- out = ""
21
-
22
- arr = str.unpack("U*")
23
- return out if arr.nil?
24
- # arr_s = arr.size
25
- # i = 0
26
- #
27
- # while i < arr_s
28
- # c = arr[i]
29
- # if c > 127
30
- # out << sprintf("\\u%04x", c)
31
- # else
32
- # out << c
33
- # end
34
- # i+=1
35
- # end
36
- arr.each do |c|
37
- if c > 127
38
- out << sprintf("\\u%04x", c)
39
- else
40
- out << c
41
- end
42
- end
43
- out
44
- end
45
-
46
- end
47
- end
@@ -1,35 +0,0 @@
1
- #!ruby19
2
- # encoding: utf-8
3
-
4
- require File.dirname(__FILE__) + '/spec_helper'
5
- require 'simply_useful/java_native2ascii'
6
-
7
- class JavaNative2AsciiHelper
8
- def native_ascii_pairs
9
- [
10
- ["foo=ęéëèAZ中文", "foo=\\u0119\\u00e9\\u00eb\\u00e8AZ\\u4e2d\\u6587"],
11
- ["foo=\304\231", "foo=\\u0119"],
12
- ["bar=bbzz", "bar=bbzz"]
13
- ] # Believe me! Those characters are there (even if they are not in your fontset!
14
- end
15
- end
16
-
17
- describe SimplyUseful::JavaNative2Ascii do
18
- before(:all) do
19
- @helper = JavaNative2AsciiHelper.new
20
- end
21
-
22
- it "should convert from ascii to native" do
23
- @helper.native_ascii_pairs.each do |native_ascii|
24
- native,ascii = native_ascii
25
- SimplyUseful::JavaNative2Ascii.ascii2native(ascii).should == native
26
- end
27
- end
28
-
29
- it "should convert from native to ascii" do
30
- @helper.native_ascii_pairs.each do |native_ascii|
31
- native,ascii = native_ascii
32
- SimplyUseful::JavaNative2Ascii.native2ascii(native).should == ascii
33
- end
34
- end
35
- end