brewer 0.0.21 β†’ 0.0.24

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: 6fd3151ef2ca1e31779cd287565ec95a6bef5726
4
- data.tar.gz: b6d6689d3681a42b5293ea784399ea9072f34494
3
+ metadata.gz: c59e6ed5a2631055e58561388cd0281981d8b2e6
4
+ data.tar.gz: cb7a25668057a798c748c24772cfa801e5ed5cd3
5
5
  SHA512:
6
- metadata.gz: b63a554cc5966155fa62a37f91ee7625efc38d5997a8fde3009e670a544e9f83ecbdb93a934c28f55feb024582e4bfe58f34c197a062b0bd1fcb4d28a74fda78
7
- data.tar.gz: fda7bd47781e154b96fe918fb5e44192f964000a64d6b11967a6a17d87228fb17d2237f9baa84306d5867b2d3a4094a8044b3ff730e9a389a97b983a72417e7a
6
+ metadata.gz: b3b4cb3d456e0acb045e02b9c342d041cbc8e6a683ae72e304c912fa7b6a129134b7e2bac1f7d20f54a59333356b89a8e7ee58e4c85600198dca7785d12cfcaf
7
+ data.tar.gz: 266b36dea35b67b9aeb866ebd8a668a00bf9e18b9ef053f6a29909e12afb6c1d8b6c7860d3bcb7a5e48f8f8cd4abb97a34f172fb5be7afafd43e9630e957da2b
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brewer (0.0.10)
4
+ brewer (0.0.23)
5
5
  git (~> 1.3, >= 1.3.0)
6
+ net-ping (~> 1.7.0)
6
7
  ripl (~> 0.7.0)
7
8
 
8
9
  GEM
@@ -17,6 +18,7 @@ GEM
17
18
  json (2.0.3)
18
19
  launchy (2.4.3)
19
20
  addressable (~> 2.3)
21
+ net-ping (1.7.8)
20
22
  public_suffix (2.0.4)
21
23
  rake (12.0.0)
22
24
  rdoc (5.1.0)
data/bin/brewer CHANGED
@@ -1,20 +1,28 @@
1
1
  #!/usr/bin/env ruby
2
- # 🍺🍺🍺
3
2
  # This executable will start a Ripl shell with a 'brewer' and 'adaptibrew' objects
4
3
 
5
4
  require 'ripl'
6
5
 
7
6
  require_relative "../lib/brewer"
7
+ require_relative "../lib/helpers"
8
8
 
9
- # Refresh to make sure we have the lastest version of adaptibrew
10
- adaptibrew = Adaptibrew.new.refresh
9
+ include Helpers
10
+
11
+ if !network?
12
+ puts "Warning: You have no network connection. If you delete the adaptibrew directory, you will not be able to clone it back."
13
+ print "Are you sure you want to continue? "
14
+ confirm ? nil : abort
15
+ end
11
16
 
17
+ # Refresh to make sure we have the lastest version of adaptibrew
18
+ adaptibrew = Adaptibrew.new
19
+ if network?
20
+ adaptibrew.refresh
21
+ end
12
22
  brewer = Brewer.new
13
23
 
14
- puts "Warning: Adaptibrew has been cloned into the directory you executed 'brewer'"
15
- puts "You may wish to delete it when you are finished. Do that with `adaptibrew.clear`"
16
- puts "🍺 have fun 🍺"
17
24
 
18
25
  # 🍺🍺🍺
26
+ puts "🍺 have fun 🍺"
19
27
  Ripl.start :binding => binding
20
28
  # 🍺🍺🍺
@@ -2,18 +2,19 @@ require 'rake'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "brewer"
5
- s.version = "0.0.21"
5
+ s.version = "0.0.24"
6
6
  s.default_executable = "brewer"
7
7
 
8
8
  s.authors = ["Luke Sweeney"]
9
9
  s.date = %q{2017-03-08}
10
10
  s.description = %q{A Ruby API for adaptiman/adaptibrew}
11
+ s.post_install_message = "🍺 have fun 🍺"
11
12
  s.email = %q{luke@thesweeneys.org}
12
13
  s.files = FileList.new(['lib/*.rb', 'bin/*', '[A-Z]*', 'spec/*.rb']).to_a
13
14
  s.executables = ['brewer']
14
15
  s.bindir = 'bin'
15
16
  s.test_files = FileList.new(["spec/*.rb"]).to_a
