cch 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDUyZGFiOTQ3YTc2MmViMTgyYjIwMjZmZmMzZThmZmI3NmYxNjIyMQ==
4
+ MjJjYTgxOGI3ZWQwYzdkNzY0ZDczN2ZiYWM5NzNhNGQ3YzBkYzQxYg==
5
5
  data.tar.gz: !binary |-
6
- ZjhiMDM2Mzc5Y2Y0NjQ5MTY3MzMxMTRhNThhM2VjNmY0NzE5YzFlYw==
6
+ MzdkYmZlOWFlNjVjNTM2N2ZlNzhiM2YzMWY3MTQwMzEyNzQyZDAxMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDkwZWExYzQ0ZjIwNTMwNjI0NTBjMDM5NmYwNzI1NDU1MjMwODE2ZjBhYzE2
10
- NjhmY2MzNDI2NmY5ZTc5ZThhNzQ1OGEyMGFiZDQ3ODM4YzJjNmZjYzZiOTE1
11
- MTZkYTQ1MGJlZmNmMjg5M2RhM2E5MjU5NjNhNDgwZDQ4NTE0ZGE=
9
+ M2JlZGFkNDYxYTcwMTQwYzAwYTNmOTk0Njg0MDA5ZjFlNzVlZGFkZjg1MDUw
10
+ Njc4MjgwZDE1YmM5NjZkMDY2YWIyNTlhMzkyNDI1Y2E0ODE0YTIzZTRiMzY2
11
+ ZDBkYjQwOWFjYTJjMTdmNjNjZWMxZmZkYWU0ZTRlNTE4NDNiNzQ=
12
12
  data.tar.gz: !binary |-
13
- NTZlMGY3Yzc2NjY3OTAxOWMzNDE5NGViZDcwN2M4NGNkMjk0NmYwZTU5MDg5
14
- MmQ3OGYxMjExZWZiZGEzMzdiY2E4OTczNGI5NmQzNmNhZTg0YmQxYWZjYTA5
15
- MWFlN2FjNjZlNDRlMjQ5ZTgzNTdlOTNjNTM0NzliNzc1MjNmZDA=
13
+ M2VmZmY4Y2U0MTgxYTcyMzZkOTgwZDFkZjI0MjU3YTg4NmMzOGE4NWRhOGIz
14
+ NWFjODc4MzlmZTVlY2Q1ODZmZGMxZGE5ZTEzYTA0M2I3N2FjMGM3ZmVjNTA4
15
+ MGMwMzcwYjQ2MjFmYTlhMzgxNDFmMDU0MTY1ZTRlODhjODljNzY=
data/.gitignore CHANGED
@@ -1,35 +1,9 @@
1
- *.gem
2
- *.rbc
3
- /.config
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
4
5
  /coverage/
5
- /InstalledFiles
6
+ /doc/
6
7
  /pkg/
7
8
  /spec/reports/
8
- /test/tmp/
9
- /test/version_tmp/
10
9
  /tmp/
11
-
12
- ## Specific to RubyMotion:
13
- .dat*
14
- .repl_history
15
- build/
16
-
17
- ## Documentation cache and generated files:
18
- /.yardoc/
19
- /_yardoc/
20
- /doc/
21
- /rdoc/
22
-
23
- ## Environment normalisation:
24
- /.bundle/
25
- /vendor/bundle
26
- /lib/bundler/man/
27
-
28
- # for a library or gem, you might want to ignore these files since the code is
29
- # intended to run in multiple environments; otherwise, check them in:
30
- # Gemfile.lock
31
- # .ruby-version
32
- # .ruby-gemset
33
-
34
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
- .rvmrc
data/README.md CHANGED
@@ -25,7 +25,7 @@ cch_install
25
25
  Configure through the `Cchfile` the way you want to run **cch**:
26
26
 
27
27
  ```ruby
28
- Cch.setup.run [:rubocop, :haml_lint, :rspec]
28
+ Cch::Runner.run [:rubocop, :haml_lint, :rspec]
29
29
  ```
30
30
 
31
31
  ## Usage
@@ -6,6 +6,6 @@ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
6
6
 
7
7
  File.open('Cchfile', 'w') do |file|
8
8
  file.write <<STRING
9
- # Cch.setup.run [:rubocop, :rspec]
9
+ Cch::Runner.run [:rubocop, :haml_lint, :rspec]
10
10
  STRING
11
11
  end
