guard-haml-coffee 0.2.0 → 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 587cd4e49ab5e4d7932837ff09e3d6d54ecc21e1
4
+ data.tar.gz: 0551e719daa33aaa2412c1437fa3797c1bdee0e4
5
+ SHA512:
6
+ metadata.gz: c39dd4d39d1e78ef101c3887500cc189056541697e1849b16a6a4f211e579de116f0e65af04d3a9a2a7082e31c266bfe38a82342b6697a7bb50b35a5ff65b7d6
7
+ data.tar.gz: ca34da908c26799d97f5b672a2e83fa4b7b506a4fce9da80ec4e7bbb8e10738e5e0947daa25494ed46e554211e3b14d1e410cd191b71bc88de1e7cae53e60ecf
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ spec/examples.txt
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,84 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-10-06 17:20:52 +0200 using RuboCop version 0.34.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 18
10
+ Lint/UselessAssignment:
11
+ Exclude:
12
+ - 'lib/guard/haml-coffee.rb'
13
+
14
+ # Offense count: 2
15
+ Metrics/AbcSize:
16
+ Max: 27
17
+
18
+ # Offense count: 6
19
+ # Configuration parameters: AllowURI, URISchemes.
20
+ Metrics/LineLength:
21
+ Max: 121
22
+
23
+ # Offense count: 1
24
+ # Configuration parameters: CountComments.
25
+ Metrics/MethodLength:
26
+ Max: 34
27
+
28
+ # Offense count: 2
29
+ # Configuration parameters: Exclude.
30
+ Style/Documentation:
31
+ Exclude:
32
+ - 'lib/guard/haml-coffee.rb'
33
+ - 'lib/guard/haml-coffee/version.rb'
34
+
35
+ # Offense count: 3
36
+ # Configuration parameters: Exclude.
37
+ Style/FileName:
38
+ Exclude:
39
+ - 'lib/guard-haml-coffee.rb'
40
+ - 'lib/guard/haml-coffee.rb'
41
+ - 'spec/guard/haml-coffee_spec.rb'
42
+
43
+ # Offense count: 2
44
+ # Cop supports --auto-correct.
45
+ # Configuration parameters: PreferredDelimiters.
46
+ Style/PercentLiteralDelimiters:
47
+ Exclude:
48
+ - 'guard-haml-coffee.gemspec'
49
+
50
+ # Offense count: 1
51
+ # Cop supports --auto-correct.
52
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
53
+ Style/SpaceBeforeBlockBraces:
54
+ Enabled: false
55
+
56
+ # Offense count: 1
57
+ # Cop supports --auto-correct.
58
+ Style/SpecialGlobalVars:
59
+ Exclude:
60
+ - 'guard-haml-coffee.gemspec'
61
+
62
+ # Offense count: 8
63
+ # Cop supports --auto-correct.
64
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
65
+ Style/StringLiterals:
66
+ Enabled: false
67
+
68
+ # Offense count: 1
69
+ # Cop supports --auto-correct.
70
+ # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
71
+ Style/TrailingComma:
72
+ Exclude:
73
+ - 'lib/guard/haml-coffee.rb'
74
+
75
+ # Offense count: 2
76
+ # Cop supports --auto-correct.
77
+ Style/UnneededPercentQ:
78
+ Exclude:
79
+ - 'guard-haml-coffee.gemspec'
80
+
81
+ # Offense count: 13
82
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
83
+ Style/VariableName:
84
+ Enabled: false
data/Gemfile CHANGED
@@ -1,4 +1,17 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in guard-haml-coffee.gemspec
4
- gemspec
4
+ gemspec development_group: :gem_build_tools
5
+
6
+ group :development do
7
+ gem 'guard'
8
+ gem 'guard-rspec', '~> 4.5', '>= 4.5.2'
9
+
10
+ gem 'rubocop', require: false
11
+ gem 'guard-rubocop', require: false
12
+ end
13
+
14
+ group :gem_build_tools do
15
+ gem 'rake', '~> 10.0'
16
+ gem 'rspec', '~> 3.2'
17
+ end
@@ -0,0 +1,49 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ group :spec, halt_on_failure: true do
28
+ guard :rspec, cmd: 'bundle exec rspec' do
29
+ require 'guard/rspec/dsl'
30
+ dsl = Guard::RSpec::Dsl.new(self)
31
+
32
+ # Feel free to open issues for suggestions and improvements
33
+
34
+ # RSpec files
35
+ rspec = dsl.rspec
36
+ watch(rspec.spec_helper) { rspec.spec_dir }
37
+ watch(rspec.spec_support) { rspec.spec_dir }
38
+ watch(rspec.spec_files)
39
+
40
+ # Ruby files
41
+ ruby = dsl.ruby
42
+ dsl.watch_spec_files_for(ruby.lib_files)
43
+ end
44
+
45
+ guard :rubocop do
46
+ watch(/.+\.rb$/)
47
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
48
+ end
49
+ end
data/Rakefile CHANGED
@@ -1,2 +1,11 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
2
+ require 'bundler/gem_tasks'
3
+
4
+ default_tasks = []
5
+
6
+ require 'rspec/core/rake_task'
7
+ default_tasks << RSpec::Core::RakeTask.new(:spec) do |t|
8
+ t.verbose = false
9
+ end
10
+
11
+ task default: default_tasks.map(&:name)
@@ -15,7 +15,9 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Guard::Haml::Coffee::VERSION
17
17
 
