aid 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d410aaa006c361b0a2def56ab77ed4e4cbb7e7f
4
- data.tar.gz: cbe5fbe9a404339b9da151f7c09e30e654993308
3
+ metadata.gz: 4e7ddbdb9940084ffb7cb80cc7a8bab11b55be7e
4
+ data.tar.gz: cd4394ea900d7f0e998d61122020f7e7a3465e4c
5
5
  SHA512:
6
- metadata.gz: dd862dbea28b6ec45c838178cbe17d34b2c8d7034cb9b0ec6c8fd507646a2ebcfeafbd788172bf3669b0c69e32ae7cadb0dd70fb02ccd280554cc83e974d17fc
7
- data.tar.gz: bfd5c74b562d001a650a39dbbc4c79004ef153a58fa157b4362835f5a64578b84738d9c97f60a7311ca7f333caebd858f2110a6f8c0912833f96f3f6528193a6
6
+ metadata.gz: 3084b847b65d7fcedbd37f13fa823146f256191bc377943aaac33f70959fdf7416f9cf058586dbcaa346ac66f191448b921add091abd33c641de3abb1bb93628
7
+ data.tar.gz: 9df4181994fa6316fc18f2d0ab08a1da73b380ed52463fb4a807cfd709c23236eba58baf632953c0214b6760d64442b07bfcd880ab58279fd7b86d4d60c31f21
data/.gitignore CHANGED
@@ -11,5 +11,5 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
 
14
- /.aide
14
+ /.aid
15
15
  *.gem
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format documentation
2
2
  --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ [0.1.1](https://github.com/dbalatero/aid/tag/0.1.1)
2
+
3
+ #### New features:
4
+ * Added doctor script
5
+
6
+ #### Bug fixes:
7
+ * Allow subclassing a Script
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Aide
1
+ # Aid
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aide`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aid`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
5
  TODO: Delete this and the text above, and describe your gem
6
6
 
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'aide'
12
+ gem 'aid'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -18,7 +18,7 @@ And then execute:
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install aide
21
+ $ gem install aid
22
22
 
23
23
  ## Usage
24
24
 
@@ -32,7 +32,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
32
 
33
33
  ## Contributing
34
34
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/dbalatero/aide.
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dbalatero/aid.
36
36
 
37
37
  ## License
38
38
 
@@ -5,7 +5,7 @@ module Aid
5
5
  extend ClassMethods
6
6
 
7
7
  def self.inherited(subklass)
8
- self.script_classes << subklass
8
+ Aid::Script.script_classes << subklass
9
9
  end
10
10
  end
11
11
  end
@@ -51,6 +51,10 @@ module Aid
51
51
  raise NotImplementedError
52
52
  end
53
53
 
54
+ def exit_code
55
+ 0
56
+ end
57
+
54
58
  def system!(*args)
55
59
  puts colorize(:command, args.join(" "))
56
60
  system(*args) || abort(colorize(:error, "\n== Command #{args} failed =="))
@@ -0,0 +1,95 @@
1
+ module Aid
2
+ module Scripts
3
+ class Doctor < Aid::Script
4
+ class Check
5
+ include Aid::Colorize
6
+
7
+ attr_reader :name, :command, :remedy, :problems
8
+
9
+ def initialize(name:, command:, remedy:)
10
+ @name = name
11
+ @command = command
12
+ @remedy = remedy
13
+ @problems = []
14
+ end
15
+
16
+ def run!
17
+ print "Checking: #{name}... "
18
+
19
+ success = if command.respond_to?(:call)
20
+ command.call
21
+ else
22
+ system "#{command} > /dev/null 2>&1"
23
+ end
24
+
25
+ if success
26
+ puts 'OK'
27
+ else
28
+ print colorize(:error, 'F')
29
+ fix = remedy.respond_to?(:join) ? remedy.join(" ") : remedy
30
+ puts "\n To fix: #{colorize(:command, fix)}\n\n"
31
+
32
+ problems << name
33
+ end
34
+ end
35
+ end
36
+
37
+ def self.description
38
+ "Checks the health of your development environment"
39
+ end
40
+
41
+ def self.help
42
+ "doctor - helps you diagnose any setup issues with this application"
43
+ end
44
+
45
+ def initialize(*args)
46
+ super
47
+ @checks = []
48
+ end
49
+
50
+ def check(**options)
51
+ check = Check.new(options)
52
+ @checks << check
53
+
54
+ check.run!
55
+ end
56
+
57
+ def run
58
+ puts <<~HELP
59
+ To implement this script for your repository, create the following
60
+ file in #{colorize(:green, "#{aid_directory}/doctor.rb")}:
61
+
62
+ class Doctor < Aid::Scripts::Doctor
63
+ def run
64
+ check_phantomjs_installed
65
+ end
66
+
67
+ private
68
+
69
+ def check_phantomjs_installed
70
+ check name: "PhantomJS installed",
71
+ command: "which phantomjs",
72
+ remedy: command("brew install phantomjs")
73
+ end
74
+ end
75
+
76
+ You can add as many checks to your script as you want.
77
+ HELP
78
+
79
+ exit
80
+ end
81
+
82
+ def problems
83
+ @checks.map(&:problems).flatten
84
+ end
85
+
86
+ def exit_code
87
+ problems.size
88
+ end
89
+
90
+ def command(s)
91
+ "run #{colorize :command, s}"
92
+ end
93
+ end
94
+ end
95
+ end
@@ -1,3 +1,3 @@
1
1
  module Aid
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Balatero
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-01 00:00:00.000000000 Z
11
+ date: 2017-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,6 +63,7 @@ files:
63
63
  - ".gitignore"
64
64
  - ".rspec"
65
65
  - ".travis.yml"
66
+ - CHANGELOG.md
66
67
  - Gemfile
67
68
  - LICENSE.txt
68
69
  - README.md
@@ -76,6 +77,7 @@ files:
76
77
  - lib/aid/inheritable.rb
77
78
  - lib/aid/script.rb
78
79
  - lib/aid/scripts.rb
80
+ - lib/aid/scripts/doctor.rb
79
81
  - lib/aid/scripts/help.rb
80
82
  - lib/aid/scripts/init.rb
81
83
  - lib/aid/scripts/new.rb