equire 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/equire.rb +178 -0
  3. data/lib/equire/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4ac87cec90f1c5eb0edf95f454cbfdf787ea9b3
4
- data.tar.gz: 5ae3129e60348aa1b5b867cd45ef809aa328a1a6
3
+ metadata.gz: d2b9de00fea8a66259bccdc87cba15afcb5e16f1
4
+ data.tar.gz: 75b54d2770395660ad1ae2588cd8c215316eb251
5
5
  SHA512:
6
- metadata.gz: f3b3dabe8ad8754be13812fad908ea50e2c51e9bbaf9d386408e3d3922a0c076f96d1966f0eaa6ba25acde9978374b058cedaf77c96c7b131a2afd992c94128b
7
- data.tar.gz: 4fc840b9a3c62508dd5530deb7ba95366f45ffe8a39c41229e1f9cbcaf87606c885f6a0b05f069d6643d8dff29803ed92453e80b200d1bec178b3abfc8f52599
6
+ metadata.gz: 2dbf76cd5d74ec2ff63d9c298703609c55bed27a4a393b1e1d2a98af6ca6dfaf5336e4bd7b32433cb37867c4ca7786a093adb713da19807624d78c4c409ddded
7
+ data.tar.gz: e61c4344eb7db8e196cab66c53bf0b1b0436f6423b2e99dff8309c362157885a57f58de8fab45cfdbc847a2abb4165c5097deb39a0489579938737fb15398a3e
@@ -10,6 +10,7 @@ require "equire/version"
10
10
  # TODO: racc/parser https://docs.ruby-lang.org/ja/latest/library/racc=2fparser.html
11
11
  # TODO: rinda https://docs.ruby-lang.org/ja/latest/library/rinda=2frinda.html
12
12
  # TODO: rubygems https://docs.ruby-lang.org/ja/latest/library/rubygems.html
13
+ # TODO: mkmf https://docs.ruby-lang.org/ja/latest/library/mkmf.html
13
14
 
14
15
  module Equire
15
16
  SimpleModules = %i[
@@ -72,6 +73,157 @@ module Equire
72
73
  OpenStruct: 'ostruct',
73
74
  }.freeze
74
75
 