18
- gem.add_dependency('guard')
18
+ gem.add_dependency('guard-compat', '~> 1.2')
19
19
  gem.add_dependency('execjs')
20
20
  gem.add_dependency('coffee-script')
21
+
22
+ gem.add_development_dependency 'bundler', '~> 1.10'
21
23
  end
@@ -1,25 +1,34 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require 'guard'
3
- require 'guard/guard'
4
- require 'guard/watcher'
2
+
3
+ require 'guard/compat/plugin'
4
+
5
5
  require 'execjs'
6
6
  require 'coffee-script'
7
7
 
8
8
  module Guard
9
- class HamlCoffee < Guard
10
-
11
- def initialize(watchers=[], options={})
9
+ class HamlCoffee < Plugin
10
+ VALID_GUARD_OPTIONS = %i(watchers group callbacks)
11
+ VALID_OPTIONS = %i(object)
12
+
13
+ def initialize(options = {})
14
+ valid_options = VALID_OPTIONS + VALID_GUARD_OPTIONS
15
+ options.keys.each do |key|
16
+ unless valid_options.include?(key)
17
+ fail ArgumentError, "Unknown option: #{key.inspect}"
18
+ end
19
+ end
20
+
12
21
  @options = {
13
- :notifications => true
22
+ notifications: true
14
23
  }.merge(options)
15
- super(watchers, @options)
24
+ super(@options)
16
25
  end
17
26
 
18
27
  def start
19
- ::Guard::UI.info("Guard::HamlCoffee has started watching your files",{})
20
- source = File.read(::CoffeeScript::Source.path) + ";"
21
- source += File.read(File.expand_path('../haml-coffee/hamlcoffee.js', __FILE__)) + ";"
22
- source += File.read(File.expand_path('../haml-coffee/hamlcoffee_compiler.js', __FILE__))
28
+ Compat::UI.info('Guard::HamlCoffee has started watching your files', {})
29
+ source = File.read(::CoffeeScript::Source.path) + ';'
30
+ source += load_config('../haml-coffee/hamlcoffee.js') + ';'
31
+ source += load_config('../haml-coffee/hamlcoffee_compiler.js')
23
32
  @runtime = ExecJS.compile(source)
24
33
  end
25
34
 
@@ -46,10 +55,26 @@ module Guard
46
55
  end
47
56
 
48
57
  def run_all
49
- run_on_changes(Watcher.match_files(self, Dir.glob(File.join('**', '*.*'))))
58
+ all_files = Dir.glob(File.join('**', '*.*'))
59
+ process(Compat.matching_files(self, all_files))
60
+ end
61
+
62
+ def run_on_modifications(files)
63
+ process(files)
50
64
  end
51
65
 
52
- def run_on_changes(paths)
66
+ def run_on_changes(files)
67
+ process(files)
68
+ end
69
+
70
+ def self.template(plugin_location)
71
+ path = 'lib/guard/haml-coffee/templates/Guardfile'
72
+ (Pathname(plugin_location) + path).read
73
+ end
74
+
75
+ private
76
+
77
+ def process(paths)
53
78
  paths.each do |path|
