cch 0.2.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTlhZjNmMjc4OTU2ODQ1MTJhYzRlNDRhZTI0OWRiMmFhY2U0MTU4Zg==
4
+ YzM2NjA2YTU3MzRmYTQxYWE1NzZiYzBmOWFmNmM2ZmNkMjllMTI2ZA==
5
5
  data.tar.gz: !binary |-
6
- MDBhZGFhZmQ5ZjI4ZDViZjY3NjFjZDUzN2RiZGRiZGIzNGRiYTBhYg==
6
+ NjcwNTVjOGM1ZmYzNzhlZjA5MTVkMmNkMzJhNGU1ZjJkOWJhMGQxNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzU4OGJlZTQyZDljZWNiMWU2ZWZhNDg2MmI2NjE4N2JlNzMwYTFlYjU0Y2Zi
10
- Y2VkOTAzNzVhYmEwYzlhZWEzNmMwNDA1OTVlMjZlZGJiOTgwZDRlOWZkZjFl
11
- NmRiNzIxYTA3YmRhOTY2ODhiNTU2NzFkNGIyOTEzMTkxYjc5MzI=
9
+ Nzc1MGFjOTI1ZDliZmE1NTU1ZmU0MTdlZjkwMDIyZDEzZWExZDQ5NTYwZDI3
10
+ OWRiNDVjODZjZTBmZTJjZDdlMjRhZWRmN2NjYTE2NWMzMjM0NDM0YWM2Njc3
11
+ NGQ2YmMyNDVhOGU0Yjc3MmE1MmMwNGFmYjdjM2M3YWNmYmEwYTE=
12
12
  data.tar.gz: !binary |-
13
- NWJlMWVkNjVhNDc2OGIyNDMzY2I2YTc2ZmVlZmE4OGE1ZGYwNTNhOWIzYzJm
14
- NGQzM2U4NTM4MmU4ZjQ3ZWI0ZGNhMTQyY2FlZjIyOTBiOGMwMTU0ZWM1OTU5
15
- MGE5NWFkZGIyM2MwNWQ4NDdkYTAwMjRhZWI2YjBiNmZhN2JlMzc=
13
+ M2MwNDBlNDNkZjU3YjdkMDQ4MTM0ODc5MDRmOTI3MWEyMjgyOGNiNTJlMDdi
14
+ MzBhZjFkMjAxYjg2ZjE4OWYxY2M2ODJmYmIzZTIzODU1MWVjOWRmYTgyZGQ1
15
+ ZmI4ZDI5M2QwM2U3MTA0ZDE0NzQ3ZWU4ZWQwYzRmMjY5ZWE4ODM=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cch (0.2.0)
4
+ cch (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/cch.gemspec CHANGED
@@ -22,7 +22,9 @@ Gem::Specification.new do |spec|
22
22
  fail 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
23
23
  end
24
24
 
25
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/}) || f.match(/^Cchfile$/)
27
+ end
26
28
  spec.bindir = 'bin'
27
29
  spec.executables = %w(cch)
28
30
  spec.require_paths = ['lib']
@@ -0,0 +1,27 @@
1
+ Cch::Setup.tap do |setup|
2
+ setup.add_runner :rubocop do |runner|
3
+ runner.watch(/\.rb$/)
4
+ end
5
+
6
+ setup.add_runner :haml_lint, gem: 'haml-lint' do |runner|
7
+ runner.watch(/\.haml$/)
8
+ end
9
+
10
+ setup.add_runner :rspec do |runner|
11
+ runner.watch(/_spec\.rb$/)
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) })
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
27
+ end
@@ -0,0 +1,10 @@
1
+ Cch::Setup.tap do |setup|
2
+ setup.debug = false
3
+
4
+ setup.watcher_commands = [
5
+ 'git diff --name-only',
6
+ 'git diff --name-only --staged',
7
+ 'git ls-files --others --exclude-standard',
8
+ 'git diff --name-only ..master'
9
+ ]
10
+ end
data/lib/cch/runner.rb CHANGED
@@ -6,9 +6,22 @@ module Cch
6
6
  attr_reader :name, :patterns
7
7
  attr_accessor :command, :on
8
8
 
9
- def initialize(name)
9
+ def self.all
10
+ Setup.runners.values
11
+ end
12
+
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) }
18
+ end
19
+ runners
20
+ end
21
+
22
+ def initialize(name, options = {})
10
23
  @name = name
11
- @command = "bundle exec #{name} %{files}"
24
+ @command = "bundle exec #{options[:gem] || name} %{files}"
12
25
  @on = false
13
26
  @patterns = {}
14
27
  end
data/lib/cch/setup.rb CHANGED
@@ -5,7 +5,7 @@ module Cch
5
5
  attr_accessor(*ATTRIBUTES)
6
6
 
7
7
  def configure
8
- load_setup_files(%w(config/Cchfile Cchfile))
8
+ load_setup
9
9
  puts "=> setup\n#{inspect}" if debug
10
10
  self
11
11
  end
@@ -14,9 +14,9 @@ module Cch
14
14
  ATTRIBUTES.map { |f| " #{f} = #{send(f)}" }.join("\n")
