libciel 0.0.0.3 → 0.0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fa58b86ead83f8e76fad4c6c059365dcee1c1c2
4
- data.tar.gz: 6554e526034c197a4ede4383e89326891f2b0d04
3
+ metadata.gz: a1beff7563007f659cbd895f09df00ded56a3a77
4
+ data.tar.gz: ef5bd575643618ae8a7012bb6645b95143882fa8
5
5
  SHA512:
6
- metadata.gz: a65062be26d7329516af9e9da16b041e130e68bbd2573fb5f6c433b1284e47e99e1d402f58973f3cb58b6f15a7a2af5b31350a4e7d00d5fe9f1a08c1db4a1c35
7
- data.tar.gz: c0a1048afdc5b940e230ce6204c74970e7e580145df124bc19da37784a7bf596c1365c9e5372ddd2c0c9e4f6f1adfb13caaf6a2f08b2f481f29fb5e3532853d1
6
+ metadata.gz: 5637c324ddffd0fa76440d564a2b09af6b2c095a7de02ef8af3bb5e7517f73923cea49080cea959f2d3ca86875b8ea95ce22d6b441eb9783d2daba856711717b
7
+ data.tar.gz: 5e0a91f5910eebe5ff34806149c8239699fdffd27082fa6b978da62c435da79e8937fccc0689feb9c2286b1ac5db58f3f6bd9545014936971741e1089d6e54b5
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+ Gemfile.lock
@@ -1,7 +1,4 @@
1
1
  language: ruby
2
- before_install:
3
- - gem update --system 2.1.11
4
- - gem --version
5
2
  rvm:
6
3
  - 1.8.7
7
4
  - ree
@@ -9,15 +6,22 @@ rvm:
9
6
  - 1.9.3
10
7
  - 2.0.0
11
8
  - 2.1.0
9
+ - 2.1.7
10
+ - 2.2.0
11
+ - 2.2.3
12
12
  - ruby-head
13
13
  - jruby-18mode
14
14
  - jruby-19mode
15
15
  - jruby-20mode
16
16
  - jruby-21mode
17
17
  - jruby-head
18
- - rbx-2.1.1
19
- - rbx-2.2.3
18
+ - rbx-2
20
19
  matrix:
21
20
  allow_failures:
22
21
  - rvm: ruby-head
23
22
  - rvm: jruby-head
23
+ - rvm: jruby-18mode
24
+ - rvm: jruby-19mode
25
+ - rvm: jruby-20mode
26
+ - rvm: jruby-21mode
27
+ - rvm: rbx-2
data/Gemfile CHANGED
@@ -13,8 +13,13 @@ group :test do
13
13
  end
14
14
 
15
15
  group :development, :test do
16
+ if RUBY_VERSION<'1.9'
17
+ gem 'mime-types', '~> 1.0'
18
+ gem 'rest-client', '~> 1.6.0'
19
+ end
16
20
  gem 'bundler', '>= 1.0'
17
21
  gem 'rake'
18
22
  gem 'rspec'
19
23
  gem 'simplecov'
24
+ gem 'coveralls', :require => false
20
25
  end
@@ -0,0 +1,19 @@
1
+ #Note: this file is exactly the same as Hash#fetch_nested except the class name.
2
+
3
+ class Array
4
+ #nil safe version of Hash#[].
5
+ # a.fetch_nested(*[0,1]) is basically the same as a[0].try.send(:[],1).
6
+ def fetch_nested(*keys)
7
+ begin
8
+ keys.reduce(self){|accum, k| accum.fetch(k)}
9
+ rescue (RUBY_VERSION<'1.9' ? IndexError : KeyError)
10
+ block_given? ? yield(*keys) : nil
11
+ end
12
+ end
13
+
14
+ # Ruby 2.3 feature
15
+ # note: block yielding is libciel extention.
16
+ unless Hash.method_defined? :dig
17
+ alias :dig :fetch_nested
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ class Array
2
+ #Destructive version of Enumerable#squeeze
3
+ def squeeze!
4
+ replace(squeeze)
5
+ end
6
+ end
7
+
@@ -8,4 +8,10 @@ class Hash
8
8
  block_given? ? yield(*keys) : nil
9
9
  end
10
10
  end
11
+
12
+ # Ruby 2.3 feature
13
+ # note: block yielding is libciel extention.
14
+ unless Hash.method_defined? :dig
15
+ alias :dig :fetch_nested
16
+ end
11
17
  end