16
- s.homepage = %q{http://github.com/llamicron/brewer}
17
+ s.homepage = %q{https://rubygems.org/gems/brewer}
17
18
  s.require_paths = ["lib", "lib"]
18
19
  s.rubygems_version = %q{1.6.2}
19
20
  s.summary = %q{A shell interface for adaptibrew}
@@ -22,6 +23,8 @@ Gem::Specification.new do |s|
22
23
  # Runtime dependencies
23
24
  s.add_runtime_dependency 'git', '~> 1.3', '>= 1.3.0'
24
25
  s.add_runtime_dependency 'ripl', '~> 0.7.0'
26
+ s.add_runtime_dependency 'net-ping', '~> 1.7'
27
+
25
28
 
26
29
  # Dev dependencies
27
30
  s.add_development_dependency 'rake', '~> 12.0', '>= 12.0.0'
@@ -1,11 +1,15 @@
1
1
  require 'git'
2
2
  require 'fileutils'
3
+ require_relative 'helpers'
4
+
5
+ include Helpers
3
6
 
4
7
  # This is the 'manager' for the adaptibrew repo. It handles cloning and such.
5
8
  class Adaptibrew
6
9
 
7
10
  # If used in IRB, Ripl, etc. it will clone into the directory IRB was started in
8
11
  def clone(path=nil)
12
+ raise "πŸ›‘ Cannot clone, no network connection" unless network?
9
13
  if !Dir.exists?('adaptibrew')
10
14
  Git.clone('https://github.com/adaptiman/adaptibrew.git', 'adaptibrew', :path => path)
11
15
  end
@@ -13,12 +17,21 @@ class Adaptibrew
13
17
  end
14
18
 
15
19
  # Danger zone...
16
- def clear()
20
+ def clear
21
+ # :nocov: since this requires network to be off
22
+ if !network?
23
+ print "Warning: you have no network connection. If you clear, you will not be able to clone again, and you'll be stuck without the adaptibrew source. Are you sure? "
24
+ if !confirm
25
+ exit
26
+ end
27
+ end
28
+ # :nocov:
17
29
  FileUtils.rm_rf('adaptibrew')
18
30
  self
19
31
  end
20
32
 
21
33
  def refresh
34
+ raise "πŸ›‘ Cannot refresh, no network connection" unless network?
22
35
  clear
23
36
  clone
24
37
  self
@@ -1,3 +1,5 @@
1
+ require 'net/ping'
2
+
1
3
  module Helpers
2
4
 
3
5
  def log
@@ -9,6 +11,11 @@ module Helpers
9
11
  Time.now.strftime("%m/%d/%Y %H:%M")
10
12
  end
11
13
 
14
+ def network?
15
+ connection = Net::Ping::TCP.new('google.com', 80, 5)
16
+ connection.ping?
17
+ end
18
+
12
19
  def clear_log(log)
13
20
  File.truncate(log, 0)
14
21
  end
@@ -21,4 +28,10 @@ module Helpers
21
28
  end
22
29
  end
23
30
 
31
+ def confirm(input=gets.chomp)
32
+ if ["y", "Y", "yes", "Yes", "YES", "k"].include? input
33
+ true
34
+ end
35
+ end
36
+
24
37
  end
@@ -4,32 +4,44 @@ include Helpers
4
4
 
5
5
  describe "Helpers" do
6
6
 
7
- it "returns the log file path" do
8
- expect(log).to eq(Dir.pwd + '/logs/output')
7
+ describe "#log" do
8
+ it "returns the log file path" do
9
+ expect(log).to eq(Dir.pwd + '/logs/output')
10
+ end
9
11
  end
10
12
 
11
- it "can return the date/time" do
12
- # This might not be consistent???
13
- # What if the minute changes during tests?
14
- # dunno lol
15
- expect(time).to eq(Time.now.strftime("%m/%d/%Y %H:%M"))
13
+ describe "#time" do
14
+ it "can return the date/time" do
15
+ # This might not be consistent???
16
+ # What if the minute changes during tests?
17
+ # dunno lol
18
+ expect(time).to eq(Time.now.strftime("%m/%d/%Y %H:%M"))
19
+ end
16
20
  end
17
21
 
18
- context "when the log is empty" do
19
- before { clear_log(log) }
20
- specify { expect(File.zero?(log)).to be true }
21
- it "can write to the log" do
22
+ describe "#write_log and #clear_log" do
23
+ context "when the log is empty" do
24
+ before { clear_log(log) }
25
+ specify { expect(File.zero?(log)).to be true }
26
+ it "can write to the log" do
27
+ write_log(log, ['log entry'])
28
+ expect(File.zero?(log)).to be false
29
+ end
30
+ end
31
+
32
+ context "when the log is not empty" do
22
33
  write_log(log, ['log entry'])
23
- expect(File.zero?(log)).to be false
34
+ specify { expect(File.zero?(log)).to be false }
35
+ it "can clear the log" do
36
+ clear_log(log)
37
+ expect(File.zero?(log)).to be true
38
+ end
24
39
  end
25
40
  end
26
41
 
27
- context "when the log is not empty" do
28
- write_log(log, ['log entry'])
29
- specify { expect(File.zero?(log)).to be false }
30
- it "can clear the log" do
31
- clear_log(log)
32
- expect(File.zero?(log)).to be true
42
+ describe "#confirm" do
43
+ it "should return true" do
44
+ expect(confirm('y')).to be true
33
45
  end
34
46
  end
35
47
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Sweeney
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 0.7.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: net-ping
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.7'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.7'
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: rake
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -172,11 +186,11 @@ files:
172
186
  - spec/brewer_spec.rb
173
187
  - spec/helpers_spec.rb
174
188
  - spec/spec_helper.rb
175
- homepage: http://github.com/llamicron/brewer
189
+ homepage: https://rubygems.org/gems/brewer
176
190
  licenses:
177
191
  - MIT
178
192
  metadata: {}
179
- post_install_message:
193
+ post_install_message: "\U0001F37A have fun \U0001F37A"
180
194
  rdoc_options: []
181
195
  require_paths:
182
196
  - lib