54
79
  basename = File.basename(path, '.js.hamlc')
55
80
  output_file = get_output(path)
@@ -85,5 +110,9 @@ module Guard
85
110
  ::Guard::UI.error "Guard Haml Coffee Error: " + error.message
86
111
  throw :task_has_failed
87
112
  end
113
+
114
+ def load_config(file)
115
+ File.read(File.expand_path(file, __FILE__))
116
+ end
88
117
  end
89
118
  end
@@ -1,3 +1,10 @@
1
- guard 'haml-coffee' do
1
+ haml_coffee_options = {
2
+ # input: 'foo/bar', # strips 'foo/bar/' from output file name
3
+ # output: 'public/baz', # output dir
4
+ #
5
+ # Example (given above options): src/foo/bar/a.js.hamlc -> public/baz/a.js
6
+ }
7
+
8
+ guard 'haml-coffee', haml_coffee_options do
2
9
  watch(/^.+(\.js\.hamlc)\Z/)
3
10
  end
@@ -1,7 +1,7 @@
1
1
  module Guard
2
2
  module Haml
3
3
  module Coffee
4
- VERSION = "0.2.0"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,110 @@
1
+ require 'guard/compat/test/helper'
2
+ require 'guard/haml-coffee'
3
+
4
+ RSpec.describe Guard::HamlCoffee do
5
+ subject { described_class.new(options) }
6
+
7
+ let(:options) { {} }
8
+
9
+ before do
10
+ allow(Guard::Compat::UI).to receive(:info)
11
+ allow(File).to receive(:expand_path) do |*args|
12
+ msg = 'unstubbed call to File.expand_path(%s)'
13
+ fail msg % args.map(&:inspect).join(',')
14
+ end
15
+
16
+ allow(IO).to receive(:read) do |*args|
17
+ msg = 'unstubbed call to IO.read(%s)'
18
+ fail msg % args.map(&:inspect).join(',')
19
+ end
20
+ end
21
+
22
+ describe '#initialize' do
23
+ context 'with an unknown option' do
24
+ let(:options) { { foo: :bar } }
25
+ it 'fails' do
26
+ expect { subject }.to raise_error(ArgumentError, 'Unknown option: :foo')
27
+ end
28
+ end
29
+
30
+ context 'with a Guard::Plugin watchers option' do
31
+ let(:options) { { watchers: [] } }
32
+ it 'fails' do
33
+ expect { subject }.to_not raise_error
34
+ end
35
+ end
36
+
37
+ context 'with a Guard::Plugin group option' do
38
+ let(:options) { { group: [] } }
39
+ it 'fails' do
40
+ expect { subject }.to_not raise_error
41
+ end
42
+ end
43
+
44
+ context 'with a Guard::Plugin callbacks option' do
45
+ let(:options) { { callbacks: [] } }
46
+ it 'fails' do
47
+ expect { subject }.to_not raise_error
48
+ end
49
+ end
50
+ end
51
+
52
+ describe '#start' do
53
+ context 'with valid config' do
54
+ let(:source) { 'foo' }
55
+
56
+ before do
57
+ allow(File).to receive(:expand_path).with('../coffee-script.js', anything).and_return('foo.js')
58
+ allow(IO).to receive(:read).with('foo.js').and_return('foo')
59
+
60
+ allow(File).to receive(:expand_path).with('../haml-coffee/hamlcoffee.js', anything).and_return('bar.js')
61
+ allow(IO).to receive(:read).with('bar.js').and_return('bar')
62
+
63
+ allow(File).to receive(:expand_path).with('../haml-coffee/hamlcoffee_compiler.js', anything).and_return('baz.js')
64
+ allow(IO).to receive(:read).with('baz.js').and_return('baz')
65
+ end
66
+
67
+ it 'compiles' do
68
+ expect(ExecJS).to receive(:compile).with('foo;bar;baz')
69
+ subject.start
70
+ end
71
+ end
72
+ end
73
+
74
+ describe '#run_all' do
75
+ context 'with matching files' do
76
+ let(:existing) { %w(foo bar baz) }
77
+ let(:matching) { %w(foo bar) }
78
+
79
+ before do
80
+ allow(Dir).to receive(:glob).with(anything).and_return(existing)
81
+ allow(Guard::Compat).to receive(:matching_files).with(subject, existing).and_return(matching)
82
+ end
83
+
84
+ it 'compiles' do
85
+ expect(subject).to receive(:process).with(matching)
86
+ subject.run_all
87
+ end
88
+ end
89
+ end
90
+
91
+ describe '#run_on_modifications' do
92
+ context 'with modifications' do
93
+ let(:files) { %w(foo bar) }
94
+ it 'compiles' do
95
+ expect(subject).to receive(:process).with(files)
96
+ subject.run_on_modifications(files)
97
+ end
98
+ end
99
+ end
100
+
101
+ describe '#run_on_changes' do
102
+ context 'with changes' do
103
+ let(:files) { %w(foo bar) }
104
+ it 'compiles' do
105
+ expect(subject).to receive(:process).with(files)
106
+ subject.run_on_changes(files)
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,26 @@
1
+ RSpec.configure do |config|
2
+ config.expect_with :rspec do |expectations|
3
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
4
+ end
5
+
6
+ config.mock_with :rspec do |mocks|
7
+ mocks.verify_partial_doubles = true
8
+ end
9
+
10
+ config.filter_run :focus
11
+ config.run_all_when_everything_filtered = true
12
+
13
+ config.example_status_persistence_file_path = 'spec/examples.txt'
14
+
15
+ config.disable_monkey_patching!
16
+
17
+ config.warnings = true
18
+
19
+ config.default_formatter = 'doc' if config.files_to_run.one?
20
+
21
+ # config.profile_examples = 10
22
+
23
+ config.order = :random
24
+
25
+ Kernel.srand config.seed
26
+ end
metadata CHANGED
@@ -1,49 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-haml-coffee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ouvrages
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-01 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: guard
16
- requirement: &85692160 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: guard-compat
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '1.2'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *85692160
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: execjs
27
- requirement: &85691740 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *85691740
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: coffee-script
38
- requirement: &85691220 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - ">="
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *85691220
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.10'
47
69
  description: Compiles HamlCoffee templates to javascript
