cch 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/README.md +14 -6
- data/bin/cch_install +11 -0
- data/cch.gemspec +1 -1
- data/lib/cch/commands/file_system.rb +1 -3
- data/lib/cch/commands/shell.rb +1 -1
- data/lib/cch/config/runners.rb +1 -1
- data/lib/cch/config/watchers.rb +1 -3
- data/lib/cch/logger.rb +24 -0
- data/lib/cch/loggers/level.rb +40 -0
- data/lib/cch/loggers/stdout.rb +11 -0
- data/lib/cch/runner.rb +3 -2
- data/lib/cch/setup.rb +8 -5
- data/lib/cch/version.rb +1 -1
- data/lib/cch/watcher.rb +2 -2
- data/lib/cch.rb +16 -9
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDUyZGFiOTQ3YTc2MmViMTgyYjIwMjZmZmMzZThmZmI3NmYxNjIyMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjhiMDM2Mzc5Y2Y0NjQ5MTY3MzMxMTRhNThhM2VjNmY0NzE5YzFlYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDkwZWExYzQ0ZjIwNTMwNjI0NTBjMDM5NmYwNzI1NDU1MjMwODE2ZjBhYzE2
|
10
|
+
NjhmY2MzNDI2NmY5ZTc5ZThhNzQ1OGEyMGFiZDQ3ODM4YzJjNmZjYzZiOTE1
|
11
|
+
MTZkYTQ1MGJlZmNmMjg5M2RhM2E5MjU5NjNhNDgwZDQ4NTE0ZGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTZlMGY3Yzc2NjY3OTAxOWMzNDE5NGViZDcwN2M4NGNkMjk0NmYwZTU5MDg5
|
14
|
+
MmQ3OGYxMjExZWZiZGEzMzdiY2E4OTczNGI5NmQzNmNhZTg0YmQxYWZjYTA5
|
15
|
+
MWFlN2FjNjZlNDRlMjQ5ZTgzNTdlOTNjNTM0NzliNzc1MjNmZDA=
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -16,14 +16,16 @@ CCH - Check on changes for ruby projects
|
|
16
16
|
gem install cch
|
17
17
|
```
|
18
18
|
|
19
|
-
|
19
|
+
Generates a `Cchfile` for project configuration:
|
20
|
+
|
21
|
+
```shell
|
22
|
+
cch_install
|
23
|
+
```
|
24
|
+
|
25
|
+
Configure through the `Cchfile` the way you want to run **cch**:
|
20
26
|
|
21
27
|
```ruby
|
22
|
-
Cch
|
23
|
-
setup.run :rubocop
|
24
|
-
setup.run :haml_lint
|
25
|
-
setup.run :rspec
|
26
|
-
end
|
28
|
+
Cch.setup.run [:rubocop, :haml_lint, :rspec]
|
27
29
|
```
|
28
30
|
|
29
31
|
## Usage
|
@@ -32,6 +34,12 @@ end
|
|
32
34
|
cch
|
33
35
|
```
|
34
36
|
|
37
|
+
Or on run time, you can specify the runners:
|
38
|
+
|
39
|
+
```shell
|
40
|
+
cch rspec rubocop
|
41
|
+
```
|
42
|
+
|
35
43
|
## Development
|
36
44
|
|
37
45
|
1. checking out the repo
|
data/bin/cch_install
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
5
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
6
|
+
|
7
|
+
File.open('Cchfile', 'w') do |file|
|
8
|
+
file.write <<STRING
|
9
|
+
# Cch.setup.run [:rubocop, :rspec]
|
10
|
+
STRING
|
11
|
+
end
|
data/cch.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
f.match(%r{^(test|spec|features)/}) || f.match(/^Cchfile$/)
|
27
27
|
end
|
28
28
|
spec.bindir = 'bin'
|
29
|
-
spec.executables = %w(cch)
|
29
|
+
spec.executables = %w(cch cch_install)
|
30
30
|
spec.require_paths = ['lib']
|
31
31
|
|
32
32
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
@@ -6,9 +6,7 @@ module Cch
|
|
6
6
|
find_matched_files(files, pattern, transform)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
puts "=> #{filtered_files.size.to_s.color(:yellow)} files=#{filtered_files}"
|
11
|
-
filtered_files
|
9
|
+
existing_files(filtered_files)
|
12
10
|
end
|
13
11
|
|
14
12
|
private
|
data/lib/cch/commands/shell.rb
CHANGED
data/lib/cch/config/runners.rb
CHANGED
data/lib/cch/config/watchers.rb
CHANGED
data/lib/cch/logger.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Cch
|
2
|
+
class Logger
|
3
|
+
attr_accessor :threshold, :implementation
|
4
|
+
|
5
|
+
def initialize(threshold, implementation)
|
6
|
+
@threshold = threshold
|
7
|
+
@implementation = implementation
|
8
|
+
end
|
9
|
+
|
10
|
+
Loggers::Level.all.each do |level_name, level|
|
11
|
+
define_method(level_name) do |message|
|
12
|
+
log(level, message)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def log(level, message)
|
19
|
+
return unless implementation && level.allowed?(threshold)
|
20
|
+
|
21
|
+
implementation.log(level, message)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Cch
|
2
|
+
module Loggers
|
3
|
+
class Level
|
4
|
+
LEVELS = [:debug, :info, :error]
|
5
|
+
|
6
|
+
def self.all
|
7
|
+
return @levels if @levels
|
8
|
+
|
9
|
+
@levels = {}
|
10
|
+
LEVELS.each { |level| @levels[level] = new(level) }
|
11
|
+
@levels
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :name
|
15
|
+
|
16
|
+
def initialize(name)
|
17
|
+
@name = name
|
18
|
+
end
|
19
|
+
|
20
|
+
def allowed?(threshold)
|
21
|
+
LEVELS.index(threshold) <= LEVELS.index(name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
name.to_s.upcase.color(color)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def color
|
31
|
+
case name
|
32
|
+
when :debug then :pink
|
33
|
+
when :info then :cyan
|
34
|
+
when :error then :red
|
35
|
+
else :yellow
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/cch/runner.rb
CHANGED
@@ -7,7 +7,7 @@ module Cch
|
|
7
7
|
attr_accessor :command, :on
|
8
8
|
|
9
9
|
def self.all
|
10
|
-
|
10
|
+
Cch.setup.runners.values
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.where(options = {})
|
@@ -31,7 +31,7 @@ module Cch
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def run(files)
|
34
|
-
|
34
|
+
Cch.logger.info("running #{name.to_s.color(:black, :green)}")
|
35
35
|
filtered_files = filter_files(files, patterns)
|
36
36
|
return unless run?(filtered_files)
|
37
37
|
|
@@ -39,6 +39,7 @@ module Cch
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def run?(files)
|
42
|
+
Cch.logger.info("#{files.size.to_s.color(:yellow)} files=#{files}")
|
42
43
|
files.size > 0
|
43
44
|
end
|
44
45
|
end
|
data/lib/cch/setup.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
module Cch
|
2
2
|
class Setup
|
3
3
|
class << self
|
4
|
-
ATTRIBUTES = [:
|
4
|
+
ATTRIBUTES = [:watcher_commands, :runners]
|
5
5
|
attr_accessor(*ATTRIBUTES)
|
6
6
|
|
7
7
|
def configure
|
8
|
+
require 'cch/config/watchers'
|
9
|
+
require 'cch/config/runners'
|
10
|
+
|
8
11
|
load_setup
|
9
|
-
|
12
|
+
Cch.logger.debug("setup\n#{inspect}")
|
10
13
|
self
|
11
14
|
end
|
12
15
|
|
@@ -17,11 +20,11 @@ module Cch
|
|
17
20
|
def add_runner(runner, options = {})
|
18
21
|
@runners ||= {}
|
19
22
|
@runners[runner] = Runner.new(runner, options)
|
20
|
-
yield @runners
|
23
|
+
yield @runners.fetch(runner) if block_given?
|
21
24
|
end
|
22
25
|
|
23
|
-
def run(
|
24
|
-
runners.fetch(runner).on = true
|
26
|
+
def run(runners)
|
27
|
+
Array(runners).each { |runner| @runners.fetch(runner).on = true }
|
25
28
|
end
|
26
29
|
|
27
30
|
private
|
data/lib/cch/version.rb
CHANGED
data/lib/cch/watcher.rb
CHANGED
@@ -7,12 +7,12 @@ module Cch
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def initialize(commands = nil)
|
10
|
-
@commands = commands ||
|
10
|
+
@commands = commands || Cch.setup.watcher_commands
|
11
11
|
end
|
12
12
|
|
13
13
|
def files
|
14
14
|
files = @commands.flat_map { |command| backtiq_command(command) }.compact.sort.uniq
|
15
|
-
|
15
|
+
Cch.logger.info("watched files='#{files}'")
|
16
16
|
files
|
17
17
|
end
|
18
18
|
end
|
data/lib/cch.rb
CHANGED
@@ -2,21 +2,30 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
require 'cch/extensions/string'
|
4
4
|
require 'cch/version'
|
5
|
-
require 'cch/setup'
|
6
5
|
require 'cch/commands/shell'
|
7
6
|
require 'cch/commands/file_system'
|
8
7
|
require 'cch/watcher'
|
9
8
|
require 'cch/runner'
|
10
|
-
|
11
|
-
require 'cch/
|
12
|
-
require 'cch/
|
9
|
+
require 'cch/loggers/level'
|
10
|
+
require 'cch/loggers/stdout'
|
11
|
+
require 'cch/logger'
|
12
|
+
require 'cch/setup'
|
13
13
|
|
14
14
|
module Cch
|
15
15
|
class << self
|
16
|
-
def
|
17
|
-
|
16
|
+
def logger
|
17
|
+
@logger ||= Logger.new(:info, Loggers::Stdout.new)
|
18
|
+
end
|
19
|
+
|
20
|
+
def setup
|
21
|
+
return @setup if @setup
|
22
|
+
@setup = Setup
|
18
23
|
Setup.configure
|
24
|
+
@setup
|
25
|
+
end
|
19
26
|
|
27
|
+
def run(args = [])
|
28
|
+
logger.info("running cch with args='#{args}'")
|
20
29
|
files = Watcher.files
|
21
30
|
runners(args).each { |runner| runner.run(files) }
|
22
31
|
end
|
@@ -24,9 +33,7 @@ module Cch
|
|
24
33
|
private
|
25
34
|
|
26
35
|
def runners(names)
|
27
|
-
|
28
|
-
filter.merge!(name: names) if names.size > 0
|
29
|
-
Runner.where(filter)
|
36
|
+
Runner.where(on?: true, name: names)
|
30
37
|
end
|
31
38
|
end
|
32
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vinicius Ferreira Negrisolo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,6 +99,7 @@ email:
|
|
99
99
|
- vinicius.negrisolo@gmail.com
|
100
100
|
executables:
|
101
101
|
- cch
|
102
|
+
- cch_install
|
102
103
|
extensions: []
|
103
104
|
extra_rdoc_files: []
|
104
105
|
files:
|
@@ -115,6 +116,7 @@ files:
|
|
115
116
|
- README.md
|
116
117
|
- Rakefile
|
117
118
|
- bin/cch
|
119
|
+
- bin/cch_install
|
118
120
|
- bin/console
|
119
121
|
- bin/setup
|
120
122
|
- cch.gemspec
|
@@ -124,6 +126,9 @@ files:
|
|
124
126
|
- lib/cch/config/runners.rb
|
125
127
|
- lib/cch/config/watchers.rb
|
126
128
|
- lib/cch/extensions/string.rb
|
129
|
+
- lib/cch/logger.rb
|
130
|
+
- lib/cch/loggers/level.rb
|
131
|
+
- lib/cch/loggers/stdout.rb
|
127
132
|
- lib/cch/runner.rb
|
128
133
|
- lib/cch/setup.rb
|
129
134
|
- lib/cch/version.rb
|