guard-haml_lint 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f2728f3de9d34480ca62fe7479bf47f6088ed94c
4
+ data.tar.gz: d7c90b7c92b4cf3fcbd5e16cf8072d5a33b86fb2
5
+ SHA512:
6
+ metadata.gz: 6f483039e2805c49a5563d7ec8257e99c037665c02b6f155c57a90d8c82ab773bc2b2ead3ce0500353acca80538996bcaaa17aa5c75bfdec4fe9670b5acb648e
7
+ data.tar.gz: fe0c64895abbf8707f7265c2b2a37cbdf39d557812423ad3cdae3418803f2138edad9e8c9964c3c8b0362ef0ac02549cdbddfc6b8b78d4512a769f3fad742413
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in guard-haml_lint.gemspec
4
+ gemspec
@@ -0,0 +1,42 @@
1
+ # Guard::HamlLint
2
+
3
+ A guard to lint your Haml.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'guard-haml_lint'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install guard-haml_lint
20
+
21
+ Add the default guard-haml_lint definition to your Guardfile:
22
+
23
+ $ guard init haml_lint
24
+
25
+ ## Guardfile
26
+
27
+ Please read the [Guardfile DSL documentation](https://github.com/guard/guard#readme) for additional information.
28
+
29
+ Available options:
30
+
31
+ all_on_start: true # Check all files at Guard startup. default: true
32
+ haml_dires: ['app/views'] # Check Directories. default: 'app/views' or '.'
33
+
34
+ ## Development
35
+
36
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
+
38
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/yatmsu/guard-haml_lint.
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'guard/haml_lint'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'guard/haml_lint/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'guard-haml_lint'
7
+ spec.version = Guard::HamlLintVersion::VERSION
8
+ spec.authors = ['y@su']
9
+ spec.email = ['toyasyu@gmail.com']
10
+
11
+ spec.summary = 'Guard plugin for HAML-Lint'
12
+ spec.description = 'Guard::HamlLint automatically runs Haml Lint tools.'
13
+ spec.homepage = 'https://github.com/yatmsu/guard-haml-lint'
14
+
15
+ spec.files = `git ls-files`.split("\n")
16
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ spec.executables = `git ls-files -- exe/*`.split("\n").map{ |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.required_ruby_version = '>= 2.0.0'
21
+
22
+ spec.add_dependency 'guard', '~> 2.2'
23
+ spec.add_dependency 'guard-compat', '~> 1.1'
24
+ spec.add_runtime_dependency 'haml_lint', '~> 0.15.2'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.10'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec'
29
+ end
@@ -0,0 +1,108 @@
1
+ require 'guard/compat/plugin'
2
+
3
+ module Guard
4
+ class HamlLint < Plugin
5
+
6
+ DEFAULT_OPTIONS = {
7
+ all_on_start: true
8
+ }
9
+
10
+ attr_reader :options
11
+
12
+ # Initializes a Guard plugin.
13
+ # Don't do any work here, especially as Guard plugins get initialized even if they are not in an active group!
14
+ #
15
+ # @param [Hash] options the custom Guard plugin options
16
+ # @option options [Array<Guard::Watcher>] watchers the Guard plugin file watchers
17
+ # @option options [Symbol] group the group this Guard plugin belongs to
18
+ # @option options [Boolean] any_return allow any object to be returned from a watcher
19
+ #
20
+ def initialize(options = {})
21
+ super
22
+ @options = DEFAULT_OPTIONS
23
+ .merge({ haml_dires: default_haml_dirs })
24
+ .merge(options)
25
+ end
26
+
27
+ # Called once when Guard starts. Please override initialize method to init stuff.
28
+ #
29
+ # @raise [:task_has_failed] when start has failed
30
+ # @return [Object] the task result
31
+ #
32
+ def start
33
+ run if @options[:all_on_start]
34
+ end
35
+
36
+ # Called when `reload|r|z + enter` is pressed.
37
+ # This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
38
+ #
39
+ # @raise [:task_has_failed] when reload has failed
40
+ # @return [Object] the task result
41
+ #
42
+ def reload
43
+ run
44
+ end
45
+
46
+ # Called when just `enter` is pressed
47
+ # This method should be principally used for long action like running all specs/tests/...
48
+ #
49
+ # @raise [:task_has_failed] when run_all has failed
50
+ # @return [Object] the task result
51
+ #
52
+ def run_all
53
+ run
54
+ end
55
+
56
+ # Called on file(s) additions that the Guard plugin watches.
57
+ #
58
+ # @param [Array<String>] paths the changes files or paths
59
+ # @raise [:task_has_failed] when run_on_additions has failed
60
+ # @return [Object] the task result
61
+ #
62
+ def run_on_additions(paths)
63
+ run(paths)
64
+ end
65
+
66
+ # Called on file(s) modifications that the Guard plugin watches.
67
+ #
68
+ # @param [Array<String>] paths the changes files or paths
69
+ # @raise [:task_has_failed] when run_on_modifications has failed
70
+ # @return [Object] the task result
71
+ #
72
+ def run_on_modifications(paths)
73
+ run(paths)
74
+ end
75
+
76
+ # Called on file(s) removals that the Guard plugin watches.
77
+ #
78
+ # @param [Array<String>] paths the changes files or paths
79
+ # @raise [:task_has_failed] when run_on_removals has failed
80
+ # @return [Object] the task result
81
+ #
82
+ def run_on_removals(paths)
83
+ run(paths)
84
+ end
85
+
86
+ private
87
+ # Watcher.match_files(self, Dir.glob("#{@options[:haml_dires]}/**/*.haml"))
88
+ def run(_paths = [])
89
+ Guard::Compat::UI.info 'Running HAML-Lint for all haml files'
90
+
91
+ command = ['haml-lint']
92
+ if _paths.empty?
93
+ command.concat @options[:haml_dires]
94
+ else
95
+ command.concat _paths
96
+ end
97
+
98
+ throw :task_has_failed unless system(*command)
99
+ end
100
+
101
+ # @return [Array<String>] haml directory paths
102
+ #
103
+ def default_haml_dirs
104
+ File.exists?('app/views') ? ['app/views'] : ['.']
105
+ end
106
+
107
+ end
108
+ end
@@ -0,0 +1,4 @@
1
+ guard :haml_lint do
2
+ watch(%r{.+\.html.*\.haml$})
3
+ watch(%r{(?:.+/)?\.haml-lint\.yml$}) { |m| File.dirname(m[0]) }
4
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ class HamlLintVersion
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::HamlLint do
4
+ subject { Guard::HamlLint.new(options) }
5
+ let(:options) { {} }
6
+
7
+ describe '#initialize' do
8
+ context 'when default initialized' do
9
+ it { expect(subject.options[:all_on_start]).to be true }
10
+
11
+ context 'when app/views directory exists' do
12
+ before do
13
+ allow(File).to receive(:exists?).with('app/views').and_return(true)
14
+ end
15
+
16
+ it { expect(subject.options[:haml_dires]).to eq ['app/views'] }
17
+ end
18
+
19
+ context 'when app/views directory not exists' do
20
+ before do
21
+ allow(File).to receive(:exists?).with('app/views').and_return(false)
22
+ end
23
+
24
+ it { expect(subject.options[:haml_dires]).to eq ['.'] }
25
+ end
26
+ end
27
+ end
28
+
29
+ xdescribe '#start' do
30
+ end
31
+
32
+ xdescribe '#reload' do
33
+ end
34
+
35
+ xdescribe '#run_all' do
36
+ end
37
+
38
+ xdescribe '#run_on_additions' do
39
+ end
40
+
41
+ xdescribe '#run_on_modifications' do
42
+ end
43
+
44
+ xdescribe '#run_on_removals' do
45
+ end
46
+
47
+ end
@@ -0,0 +1,3 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'guard/haml_lint'
3
+ require 'guard/compat/test/helper'
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-haml_lint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - y@su
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: guard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: guard-compat
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: haml_lint
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.15.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.15.2
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'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Guard::HamlLint automatically runs Haml Lint tools.
98
+ email:
99
+ - toyasyu@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .rspec
106
+ - Gemfile
107
+ - README.md
108
+ - Rakefile
109
+ - bin/console
110
+ - bin/setup
111
+ - guard-haml_lint.gemspec
112
+ - lib/guard/haml_lint.rb
113
+ - lib/guard/haml_lint/templates/Guardfile
114
+ - lib/guard/haml_lint/version.rb
115
+ - spec/guard/haml_lint_spec.rb
116
+ - spec/spec_helper.rb
117
+ homepage: https://github.com/yatmsu/guard-haml-lint
118
+ licenses: []
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - '>='
127
+ - !ruby/object:Gem::Version
128
+ version: 2.0.0
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.5.1
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Guard plugin for HAML-Lint
140
+ test_files:
141
+ - spec/guard/haml_lint_spec.rb
142
+ - spec/spec_helper.rb