kinit 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kinit.rb +25 -18
- data/lib/kinit/version.rb +1 -1
- metadata +2 -2
data/lib/kinit.rb
CHANGED
@@ -8,9 +8,10 @@ module Kinit
|
|
8
8
|
class GemsEnforcer
|
9
9
|
|
10
10
|
GemError = Class.new(ArgumentError)
|
11
|
+
CONFIG_FILE = "kinit_config.yml"
|
11
12
|
|
12
13
|
def initialize(options={})
|
13
|
-
default_config = File.join(File.dirname(__FILE__), "..",
|
14
|
+
default_config = File.join(File.dirname(__FILE__), "..", CONFIG_FILE)
|
14
15
|
custom_config = File.join(base_path, 'config/kinit_config.yml')
|
15
16
|
@config = File.exists?(custom_config) ? custom_config : default_config
|
16
17
|
end
|
@@ -29,29 +30,36 @@ module Kinit
|
|
29
30
|
|
30
31
|
def CheckIsGemPresent
|
31
32
|
gemList = YAML.load_file @config
|
33
|
+
|
32
34
|
#puts gemList.inspect
|
33
|
-
if
|
34
|
-
gemList
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
if gemList
|
36
|
+
if gemList.has_key?("bestPracticesGems")
|
37
|
+
gemList["bestPracticesGems"].each do |gemname|
|
38
|
+
if Gem.available?(gemname)
|
39
|
+
plain_output "Gem '#{gemname}' is present in your project. Neat." , 'green'
|
40
|
+
else
|
41
|
+
add_error "Gem '#{gemname}' is not present in your project. Not Good."
|
42
|
+
end
|
43
|
+
# if Gem::Specification.find_by_name(gem)
|
44
|
+
# raise GemsEnforcer::GemError, "Please include gem 'cane' to the project."
|
39
45
|
end
|
40
|
-
# if Gem::Specification.find_by_name(gem)
|
41
|
-
# raise GemsEnforcer::GemError, "Please include gem 'cane' to the project."
|
42
46
|
end
|
43
47
|
|
44
48
|
output_terminal_errors
|
45
49
|
|
46
|
-
gemList
|
47
|
-
|
50
|
+
if gemList.has_key?("suggestions")
|
51
|
+
gemList["suggestions"].each do |suggestion|
|
52
|
+
plain_output "Kinit Suggestions: You may use tools like '#{suggestion}' for your project.", 'green'
|
53
|
+
end
|
48
54
|
end
|
49
55
|
|
50
56
|
return true
|
51
57
|
else
|
58
|
+
#puts gemList.inspect
|
59
|
+
plain_output "Please define checks in your config/kinit_config.yml to enforce best practices.", 'red'
|
52
60
|
return false
|
53
|
-
end
|
54
|
-
end
|
61
|
+
end
|
62
|
+
end
|
55
63
|
|
56
64
|
def colorize(text, color_code)
|
57
65
|
"\e[#{color_code}m#{text}\e[0m"
|
@@ -65,17 +73,16 @@ module Kinit
|
|
65
73
|
if errors.empty?
|
66
74
|
plain_output("\nNo issues or errors found. Cool! Your project passed Kinit checks.", 'green')
|
67
75
|
else
|
68
|
-
@errors.each { |error| plain_output(error.to_s, 'red') }
|
76
|
+
@errors.each { |error| plain_output(error.to_s, 'red') }
|
69
77
|
plain_output("\nFound #{errors.size} errors.", 'red')
|
70
78
|
end
|
71
79
|
end
|
72
80
|
|
73
81
|
def plain_output(message, color)
|
74
|
-
puts result = (color == "red" && red(message) ) || green(message)
|
82
|
+
puts result = (color == "red" && red(message) ) || green(message)
|
75
83
|
end
|
76
84
|
|
77
85
|
def red(text); colorize(text, 31); end
|
78
86
|
def green(text); colorize(text, 32); end
|
79
|
-
|
80
|
-
|
81
|
-
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/kinit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kinit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|