@@ -1,9 +1,12 @@
1
+ require File.expand_path(File.dirname(__FILE__)+'/array/fetch_nested')
1
2
  require File.expand_path(File.dirname(__FILE__)+'/array/permutation2')
3
+ require File.expand_path(File.dirname(__FILE__)+'/array/squeeze')
2
4
  require File.expand_path(File.dirname(__FILE__)+'/enumerable/squeeze')
3
5
  require File.expand_path(File.dirname(__FILE__)+'/enumerator/lazy/squeeze')
4
6
  require File.expand_path(File.dirname(__FILE__)+'/hash/fetch_nested')
5
7
  require File.expand_path(File.dirname(__FILE__)+'/kernel/zip')
6
8
  require File.expand_path(File.dirname(__FILE__)+'/object/extract')
9
+ require File.expand_path(File.dirname(__FILE__)+'/string/phpass')
7
10
  require File.expand_path(File.dirname(__FILE__)+'/string/rotate')
8
11
 
9
12
  #DBI stuff will be dropped in the future (maybe)
@@ -11,5 +14,5 @@ require File.expand_path(File.dirname(__FILE__)+'/dbi/connect_transaction')
11
14
 
12
15
  module LibCiel
13
16
  #Version string
14
- VERSION='0.0.0.3'
17
+ VERSION='0.0.0.5'
15
18
  end
@@ -0,0 +1,43 @@
1
+ require 'digest/md5'
2
+
3
+ class String
4
+ def phpass(encpass)
5
+ return "*" if !encpass || encpass.size < 12
6
+ table = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
7
+ cnt = table.index(encpass[3..3])
8
+ return "*" if cnt > 31
9
+ pass = self
10
+ cnt = 1 << cnt
11
+ salt = encpass[4, 8]
12
+ hash = Digest::MD5.digest(salt + pass)
13
+ cnt.times{
14
+ hash = Digest::MD5.digest(hash + pass)
15
+ }
16
+
17
+ result = encpass[0, 12]
18
+ i = 0
19
+ cnt = 16
20
+ while i < cnt
21
+ val = hash[i].ord; i += 1
22
+ result += table[val & 0x3f, 1]
23
+
24
+ val |= hash[i].ord << 8 if i < cnt
25
+ result += table[(val >> 6) & 0x3f, 1]
26
+ i += 1
27
+ break if i >= cnt
28
+
29
+ val |= hash[i].ord << 16 if i < cnt
30
+ result += table[(val >> 12) & 0x3f, 1]
31
+ i += 1
32
+ break if i >= cnt
33
+
34
+ result += table[(val >> 18) & 0x3f, 1]
35
+ end
36
+ return result
37
+ end
38
+
39
+ def gen_phpass
40
+ # todo: better random generation?
41
+ self.phpass('$P$B' + ([*'0'..'9'] + [*'a'..'z'] + [*'A'..'Z']).sample(8).join)
42
+ end
43
+ end
@@ -30,7 +30,7 @@ describe Enumerable do
30
30
  specify 'example' do
31
31
  [1,2,2,3,3,2,1].squeeze.should eq [1,2,3,2,1]
32
32
  end
33
- specify 'sort.squeeze is eq uniq' do
33
+ specify 'sort.squeeze eq uniq' do
34
34
  [1,2,2,3,3,2,1].sort.squeeze.should eq [1,2,3]
35
35
  end
36
36
  end
@@ -49,13 +49,21 @@ describe Array do
49
49
  [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2]
50
50
  ]
51
51
  end
52
- it 'is not eq permutation.to_a' do
52
+ it 'not eq permutation.to_a' do
53
53
  [1,1,2,3].permutation2.to_a.should_not eq [1,1,2,3].permutation.to_a
54
54
  end
55
- it 'is eq permutation.to_a.uniq' do
55
+ it 'eq permutation.to_a.uniq' do
56
56
  [1,1,2,3].permutation2.to_a.should eq [1,1,2,3].permutation.to_a.uniq
57
57
  end
58
58
  end
59
+ specify 'squeeze!' do
60
+ a=[1,2,2,3,3,2,1]
61
+ a.squeeze!
62
+ a.should eq [1,2,3,2,1]
63
+ end
64
+ specify 'fetch_nested' do
65
+ [[1,2,3]].fetch_nested(0,1).should eq 2
66
+ end
59
67
  end
60
68
 
61
69
  describe String do
@@ -79,6 +87,11 @@ describe String do
79
87
  s.should eq 'ghabcdef'
80
88
  end
81
89
  end
