chekku 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chekku.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Yannick Schutz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Chekku
2
+
3
+ The gem that checks your software dependencies
4
+
5
+ ## WARNING
6
+
7
+ **This gem is in alpha mode! Please use it carefully.**
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'chekku'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install chekku
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ $ chekku checks # Check your software dependencies
27
+ $ chekku help [TASK] # Describe available tasks or one specific task
28
+ ```
29
+
30
+ ## Chekkufile
31
+
32
+ This is the file that contains the dependencies we need to check
33
+ For the moment only the name is executable is validated
34
+
35
+ Chekkufile :
36
+
37
+ ```ruby
38
+ check 'mysql', '>= 5.0', env: :production
39
+ check 'redis-server'
40
+ check 'mongod', '~> 1.0', env: :development, must_run: true
41
+ ```
42
+
43
+ **As you can see, you have to set the executable name for the moment, I'm trying to find an easy way to check for software which executables aren't name as the project (see imagemagick)**
44
+ ## Contributing
45
+
46
+ 1. Fork it
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/chekku ADDED
@@ -0,0 +1,2 @@
1
+ #! /usr/bin/env ruby
2
+ require 'chekku'
data/chekku.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'chekku/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'chekku'
8
+ gem.version = Chekku::VERSION
9
+ gem.authors = ['Yannick Schutz']
10
+ gem.email = ['yannick.schutz@gmail.com']
11
+ gem.description = %q{Chekku checks all your software dependencies in every environment. It will helps you installing them too.}
12
+ gem.summary = %q{Chekku: software dependencies checker}
13
+ gem.homepage = 'http://ys.github.com/chekku'
14
+
15
+ gem.required_ruby_version = '>= 1.9'
16
+ gem.required_rubygems_version = '>= 1.3.6'
17
+
18
+ gem.add_development_dependency 'rspec', '>= 2.0'
19
+
20
+ gem.add_dependency 'thor'
21
+
22
+ gem.files = `git ls-files`.split($/)
23
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
24
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
25
+ gem.require_paths = ['lib']
26
+ end
data/lib/chekku.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "chekku/version"
2
+ require 'thor'
3
+ require 'thor/group'
4
+
5
+ module Chekku
6
+ class Command
7
+ if ARGV.first == 'version'
8
+ puts Chekku::VERSION
9
+ else
10
+ require 'chekku/checker'
11
+ Chekku::Checker.start
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,34 @@
1
+ require 'pathname'
2
+ require_relative 'dsl'
3
+
4
+ class Chekku::Checker < Thor
5
+ include Thor::Actions
6
+
7
+ desc 'checks', 'Check your software dependencies'
8
+
9
+ default_task :checks
10
+
11
+ method_option :chekkufile, type: :string, desc: 'Chekkufile Path', default: 'Chekkufile'
12
+
13
+ def checks
14
+ @chekkufile = options[:chekkufile]
15
+ verify_chekku_file_existence
16
+ check_dependencies
17
+ end
18
+
19
+ private
20
+
21
+ def check_dependencies
22
+ Chekku::Dsl.evaluate(@chekkufile)
23
+ end
24
+
25
+ def verify_chekku_file_existence
26
+ chekkufile = Pathname.new(@chekkufile).expand_path
27
+
28
+ unless chekkufile.file?
29
+ say "#{chekkufile} not found"
30
+ exit -1
31
+ end
32
+ end
33
+
34
+ end
data/lib/chekku/dsl.rb ADDED
@@ -0,0 +1,20 @@
1
+ require_relative 'generic_checker.rb'
2
+ class Chekku::Dsl < Thor::Group
3
+ def self.evaluate(file)
4
+ builder = new
5
+ builder.eval_chekkufile(file)
6
+ end
7
+
8
+ def eval_chekkufile(file)
9
+ instance_eval(read_file(file))
10
+ end
11
+
12
+ def check(name, version = nil, args ={})
13
+ Chekku::GenericChecker.new(name, version, args).chekku!
14
+ end
15
+
16
+ def read_file(file)
17
+ File.open(file, "r") { |f| f.read }
18
+ end
19
+
20
+ end
@@ -0,0 +1,24 @@
1
+ class Chekku::GenericChecker < Thor::Shell::Basic
2
+
3
+ def initialize(name, version = nil, args = {})
4
+ @name = sanitize name.to_s
5
+ @version = version
6
+ @args = args
7
+ end
8
+
9
+ def chekku!
10
+ if which_exists?
11
+ puts "\e[32m#{@name} exists!\e[0m"
12
+ else
13
+ puts "\e[31mI think you must install #{@name}\e[0m"
14
+ end
15
+ end
16
+
17
+ def which_exists?
18
+ system("which '#{@name}' > /dev/null")
19
+ end
20
+
21
+ def sanitize(name)
22
+ name.gsub(/&|"|'|;|\s/, "")
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module Chekku
2
+ VERSION = '0.0.2'
3
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chekku
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yannick Schutz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: thor
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Chekku checks all your software dependencies in every environment. It
47
+ will helps you installing them too.
48
+ email:
49
+ - yannick.schutz@gmail.com
50
+ executables:
51
+ - chekku
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - LICENSE.txt
58
+ - README.md
59
+ - Rakefile
60
+ - bin/chekku
61
+ - chekku.gemspec
62
+ - lib/chekku.rb
63
+ - lib/chekku/checker.rb
64
+ - lib/chekku/dsl.rb
65
+ - lib/chekku/generic_checker.rb
66
+ - lib/chekku/version.rb
67
+ homepage: http://ys.github.com/chekku
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '1.9'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: 1.3.6
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.23
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: ! 'Chekku: software dependencies checker'
91
+ test_files: []