48
70
  email:
49
71
  - contact@ouvrages-web.fr
@@ -51,8 +73,12 @@ executables: []
51
73
  extensions: []
52
74
  extra_rdoc_files: []
53
75
  files:
54
- - .gitignore
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".rubocop.yml"
79
+ - ".rubocop_todo.yml"
55
80
  - Gemfile
81
+ - Guardfile
56
82
  - LICENSE
57
83
  - README.md
58
84
  - Rakefile
@@ -63,29 +89,31 @@ files:
63
89
  - lib/guard/haml-coffee/hamlcoffee_compiler.js
64
90
  - lib/guard/haml-coffee/templates/Guardfile
65
91
  - lib/guard/haml-coffee/version.rb
92
+ - spec/guard/haml-coffee_spec.rb
93
+ - spec/spec_helper.rb
66
94
  homepage: https://github.com/ouvrages/guard-haml-coffee
67
95
  licenses: []
96
+ metadata: {}
68
97
  post_install_message:
69
98
  rdoc_options: []
70
99
  require_paths:
71
100
  - lib
72
101
  required_ruby_version: !ruby/object:Gem::Requirement
73
- none: false
74
102
  requirements:
75
- - - ! '>='
103
+ - - ">="
76
104
  - !ruby/object:Gem::Version
77
105
  version: '0'
78
106
  required_rubygems_version: !ruby/object:Gem::Requirement
79
- none: false
80
107
  requirements:
81
- - - ! '>='
108
+ - - ">="
82
109
  - !ruby/object:Gem::Version
83
110
  version: '0'
84
111
  requirements: []
85
112
  rubyforge_project:
86
- rubygems_version: 1.8.11
113
+ rubygems_version: 2.4.5
87
114
  signing_key:
88
- specification_version: 3
115
+ specification_version: 4
89
116
  summary: Guard gem for HamlCoffee
90
- test_files: []
91
- has_rdoc:
117
+ test_files:
118
+ - spec/guard/haml-coffee_spec.rb
119
+ - spec/spec_helper.rb