90
+ specify 'phpass' do
91
+ s='hello'
92
+ encpass=s.gen_phpass
93
+ s.phpass(encpass).should eq encpass
94
+ end
82
95
  end
83
96
 
84
97
  describe Hash do
@@ -5,6 +5,11 @@ RSpec.configure{|config|
5
5
 
6
6
  if !defined?(RUBY_ENGINE)||RUBY_ENGINE=='ruby'
7
7
  require 'simplecov'
8
+ require 'coveralls'
9
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
10
+ SimpleCov::Formatter::HTMLFormatter,
11
+ Coveralls::SimpleCov::Formatter
12
+ ]
8
13
  SimpleCov.start do
9
14
  add_filter 'spec'
10
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libciel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.3
4
+ version: 0.0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - cielavenir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-24 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -59,15 +59,17 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - .coveralls.yml
62
63
  - .gitignore
63
64
  - .travis.yml
64
65
  - CHANGELOG.md
65
66
  - Gemfile
66
- - Gemfile.lock
67
67
  - LICENSE.txt
68
68
  - README.md
69
69
  - Rakefile
70
+ - lib/array/fetch_nested.rb
70
71
  - lib/array/permutation2.rb
72
+ - lib/array/squeeze.rb
71
73
  - lib/dbi/connect_transaction.rb
72
74
  - lib/enumerable/squeeze.rb
73
75
  - lib/enumerator/lazy/squeeze.rb
@@ -75,6 +77,7 @@ files:
75
77
  - lib/kernel/zip.rb
76
78
  - lib/libciel.rb
77
79
  - lib/object/extract.rb
80
+ - lib/string/phpass.rb
78
81
  - lib/string/rotate.rb
79
82
  - libciel.gemspec
80
83
  - spec/libciel_spec.rb
@@ -100,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
103
  version: '0'
101
104
  requirements: []
102
105
  rubyforge_project:
103
- rubygems_version: 2.0.3
106
+ rubygems_version: 2.0.14.1
104
107
  signing_key:
105
108
  specification_version: 4
106
109
  summary: ciel's useful libraries of Ruby
