console_utils 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -17
- data/lib/awesome_print/proc.rb +0 -2
- data/lib/console_utils.rb +2 -2
- data/lib/console_utils/request_utils/requester.rb +2 -2
- data/lib/console_utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db3cc812c5661b7c40bc42c28bf05b6e76a42edb
|
4
|
+
data.tar.gz: 6bd072010709a36781fd9f699ccede62917d1b01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0201a12347ff3f30cda294fcd1e83132aa7ff3309eeb11f780f4982c369bb3cb2ff893c5c7d05eeb82b321aa13cdf34c706a13a25137d45d29694904b3103c4
|
7
|
+
data.tar.gz: eb94b91e56d4a1b5739a6789a4487b3a12168a33f081e019bb3f42d3bf6dd2e19dc4570cd601f79077284fcc6810567f1babec89053a9ce69f82c0d1500d5d2e
|
data/README.md
CHANGED
@@ -1,34 +1,36 @@
|
|
1
|
+
[](https://codeclimate.com/github/estum/console_utils)
|
2
|
+
|
1
3
|
# Rails Console Utils
|
2
4
|
|
3
5
|
ConsoleUtils gem provides several handy tools to use in Rails Console. It includes following modules:
|
4
6
|
|
5
|
-
1. **[RequestUtils](#requestutils)**
|
6
|
-
the collection of methods to make either local or remote JSON API requests.
|
7
|
-
Provides response body formatting and auto-token authentication feature
|
7
|
+
1. **[RequestUtils](#requestutils)**
|
8
|
+
the collection of methods to make either local or remote JSON API requests.
|
9
|
+
Provides response body formatting and auto-token authentication feature
|
8
10
|
(currently supports only params tokens).
|
9
|
-
2. **[BenchUtils](#benchutils)**
|
11
|
+
2. **[BenchUtils](#benchutils)**
|
10
12
|
benchmark shorthands
|
11
|
-
3. **[ActiveRecordUtils](#activerecordutils)**
|
13
|
+
3. **[ActiveRecordUtils](#activerecordutils)**
|
12
14
|
useful console methods for ActiveRecord::Base models
|
13
|
-
4. **[OtherUtils](#otherutils)**
|
15
|
+
4. **[OtherUtils](#otherutils)**
|
14
16
|
uncategorized methods
|
15
17
|
|
16
18
|
The gem was collected from several **very *(very-very)* raw** modules used in different projects in different time. The code was refactored, but currently there are no specs or complete docs (sowwy ^_^), but they are *coming soon*.
|
17
19
|
|
18
20
|
## Installation
|
19
21
|
|
20
|
-
Add this lines to your application's Gemfile.
|
22
|
+
Add this lines to your application's Gemfile.
|
21
23
|
**Note**: when using with `pry-rails` gem, make sure to depend it before this gem.
|
22
24
|
|
23
25
|
```ruby
|
24
26
|
group :development do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
## to enable inspecting procs' sources, uncomment next lines:
|
28
|
+
# gem 'term-ansicolor', '1.1.5'
|
29
|
+
# gem 'sourcify', '~> 0.6.0.rc4', require: false
|
30
|
+
|
31
|
+
## when using `pry-rails`, it should be somewhere here:
|
30
32
|
# gem 'pry-rails'
|
31
|
-
|
33
|
+
|
32
34
|
gem 'console_utils'
|
33
35
|
end
|
34
36
|
```
|
@@ -116,7 +118,7 @@ Just add reports:
|
|
116
118
|
```ruby
|
117
119
|
chips.("merge") { the_hash.merge(other_hash) }
|
118
120
|
chips.("merge!") { the_hash.merge!(other_hash) }
|
119
|
-
|
121
|
+
# => x.report(..) { ... }
|
120
122
|
```
|
121
123
|
|
122
124
|
... and compare!
|
@@ -171,7 +173,7 @@ Includes methods to query a random record:
|
|
171
173
|
User.random # => reorder("RANDOM()")
|
172
174
|
User.anyone # get a random record (like [].sample method)
|
173
175
|
User.active.anyone # works under a scope - get a random active record
|
174
|
-
User.anyid
|
176
|
+
User.anyid # get an id of some existing record
|
175
177
|
```
|
176
178
|
|
177
179
|
Also provides shorthand to find any user by id: `usr(id)`
|
@@ -204,7 +206,7 @@ Converts array to proc with chained calls of items. Every item can be either a m
|
|
204
206
|
```ruby
|
205
207
|
the_hash = { :one => "One", :two => "Two", :three => 3, :four => nil }
|
206
208
|
the_hash.select(&[[:[], 1], [:is_a?, String]])
|
207
|
-
|
209
|
+
# => { :one => "One", :two => "Two" }
|
208
210
|
```
|
209
211
|
|
210
212
|
Pretty good, huh? ;)
|
@@ -214,7 +216,7 @@ See again:
|
|
214
216
|
```ruby
|
215
217
|
mapping = { "one" => "1", "two" => "2", "" => "0" }
|
216
218
|
the_hash.values.map(&[:to_s, :downcase, [:sub, /one|two|$^/, mapping]])
|
217
|
-
|
219
|
+
# => ["1", "2", "3", "0"]
|
218
220
|
```
|
219
221
|
|
220
222
|
Avoid to use it in production, seriously.
|
data/lib/awesome_print/proc.rb
CHANGED
data/lib/console_utils.rb
CHANGED
@@ -7,10 +7,10 @@ require "console_utils/version"
|
|
7
7
|
begin
|
8
8
|
require "awesome_print"
|
9
9
|
rescue LoadError
|
10
|
+
else
|
11
|
+
require "awesome_print/proc" if defined?(AwesomePrint)
|
10
12
|
end
|
11
13
|
|
12
|
-
require "awesome_print/proc" if defined?(AwesomePrint)
|
13
|
-
|
14
14
|
# = Rails Console Utils
|
15
15
|
# Collection of utilities to use in Rails Console.
|
16
16
|
#
|
@@ -112,8 +112,8 @@ module ConsoleUtils::RequestUtils #:nodoc:
|
|
112
112
|
@_size = nil
|
113
113
|
end
|
114
114
|
|
115
|
-
private_constant :REQUEST_METHODS, :AUTOAUTH_FORMAT, :
|
116
|
-
:
|
115
|
+
private_constant :REQUEST_METHODS, :AUTOAUTH_FORMAT, :PBCOPY_MESSAGE,
|
116
|
+
:NO_RESPONSE, :COMPLETE_IN, :TRANSFERED,
|
117
117
|
:INFO_FORMAT
|
118
118
|
# -
|
119
119
|
|