15
15
  end
16
16
 
17
- def add_runner(runner)
17
+ def add_runner(runner, options = {})
18
18
  @runners ||= {}
19
- @runners[runner] = Runner.new(runner)
19
+ @runners[runner] = Runner.new(runner, options)
20
20
  yield @runners[runner] if block_given?
21
21
  end
22
22
 
@@ -26,8 +26,8 @@ module Cch
26
26
 
27
27
  private
28
28
 
29
- def load_setup_files(files)
30
- files.each { |f| load(f, true) if File.exist?(f) }
29
+ def load_setup(file = 'Cchfile')
30
+ load(file, true) if File.exist?(file)
31
31
  end
32
32
  end
33
33
  end
data/lib/cch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cch
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
data/lib/cch/watcher.rb CHANGED
@@ -2,6 +2,10 @@ module Cch
2
2
  class Watcher
3
3
  include Commands::Shell
4
4
 
5
+ def self.files
6
+ new.files
7
+ end
8
+
5
9
  def initialize(commands = nil)
6
10
  @commands = commands || Setup.watcher_commands
7
11
  end
data/lib/cch.rb CHANGED
@@ -8,20 +8,25 @@ require 'cch/commands/file_system'
8
8
  require 'cch/watcher'
9
9
  require 'cch/runner'
10
10
 
11
+ require 'cch/config/watchers'
12
+ require 'cch/config/runners'
13
+
11
14
  module Cch
12
15
  class << self
13
- def run(args)
16
+ def run(args = [])
14
17
  puts "=> running cch with args='#{args}'"
15
18
  Setup.configure
16
19
 
17
- files = Watcher.new.files
18
- runners.each { |runner| runner.run(files) if runner.on }
20
+ files = Watcher.files
21
+ runners(args).each { |runner| runner.run(files) }
19
22
  end
20
23
 
21
24
  private
22
25
 
23
- def runners
24
- Setup.runners.values
26
+ def runners(names)
27
+ filter = { on?: true }
28
+ filter.merge!(name: names) if names.size > 0
29
+ Runner.where(filter)
25
30
  end
26
31
  end
27
32
  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.2.0
4
+ version: 0.3.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-09 00:00:00.000000000 Z
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,7 +109,6 @@ files:
109
109
  - .travis.yml
110
110
  - CODE_OF_CONDUCT.md
111
111
  - CONTRIBUTING.md
112
- - Cchfile
113
112
  - Gemfile
114
113
  - Gemfile.lock
115
114
  - LICENSE.md
@@ -119,10 +118,11 @@ files:
119
118
  - bin/console
120
119
  - bin/setup
121
120
  - cch.gemspec
122
- - config/Cchfile
123
121
  - lib/cch.rb
124
122
  - lib/cch/commands/file_system.rb
125
123
  - lib/cch/commands/shell.rb
124
+ - lib/cch/config/runners.rb
125
+ - lib/cch/config/watchers.rb
126
126
  - lib/cch/extensions/string.rb
127
127
  - lib/cch/runner.rb
128
128
  - lib/cch/setup.rb
data/Cchfile DELETED
@@ -1,6 +0,0 @@
1
- Cch::Setup.tap do |setup|
2
- setup.debug = true
3
-
4
- setup.run :rspec
5
- setup.run :rubocop
6
- end
data/config/Cchfile DELETED
@@ -1,31 +0,0 @@
1
- Cch::Setup.tap do |setup|
2
- setup.debug = false
3
-
4
- setup.watcher_commands = [
5
- 'git diff --name-only',
6
- 'git diff --name-only --staged',
7
- 'git ls-files --others --exclude-standard',
8
- 'git diff --name-only ..master'
9
- ]
10
-
11
- setup.add_runner :rubocop do |runner|
12
- runner.watch /\.rb$/
13
- end
14
-
15
- setup.add_runner :haml_lint do |runner|
16
- runner.watch /\.haml$/
17
- end
18
-
19
- setup.add_runner :rspec do |runner|
20
- runner.watch /_spec\.rb$/
21
-
22
- runner.watch /^spec\/spec_helper.rb$/, proc { |m| %W(spec) }
23
- runner.watch /^spec\/rails_helper.rb$/, proc { |m| %W(spec) }
24
- runner.watch /^config\/routes.rb$/, proc { |m| %W(spec/routing) }
25
- runner.watch /^app\/controllers\/application_controller.rb$/, proc { |m| %W(spec/controllers) }
26
-
27
- runner.watch /^lib\/(.+)\.rb$/, proc { |m| %W(spec/#{m[1]}_spec.rb spec/lib/#{m[1]}_spec.rb) }
28
- runner.watch /^app\/(.+)\.rb$/, proc { |m| %W(spec/#{m[1]}_spec.rb) }
29
- runner.watch /^app\/controllers\/(.+)_(controller)\.rb$/, proc { |m| %W(spec/routing/#{m[1]}_routing_spec.rb spec/requests/#{m[1]}_spec.rb spec/features/#{m[1]}_spec.rb) }
30
- end
31
- end