data/lib/cch.rb CHANGED
@@ -14,26 +14,18 @@ require 'cch/setup'
14
14
  module Cch
15
15
  class << self
16
16
  def logger
17
- @logger ||= Logger.new(:info, Loggers::Stdout.new)
17
+ @logger ||= Logger.new
18
18
  end
19
19
 
20
20
  def setup
21
- return @setup if @setup
22
- @setup = Setup
23
- Setup.configure
24
- @setup
21
+ @setup ||= Setup.new
25
22
  end
26
23
 
27
24
  def run(args = [])
28
- logger.info("running cch with args='#{args}'")
29
- files = Watcher.files
30
- runners(args).each { |runner| runner.run(files) }
31
- end
25
+ setup.configure
32
26
 
33
- private
34
-
35
- def runners(names)
36
- Runner.where(on?: true, name: names)
27
+ files = Watcher.files
28
+ Runner.where(on?: true, name: args).each { |runner| runner.run(files) }
37
29
  end
38
30
  end
39
31
  end
@@ -0,0 +1,2 @@
1
+ Cch.logger.threshold = :info
2
+ Cch.logger.implementation = Cch::Loggers::Stdout.new
@@ -1,27 +1,26 @@
1
- Cch.setup.tap do |setup|
2
- setup.add_runner :rubocop do |runner|
3
- runner.watch(/\.rb$/)
4
- end
1
+ Cch::Runner.configure :rubocop do |runner|
2
+ runner.watch(/\.rb$/)
3
+ runner.watch(/\.rake$/)
4
+ end
5
5
 
6
- setup.add_runner :haml_lint, gem: 'haml-lint' do |runner|
7
- runner.watch(/\.haml$/)
8
- end
6
+ Cch::Runner.configure :haml_lint, gem: 'haml-lint' do |runner|
7
+ runner.watch(/\.haml$/)
8
+ end
9
9
 
10
- setup.add_runner :rspec do |runner|
11
- runner.watch(/_spec\.rb$/)
10
+ Cch::Runner.configure :rspec do |runner|
11
+ runner.watch(/_spec\.rb$/)
12
12
 
13
- runner.watch(%r{^spec/spec_helper.rb$}, proc { %w(spec) })
14
- runner.watch(%r{^spec/rails_helper.rb$}, proc { %w(spec) })
15
- runner.watch(%r{^config/routes.rb$}, proc { %w(spec/routing) })
16
- runner.watch(%r{^app/controllers/application_controller.rb$}, proc { %w(spec/controllers) })
13
+ runner.watch(%r{^spec/spec_helper.rb$}, proc { %w(spec) })
14
+ runner.watch(%r{^spec/rails_helper.rb$}, proc { %w(spec) })
15
+ runner.watch(%r{^config/routes.rb$}, proc { %w(spec/routing) })
16
+ runner.watch(%r{^app/controllers/application_controller.rb$}, proc { %w(spec/controllers) })
17
17
 
