yakka 0.0.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.
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/README +0 -0
- data/Rakefile +2 -0
- data/bin/yakka +6 -0
- data/lib/yakka/cli.rb +36 -0
- data/lib/yakka/configuration.rb +17 -0
- data/lib/yakka/rules.rb +48 -0
- data/lib/yakka/templates/yakka.yml +11 -0
- data/lib/yakka/version.rb +3 -0
- data/lib/yakka.rb +8 -0
- data/yakka.gemspec +25 -0
- metadata +99 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.2@yakka --create
|
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
data/bin/yakka
ADDED
data/lib/yakka/cli.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'yakka'
|
3
|
+
|
4
|
+
module Yakka
|
5
|
+
class Cli < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
File.dirname(__FILE__)
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "clear", "Clear all rules"
|
13
|
+
def clear
|
14
|
+
Rules.clear
|
15
|
+
end
|
16
|
+
map "c" => :clear
|
17
|
+
|
18
|
+
desc "enable RULE", "Enable a rule"
|
19
|
+
def enable(rule)
|
20
|
+
Rules.enable(rule)
|
21
|
+
end
|
22
|
+
map "e" => :enable
|
23
|
+
|
24
|
+
desc "install", "Create ~/.yakka file for your own rules"
|
25
|
+
def install
|
26
|
+
template('templates/yakka.yml', "~/.yakka")
|
27
|
+
end
|
28
|
+
map "i" => :install
|
29
|
+
|
30
|
+
desc "list", "List all available rules"
|
31
|
+
def list
|
32
|
+
Rules.list
|
33
|
+
end
|
34
|
+
map "l" => :list
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Yakka
|
4
|
+
class Configuration
|
5
|
+
attr_reader :rules, :rule_keys
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
if ! File.exists?(File.expand_path("~/.yakka"))
|
9
|
+
puts "[Initializing] ".color(:red) + "Can not be done. You should run `yakka install`"
|
10
|
+
exit 0
|
11
|
+
end
|
12
|
+
|
13
|
+
@rules = YAML.load_file(File.expand_path("~/.yakka"))["rules"]
|
14
|
+
@rule_keys = rules.map(&:first)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/yakka/rules.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'ghost'
|
2
|
+
require 'rainbow'
|
3
|
+
|
4
|
+
module Yakka
|
5
|
+
class Rules
|
6
|
+
class << self
|
7
|
+
def enable(rule)
|
8
|
+
begin
|
9
|
+
clear
|
10
|
+
|
11
|
+
Yakka.configuration.rules[rule].each do |host|
|
12
|
+
Host.add(host, '127.0.0.1', true)
|
13
|
+
|
14
|
+
puts "[Adding] ".color(:green) + host.underline
|
15
|
+
end
|
16
|
+
rescue
|
17
|
+
puts "[Adding] ".color(:red) + "Can not be done."
|
18
|
+
exit 0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def clear
|
23
|
+
begin
|
24
|
+
Host.empty!
|
25
|
+
|
26
|
+
puts "[Emptying] ".color(:green) + "Done."
|
27
|
+
rescue
|
28
|
+
puts "[Emptying] ".color(:red) + "Can not be done."
|
29
|
+
exit 0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def list
|
34
|
+
begin
|
35
|
+
rules = Yakka.configuration.rules
|
36
|
+
|
37
|
+
puts "[Listing] ".color(:green) + "#{rules.length} rule(s):"
|
38
|
+
rules.each_key do |key|
|
39
|
+
puts " #{key}"
|
40
|
+
end
|
41
|
+
rescue
|
42
|
+
puts "[Listing] ".color(:red) + "Can not be done."
|
43
|
+
exit 0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/yakka.rb
ADDED
data/yakka.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "yakka/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "yakka"
|
7
|
+
s.version = Yakka::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Andrey Ognevsky"]
|
10
|
+
s.email = ["a.ognevsky@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Simple gem to restrict time-killing resources}
|
13
|
+
s.description = %q{Update your own restriction list to avoid visits to time-killing resources while working}
|
14
|
+
|
15
|
+
s.add_dependency "ghost"
|
16
|
+
s.add_dependency "thor"
|
17
|
+
s.add_dependency "rainbow"
|
18
|
+
|
19
|
+
s.rubyforge_project = "yakka"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yakka
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrey Ognevsky
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-19 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: ghost
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: thor
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rainbow
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id003
|
48
|
+
description: Update your own restriction list to avoid visits to time-killing resources while working
|
49
|
+
email:
|
50
|
+
- a.ognevsky@gmail.com
|
51
|
+
executables:
|
52
|
+
- yakka
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
57
|
+
files:
|
58
|
+
- .gitignore
|
59
|
+
- .rvmrc
|
60
|
+
- Gemfile
|
61
|
+
- README
|
62
|
+
- Rakefile
|
63
|
+
- bin/yakka
|
64
|
+
- lib/yakka.rb
|
65
|
+
- lib/yakka/cli.rb
|
66
|
+
- lib/yakka/configuration.rb
|
67
|
+
- lib/yakka/rules.rb
|
68
|
+
- lib/yakka/templates/yakka.yml
|
69
|
+
- lib/yakka/version.rb
|
70
|
+
- yakka.gemspec
|
71
|
+
homepage: ""
|
72
|
+
licenses: []
|
73
|
+
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project: yakka
|
94
|
+
rubygems_version: 1.8.2
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Simple gem to restrict time-killing resources
|
98
|
+
test_files: []
|
99
|
+
|