@@ -1,246 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- backports (3.4.0)
5
- dbd-sqlite3 (1.2.5)
6
- dbi (>= 0.4.0)
7
- sqlite3-ruby
8
- dbi (0.4.5)
9
- deprecated (= 2.0.1)
10
- deprecated (2.0.1)
11
- diff-lcs (1.2.5)
12
- docile (1.1.1)
13
- ffi2-generators (0.1.1)
14
- multi_json (1.8.2)
15
- rake (10.1.1)
16
- rspec (2.14.1)
17
- rspec-core (~> 2.14.0)
18
- rspec-expectations (~> 2.14.0)
19
- rspec-mocks (~> 2.14.0)
20
- rspec-core (2.14.7)
21
- rspec-expectations (2.14.4)
22
- diff-lcs (>= 1.1.3, < 2.0)
23
- rspec-mocks (2.14.4)
24
- rubysl (2.0.15)
25
- rubysl-abbrev (~> 2.0)
26
- rubysl-base64 (~> 2.0)
27
- rubysl-benchmark (~> 2.0)
28
- rubysl-bigdecimal (~> 2.0)
29
- rubysl-cgi (~> 2.0)
30
- rubysl-cgi-session (~> 2.0)
31
- rubysl-cmath (~> 2.0)
32
- rubysl-complex (~> 2.0)
33
- rubysl-continuation (~> 2.0)
34
- rubysl-coverage (~> 2.0)
35
- rubysl-csv (~> 2.0)
36
- rubysl-curses (~> 2.0)
37
- rubysl-date (~> 2.0)
38
- rubysl-delegate (~> 2.0)
39
- rubysl-digest (~> 2.0)
40
- rubysl-drb (~> 2.0)
41
- rubysl-e2mmap (~> 2.0)
42
- rubysl-english (~> 2.0)
43
- rubysl-enumerator (~> 2.0)
44
- rubysl-erb (~> 2.0)
45
- rubysl-etc (~> 2.0)
46
- rubysl-expect (~> 2.0)
47
- rubysl-fcntl (~> 2.0)
48
- rubysl-fiber (~> 2.0)
49
- rubysl-fileutils (~> 2.0)
50
- rubysl-find (~> 2.0)
51
- rubysl-forwardable (~> 2.0)
52
- rubysl-getoptlong (~> 2.0)
53
- rubysl-gserver (~> 2.0)
54
- rubysl-io-console (~> 2.0)
55
- rubysl-io-nonblock (~> 2.0)
56
- rubysl-io-wait (~> 2.0)
57
- rubysl-ipaddr (~> 2.0)
58
- rubysl-irb (~> 2.0)
59
- rubysl-logger (~> 2.0)
60
- rubysl-mathn (~> 2.0)
61
- rubysl-matrix (~> 2.0)
62
- rubysl-mkmf (~> 2.0)
63
- rubysl-monitor (~> 2.0)
64
- rubysl-mutex_m (~> 2.0)
65
- rubysl-net-ftp (~> 2.0)
66
- rubysl-net-http (~> 2.0)
67
- rubysl-net-imap (~> 2.0)
68
- rubysl-net-pop (~> 2.0)
69
- rubysl-net-protocol (~> 2.0)
70
- rubysl-net-smtp (~> 2.0)
71
- rubysl-net-telnet (~> 2.0)
72
- rubysl-nkf (~> 2.0)
73
- rubysl-observer (~> 2.0)
74
- rubysl-open-uri (~> 2.0)
75
- rubysl-open3 (~> 2.0)
76
- rubysl-openssl (~> 2.0)
77
- rubysl-optparse (~> 2.0)
78
- rubysl-ostruct (~> 2.0)
79
- rubysl-pathname (~> 2.0)
80
- rubysl-prettyprint (~> 2.0)
81
- rubysl-prime (~> 2.0)
82
- rubysl-profile (~> 2.0)
83
- rubysl-profiler (~> 2.0)
84
- rubysl-pstore (~> 2.0)
85
- rubysl-pty (~> 2.0)
86
- rubysl-rational (~> 2.0)
87
- rubysl-readline (~> 2.0)
88
- rubysl-resolv (~> 2.0)
89
- rubysl-rexml (~> 2.0)
90
- rubysl-rinda (~> 2.0)
91
- rubysl-rss (~> 2.0)
92
- rubysl-scanf (~> 2.0)
93
- rubysl-securerandom (~> 2.0)
94
- rubysl-set (~> 2.0)
95
- rubysl-shellwords (~> 2.0)
96
- rubysl-singleton (~> 2.0)
97
- rubysl-socket (~> 2.0)
98
- rubysl-stringio (~> 2.0)
99
- rubysl-strscan (~> 2.0)
100
- rubysl-sync (~> 2.0)
101
- rubysl-syslog (~> 2.0)
102
- rubysl-tempfile (~> 2.0)
103
- rubysl-thread (~> 2.0)
104
- rubysl-thwait (~> 2.0)
105
- rubysl-time (~> 2.0)
106
- rubysl-timeout (~> 2.0)
107
- rubysl-tmpdir (~> 2.0)
108
- rubysl-tsort (~> 2.0)
109
- rubysl-un (~> 2.0)
110
- rubysl-uri (~> 2.0)
111
- rubysl-weakref (~> 2.0)
112
- rubysl-webrick (~> 2.0)
113
- rubysl-xmlrpc (~> 2.0)
114
- rubysl-yaml (~> 2.0)
115
- rubysl-zlib (~> 2.0)
116
- rubysl-abbrev (2.0.4)
117
- rubysl-base64 (2.0.0)
118
- rubysl-benchmark (2.0.1)
119
- rubysl-bigdecimal (2.0.2)
120
- rubysl-cgi (2.0.1)
121
- rubysl-cgi-session (2.0.1)
122
- rubysl-cmath (2.0.0)
123
- rubysl-complex (2.0.0)
124
- rubysl-continuation (2.0.0)
125
- rubysl-coverage (2.0.3)
126
- rubysl-csv (2.0.2)
127
- rubysl-english (~> 2.0)
128
- rubysl-curses (2.0.1)
129
- rubysl-date (2.0.6)
130
- rubysl-delegate (2.0.1)
131
- rubysl-digest (2.0.3)
132
- rubysl-drb (2.0.1)
133
- rubysl-e2mmap (2.0.0)
134
- rubysl-english (2.0.0)
135
- rubysl-enumerator (2.0.0)
136
- rubysl-erb (2.0.1)
137
- rubysl-etc (2.0.3)
138
- ffi2-generators (~> 0.1)
139
- rubysl-expect (2.0.0)
140
- rubysl-fcntl (2.0.4)
141
- ffi2-generators (~> 0.1)
142
- rubysl-fiber (2.0.0)
143
- rubysl-fileutils (2.0.3)
144
- rubysl-find (2.0.1)
145
- rubysl-forwardable (2.0.1)
146
- rubysl-getoptlong (2.0.0)
147
- rubysl-gserver (2.0.0)
148
- rubysl-socket (~> 2.0)
149
- rubysl-thread (~> 2.0)
150
- rubysl-io-console (2.0.0)
151
- rubysl-io-nonblock (2.0.0)
152
- rubysl-io-wait (2.0.0)
153
- rubysl-ipaddr (2.0.0)
154
- rubysl-irb (2.0.4)
155
- rubysl-e2mmap (~> 2.0)
156
- rubysl-mathn (~> 2.0)
157
- rubysl-readline (~> 2.0)
158
- rubysl-thread (~> 2.0)
159
- rubysl-logger (2.0.0)
160
- rubysl-mathn (2.0.0)
161
- rubysl-matrix (2.1.0)
162
- rubysl-e2mmap (~> 2.0)
163
- rubysl-mkmf (2.0.1)
164
- rubysl-fileutils (~> 2.0)
165
- rubysl-shellwords (~> 2.0)
166
- rubysl-monitor (2.0.0)
167
- rubysl-mutex_m (2.0.0)
168
- rubysl-net-ftp (2.0.1)
169
- rubysl-net-http (2.0.4)
170
- rubysl-cgi (~> 2.0)
171
- rubysl-erb (~> 2.0)
172
- rubysl-singleton (~> 2.0)
173
- rubysl-net-imap (2.0.1)
174
- rubysl-net-pop (2.0.1)
175
- rubysl-net-protocol (2.0.1)
176
- rubysl-net-smtp (2.0.1)
177
- rubysl-net-telnet (2.0.0)
178
- rubysl-nkf (2.0.1)
179
- rubysl-observer (2.0.0)
180
- rubysl-open-uri (2.0.0)
181
- rubysl-open3 (2.0.0)
182
- rubysl-openssl (2.0.5)
183
- rubysl-optparse (2.0.1)
184
- rubysl-shellwords (~> 2.0)
185
- rubysl-ostruct (2.0.4)
186
- rubysl-pathname (2.0.0)
187
- rubysl-prettyprint (2.0.2)
188
- rubysl-prime (2.0.1)
189
- rubysl-profile (2.0.0)
190
- rubysl-profiler (2.0.1)
191
- rubysl-pstore (2.0.0)
192
- rubysl-pty (2.0.2)
193
- rubysl-rational (2.0.1)
194
- rubysl-readline (2.0.2)
195
- rubysl-resolv (2.0.0)
196
- rubysl-rexml (2.0.2)
197
- rubysl-rinda (2.0.0)
198
- rubysl-rss (2.0.0)
199
- rubysl-scanf (2.0.0)
200
- rubysl-securerandom (2.0.0)
201
- rubysl-set (2.0.1)
202
- rubysl-shellwords (2.0.0)
203
- rubysl-singleton (2.0.0)
204
- rubysl-socket (2.0.1)
205
- rubysl-stringio (2.0.0)
206
- rubysl-strscan (2.0.0)
207
- rubysl-sync (2.0.0)
208
- rubysl-syslog (2.0.1)
209
- ffi2-generators (~> 0.1)
210
- rubysl-tempfile (2.0.1)
211
- rubysl-thread (2.0.2)
212
- rubysl-thwait (2.0.0)
213
- rubysl-time (2.0.3)
214
- rubysl-timeout (2.0.0)
215
- rubysl-tmpdir (2.0.0)
216
- rubysl-tsort (2.0.1)
217
- rubysl-un (2.0.0)
218
- rubysl-fileutils (~> 2.0)
219
- rubysl-optparse (~> 2.0)
220
- rubysl-uri (2.0.0)
221
- rubysl-weakref (2.0.0)
222
- rubysl-webrick (2.0.0)
223
- rubysl-xmlrpc (2.0.0)
224
- rubysl-yaml (2.0.4)
225
- rubysl-zlib (2.0.1)
226
- simplecov (0.8.2)
227
- docile (~> 1.1.0)
228
- multi_json
229
- simplecov-html (~> 0.8.0)
230
- simplecov-html (0.8.0)
231
- sqlite3 (1.3.8)
232
- sqlite3-ruby (1.3.3)
233
- sqlite3 (>= 1.3.3)
234
-
235
- PLATFORMS
236
- ruby
237
-
238
- DEPENDENCIES
239
- backports
240
- bundler (>= 1.0)
241
- dbd-sqlite3
242
- dbi
243
- rake
244
- rspec
245
- rubysl
246
- simplecov