76
+ InstanceMethods = [
77
+ [IO, :expect, 'expect'],
78
+
79
+ [IO, :cooked, 'io/console'],
80
+ [IO, :cooked!, 'io/console'],
81
+ [IO, :echo=, 'io/console'],
82
+ [IO, :echo?, 'io/console'],
83
+ [IO, :getch, 'io/console'],
84
+ [IO, :iflush, 'io/console'],
85
+ [IO, :ioflush, 'io/console'],
86
+ [IO, :noecho, 'io/console'],
87
+ [IO, :oflush, 'io/console'],
88
+ [IO, :raw, 'io/console'],
89
+ [IO, :raw!, 'io/console'],
90
+ [IO, :winsize, 'io/console'],
91
+ [IO, :winsize=, 'io/console'],
92
+
93
+ [String, :iseuc, 'kconv'],
94
+ [String, :isjis, 'kconv'],
95
+ [String, :issjis, 'kconv'],
96
+ [String, :isutf8, 'kconv'],
97
+ [String, :kconv, 'kconv'],
98
+ [String, :toeuc, 'kconv'],
99
+ [String, :tojis, 'kconv'],
100
+ [String, :tolocale, 'kconv'],
101
+ [String, :tosjis, 'kconv'],
102
+ [String, :toutf16, 'kconv'],
103
+ [String, :toutf32, 'kconv'],
104
+ [String, :toutf8, 'kconv'],
105
+
106
+ [Time, :to_date, 'date'],
107
+ [Time, :to_datetime, 'date'],
108
+ [Time, :to_time, 'date'],
109
+
110
+ [Time, :httpdate, 'time'],
111
+ [Time, :iso8601, 'time'],
112
+ [Time, :rfc2822, 'time'],
113
+
114
+ [Binding, :irb, 'irb'],
115
+
116
+ [Kernel, :pp, 'pp'],
117
+ [Object, :pretty_inspect, 'pp'],
118
+ [Object, :pretty_print, 'pp'],
119
+ [Object, :pretty_print_cycle, 'pp'],
120
+ [Object, :pretty_print_inspect, 'pp'],
121
+ [Object, :pretty_print_instance_variables, 'pp'],
122
+
123
+ [Kernel, :Pathname, 'pathname'],
124
+
125
+ [Class, :json_creatable?, 'json'],
126
+ [Kernel, :JSON, 'json'],
127
+ [Kernel, :j, 'json'],
128
+ [Kernel, :jj, 'json'],
129
+ [Exception, :to_json, 'json'],
130
+ [Range, :to_json, 'json'],
131
+ [Regexp, :to_json, 'json'],
132
+ [Struct, :to_json, 'json'],
133
+ [Time, :to_json, 'json'],
134
+
135
+ [Kernel, :psych_y, 'psych'],
136
+ [Module, :psych_yaml_as, 'psych'],
137
+ [Object, :psych_to_yaml, 'psych'],
138
+
139
+ [IO, :nonblock, 'io/nonblock'],
140
+ [IO, :nonblock=, 'io/nonblock'],
141
+ [IO, :nonblock?, 'io/nonblock'],
142
+
143
+ [IO, :nread, 'io/wait'],
144
+ [IO, :ready?, 'io/wait'],
145
+ [IO, :wait, 'io/wait'],
146
+ [IO, :wait_writable, 'io/wait'],
147
+
148
+ [IO, :scanf, 'scanf'],
149
+ [Kernel, :scanf, 'scanf'],
150
+ [String, :scanf, 'scanf'],
151
+
152
+ [Kernel, :BigDecimal, 'bigdecimal'],
153
+
154
+ [Integer, :prime?, 'prime'],
155
+ [Integer, :prime_division, 'prime'],
156
+
157
+ [Enumerable, :to_set, 'set'],
158
+
159
+ [Integer, :to_bn, 'openssl'],
160
+
161
+ [Kernel, :URI, 'uri'],
162
+
163
+ [Kernel, :Digest, 'digest'],
164
+
165
+ [Array, :shelljoin, 'shellwords'],
166
+ [String, :shellescape, 'shellwords'],
167
+ [String, :shellsplit, 'shellwords'],
168
+
169
+ [Kernel, :timeout, 'timeout'],
170
+
171
+ [IO, :pathconf, 'etc'],
172
+
173
+ [Array, :abbrev, 'abbrev'],
174
+
175
+ [Kernel, :callcc, 'continuation'],
176
+
177
+ [Fiber, :alive?, 'fiber'],
178
+ [Fiber, :transfer, 'fiber'],
179
+
180
+ [ObjectSpace, :count_nodes, 'objspace'],
181
+ [ObjectSpace, :count_objects_size, 'objspace'],
182
+ [ObjectSpace, :count_tdata_objects, 'objspace'],
183
+ [ObjectSpace, :memsize_of, 'objspace'],
184
+ [ObjectSpace, :memsize_of_all, 'objspace'],
185
+ [ObjectSpace, :reachable_objects_from, 'objspace'],
186
+ ].freeze
187
+
188
+ ClassMethods = [
189
+ [IO, :console, 'io/console'],
190
+
191
+ [Time, :httpdate, 'time'],
192
+ [Time, :iso8601, 'time'],
193
+ [Time, :parse, 'time'],
194
+ [Time, :rfc2822, 'time'],
195
+ [Time, :strptime, 'time'],
196
+
197
+ [Kernel, :pp, 'pp'],
198
+
199
+ [Dir, :mktmpdir, 'tmpdir'],
200
+ [Dir, :tmpdir, 'tmpdir'],
201
+
202
+ [Exception, :json_create, 'json'],
203
+ [Range, :json_create, 'json'],
204
+ [Regexp, :json_create, 'json'],
205
+ [Struct, :json_create, 'json'],
206
+ [Time, :json_create, 'json'],
207
+
208
+ [Object, :yaml_tag, 'psych'],
209
+
210
+ [Kernel, :BigDecimal, 'bigdecimal'],
211
+
212
+ [Integer, :each_prime, 'prime'],
213
+ [Integer, :from_prime_division, 'prime'],
214
+
215
+ [Kernel, :URI, 'uri'],
216
+
217
+ [Fiber, :current, 'fiber'],
218
+
219
+ [ObjectSpace, :count_nodes, 'objspace'],
220
+ [ObjectSpace, :count_objects_size, 'objspace'],
221
+ [ObjectSpace, :count_tdata_objects, 'objspace'],
222
+ [ObjectSpace, :memsize_of, 'objspace'],
223
+ [ObjectSpace, :memsize_of_all, 'objspace'],
224
+ [ObjectSpace, :reachable_objects_from, 'objspace'],
225
+ ]
226
+
75
227
  def Object.const_missing(name)
76
228
  case
77
229
  when SimpleModules.include?(name)
@@ -85,4 +237,30 @@ module Equire
85
237
  super
86
238
  end
87
239
  end
240
+
241
+ InstanceMethods.each do |klass, method, library|
242
+ eval <<~RUBY
243
+ #{klass.is_a?(Class) ? 'class' : 'module'} ::#{klass}
244
+ def #{method}(*args)
245
+ undef #{method}
246
+ require #{library.inspect}
247
+ __send__(#{method.inspect}, *args)
248
+ end
249
+ end
250
+ RUBY
251
+ end
252
+
253
+ ClassMethods.each do |klass, method, library|
254
+ eval <<~RUBY
255
+ #{klass.is_a?(Class) ? 'class' : 'module'} ::#{klass}
256
+ def self.#{method}(*args)
257
+ class << #{klass}
258
+ undef #{method}
259
+ end
260
+ require #{library.inspect}
261
+ __send__(#{method.inspect}, *args)
262
+ end
263
+ end
264
+ RUBY
265
+ end
88
266
  end
@@ -1,3 +1,3 @@
1
1
  module Equire
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: equire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masataka Pocke Kuwabara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-30 00:00:00.000000000 Z
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler