console_utils 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98f354977ced018bcbcbdf7364468ec2129c9a37
4
- data.tar.gz: b4fb0c0299c75aeb702ea2e324660cf42863e848
3
+ metadata.gz: bfc695ee09f05cefe834a9aacb4bc1725f923e0a
4
+ data.tar.gz: 6cf231b7ba03c3d14d4b893836938969d6b84f32
5
5
  SHA512:
6
- metadata.gz: 682baa14b969162ad24608b425d38e5725d441db6f8760630706d61769ffc08306afa1966b95aa7a5b2d18f08f92cf5cf89832374d709fd28b9094a5b080b447
7
- data.tar.gz: e435b6ae8e6cbe25db985099593d777cca11f1a71f636b5b813ec45e8a57e388e03b6c1d0466dd261a6bc4b8277b6a7dd98f8bafa0cb40cd3004b2c6085fba45
6
+ metadata.gz: 7eea9de0af66cb899fc6f7bd64f196383054852750c14908140b520fd4b433aa95fe0a46d9bd6483759cdc447c28ac1c76b45cadf5defcd61a43174575446f2f
7
+ data.tar.gz: c24230444dcdd36451ef6cfd86d085a897bb389f4654e0a7232d4fecea44348a526badf748d93d6d872fb8c16aa526333157bfdcad2bc238909642a9653cd908
@@ -8,7 +8,12 @@ module ConsoleUtils::RequestUtils
8
8
 
9
9
  # Prints formatted JSON to stdout.
10
10
  def call(body)
11
- puts format(body)
11
+ formatted = format(body)
12
+ if block_given?
13
+ yield(formatted)
14
+ else
15
+ puts formatted
16
+ end
12
17
  end
13
18
 
14
19
  # Formats a given JSON string
@@ -16,15 +16,25 @@ module ConsoleUtils::RequestUtils #:nodoc:
16
16
 
17
17
  def preview(mth = nil)
18
18
  if output = to_s.presence
19
- JSONOutput.formatter.(output)
20
- show_complete_in!
21
- show_transfered!
22
- yield(self) if block_given?
19
+ JSONOutput.formatter.(output) do |formatted|
20
+ @formatted = formatted
21
+ puts @formatted
22
+ show_complete_in!
23
+ show_transfered!
24
+ yield(self) if block_given?
25
+ end
23
26
  else
24
27
  puts NO_RESPONSE
25
28
  end
26
29
  end
27
30
 
31
+ # Copies to pasteboard
32
+ def pbcopy(content = nil)
33
+ content ||= @formatted
34
+ IO.popen('pbcopy', 'w') { |io| io << content.to_s }
35
+ puts PBCOPY_MESSAGE
36
+ end
37
+
28
38
  def print_info
29
39
  tap { printf(INFO_FORMAT, to_info_hash) }
30
40
  end
@@ -59,13 +69,6 @@ module ConsoleUtils::RequestUtils #:nodoc:
59
69
  to_a
60
70
  end
61
71
 
62
- # Copies to pasteboard
63
- def pbcopy(content = nil)
64
- content ||= to_body
65
- IO.popen('pbcopy', 'w') { |io| io << content.to_s }
66
- puts PBCOPY_MESSAGE
67
- end
68
-
69
72
  private
70
73
 
71
74
  def show_complete_in!(reset = true)
@@ -1,3 +1,3 @@
1
1
  module ConsoleUtils
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-30 00:00:00.000000000 Z
11
+ date: 2015-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  version: '0'
172
172
  requirements: []
173
173
  rubyforge_project:
174
- rubygems_version: 2.4.7
174
+ rubygems_version: 2.4.8
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Groovy tools for Rails Console.