18
- runner.watch(%r{^lib/(.+)\.rb$}, proc { |m| %W(spec/#{m[1]}_spec.rb spec/lib/#{m[1]}_spec.rb) })
19
- runner.watch(%r{^app/(.+)\.rb$}, proc { |m| %W(spec/#{m[1]}_spec.rb) })
20
- runner.watch(
21
- %r{^app/controllers/(.+)_(controller)\.rb$},
22
- proc do |m|
23
- %W(spec/routing/#{m[1]}_routing_spec.rb spec/requests/#{m[1]}_spec.rb spec/features/#{m[1]}_spec.rb)
24
- end
25
- )
26
- end
18
+ runner.watch(%r{^lib/(.+)\.rb$}, proc { |m| %W(spec/#{m[1]}_spec.rb spec/lib/#{m[1]}_spec.rb) })
19
+ runner.watch(%r{^app/(.+)\.rb$}, proc { |m| %W(spec/#{m[1]}_spec.rb) })
20
+ runner.watch(
21
+ %r{^app/controllers/(.+)_(controller)\.rb$},
22
+ proc do |m|
23
+ %W(spec/routing/#{m[1]}_routing_spec.rb spec/requests/#{m[1]}_spec.rb spec/features/#{m[1]}_spec.rb)
24
+ end
25
+ )
27
26
  end
@@ -1,8 +1,6 @@
1
- Cch.setup.tap do |setup|
2
- setup.watcher_commands = [
3
- 'git diff --name-only',
4
- 'git diff --name-only --staged',
5
- 'git ls-files --others --exclude-standard',
6
- 'git diff --name-only ..master'
7
- ]
8
- end
1
+ Cch::Watcher.commands = [
2
+ 'git diff --name-only',
3
+ 'git diff --name-only --staged',
4
+ 'git ls-files --others --exclude-standard',
5
+ 'git diff --name-only ..master'
6
+ ]
@@ -2,9 +2,9 @@ module Cch
2
2
  class Logger
3
3
  attr_accessor :threshold, :implementation
4
4
 
5
- def initialize(threshold, implementation)
6
- @threshold = threshold
7
- @implementation = implementation
5
+ def initialize(options = {})
6
+ @threshold = options[:threshold]
7
+ @implementation = options[:implementation]
8
8
  end
9
9
 
10
10
  Loggers::Level.all.each do |level_name, level|
@@ -2,7 +2,7 @@ module Cch
2
2
  module Loggers
3
3
  class Stdout
4
4
  def log(level, message, time = Time.new)
5
- log_message = "=> [#{time}] [#{level}] - #{message}"
5
+ log_message = "=> #{'cch'.color(:cyan)} [#{time}] [#{level}] - #{message}"
6
6
  puts log_message
7
7
  log_message
8
8
  end
@@ -3,22 +3,36 @@ module Cch
3
3
  include Commands::Shell
4
4
  include Commands::FileSystem
5
5
 
6
- attr_reader :name, :patterns
7
- attr_accessor :command, :on
6
+ class << self
7
+ attr_accessor :runners
8
8
 
9
- def self.all
10
- Cch.setup.runners.values
11
- end
9
+ def configure(runner, options = {})
10
+ @runners ||= {}
11
+ @runners[runner] = Runner.new(runner, options)
12
+ yield @runners.fetch(runner) if block_given?
13
+ end
14
+
15
+ def run(runners)
16
+ Array(runners).each { |runner| @runners.fetch(runner).on = true }
17
+ end
12
18
 
13
- def self.where(options = {})
14
- runners = all
15
- runners = runners.select(&:on) if options[:on?]
16
- if (names = [options[:name]].flatten.compact).size > 0
17
- runners = runners.select { |r| names.include?(r.name) }
19
+ def all
20
+ runners.values
21
+ end
22
+
23
+ def where(options = {})
24
+ runners = all
25
+ runners = runners.select(&:on) if options[:on?]
26
+ if (names = [options[:name]].flatten.compact).size > 0
27
+ runners = runners.select { |r| names.include?(r.name) }
28
+ end
29
+ runners
18
30
  end
19
- runners
20
31
  end
21
32
 
33
+ attr_reader :name, :patterns
34
+ attr_accessor :command, :on
35
+
22
36
  def initialize(name, options = {})
23
37
  @name = name
24
38
  @command = "bundle exec #{options[:gem] || name} %{files}"
@@ -31,15 +45,16 @@ module Cch
31
45
  end
32
46
 
33
47
  def run(files)
34
- Cch.logger.info("running #{name.to_s.color(:black, :green)}")
35
- filtered_files = filter_files(files, patterns)
36
- return unless run?(filtered_files)
48
+ files = filter_files(files, patterns)
49
+ return unless run?(files)
37
50
 
38
- system_command(command % { files: filtered_files.join(' ') })
51
+ system_command(command % { files: files.join(' ') })
39
52
  end
40
53
 
41
54
  def run?(files)
42
- Cch.logger.info("#{files.size.to_s.color(:yellow)} files=#{files}")
55
+ message = "running #{name.to_s.color(:black, :green)}"
56
+ message << " for #{files.size.to_s.color(:yellow)} files=#{files}"
57
+ Cch.logger.info(message)
43
58
  files.size > 0
44
59
  end
45
60
  end
@@ -1,37 +1,11 @@
1
1
  module Cch
2
2
  class Setup
3
- class << self
4
- ATTRIBUTES = [:watcher_commands, :runners]
5
- attr_accessor(*ATTRIBUTES)
6
-
7
- def configure
8
- require 'cch/config/watchers'
9
- require 'cch/config/runners'
10
-
11
- load_setup
12
- Cch.logger.debug("setup\n#{inspect}")
13
- self
14
- end
15
-
16
- def inspect
17
- ATTRIBUTES.map { |f| " #{f} = #{send(f)}" }.join("\n")
18
- end
19
-
20
- def add_runner(runner, options = {})
21
- @runners ||= {}
22
- @runners[runner] = Runner.new(runner, options)
23
- yield @runners.fetch(runner) if block_given?
24
- end
25
-
26
- def run(runners)
27
- Array(runners).each { |runner| @runners.fetch(runner).on = true }
3
+ def configure
4
+ %w(logger watchers runners).each do |config_file|
5
+ require "cch/config/#{config_file}"
28
6
  end
29
7
 
30
- private
31
-
32
- def load_setup(file = 'Cchfile')
33
- load(file, true) if File.exist?(file)
34
- end
8
+ load('Cchfile', true) if File.exist?('Cchfile')
35
9
  end
36
10
  end
37
11
  end
@@ -1,3 +1,3 @@
1
1
  module Cch
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -2,17 +2,17 @@ module Cch
2
2
  class Watcher
3
3
  include Commands::Shell
4
4
 
5
- def self.files
6
- new.files
7
- end
5
+ class << self
6
+ attr_accessor :commands
8
7
 
9
- def initialize(commands = nil)
10
- @commands = commands || Cch.setup.watcher_commands
8
+ def files
9
+ new.files(commands)
10
+ end
11
11
  end
12
12
 
13
- def files
14
- files = @commands.flat_map { |command| backtiq_command(command) }.compact.sort.uniq
15
- Cch.logger.info("watched files='#{files}'")
13
+ def files(commands)
14
+ files = commands.flat_map { |command| backtiq_command(command) }.compact.sort.uniq
15
+ Cch.logger.info("watching #{files.size.to_s.color(:yellow)} files=#{files}")
16
16
  files
17
17
  end
18
18
  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.0
4
+ version: 0.5.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-21 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,7 +111,6 @@ files:
111
111
  - CODE_OF_CONDUCT.md
112
112
  - CONTRIBUTING.md
113
113
  - Gemfile
114
- - Gemfile.lock
115
114
  - LICENSE.md
116
115
  - README.md
117
116
  - Rakefile
@@ -123,6 +122,7 @@ files:
123
122
  - lib/cch.rb
124
123
  - lib/cch/commands/file_system.rb
125
124
  - lib/cch/commands/shell.rb
125
+ - lib/cch/config/logger.rb
126
126
  - lib/cch/config/runners.rb
127
127
  - lib/cch/config/watchers.rb
128
128
  - lib/cch/extensions/string.rb
@@ -1,62 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- cch (0.4.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.1.0)
10
- astrolabe (1.3.1)
11
- parser (~> 2.2)
12
- codeclimate-test-reporter (0.4.8)
13
- simplecov (>= 0.7.1, < 1.0.0)
14
- diff-lcs (1.2.5)
15
- docile (1.1.5)
16
- json (1.8.3)
17
- parser (2.2.2.6)
18
- ast (>= 1.1, < 3.0)
19
- powerpack (0.1.1)
20
- rainbow (2.0.0)
21
- rake (10.4.2)
22
- rspec (3.3.0)
23
- rspec-core (~> 3.3.0)
24
- rspec-expectations (~> 3.3.0)
25
- rspec-mocks (~> 3.3.0)
26
- rspec-core (3.3.2)
27
- rspec-support (~> 3.3.0)
28
- rspec-expectations (3.3.1)
29
- diff-lcs (>= 1.2.0, < 2.0)
30
- rspec-support (~> 3.3.0)
31
- rspec-mocks (3.3.2)
32
- diff-lcs (>= 1.2.0, < 2.0)
33
- rspec-support (~> 3.3.0)
34
- rspec-support (3.3.0)
35
- rubocop (0.34.0)
36
- astrolabe (~> 1.3)
37
- parser (>= 2.2.2.5, < 3.0)
38
- powerpack (~> 0.1)
39
- rainbow (>= 1.99.1, < 3.0)
40
- ruby-progressbar (~> 1.4)
41
- ruby-progressbar (1.7.5)
42
- simplecov (0.10.0)
43
- docile (~> 1.1.0)
44
- json (~> 1.8)
45
- simplecov-html (~> 0.10.0)
46
- simplecov-html (0.10.0)
47
- yard (0.8.7.6)
48
-
49
- PLATFORMS
50
- ruby
51
-
52
- DEPENDENCIES
53
- bundler (~> 1.10)
54
- cch!
55
- codeclimate-test-reporter
56
- rake (~> 10.0)
57
- rspec
58
- rubocop
59
- yard
60
-
61
- BUNDLED WITH
62
- 1.10.6