hound-cli 0.1.2 → 0.2.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 +4 -4
- data/.travis.yml +9 -2
- data/README.md +12 -3
- data/{hound.gemspec → hound-cli.gemspec} +0 -0
- data/lib/hound/cli.rb +9 -13
- data/lib/hound/config/base.rb +10 -2
- data/lib/hound/config_collection.rb +8 -8
- data/lib/hound/hound_config.rb +19 -19
- data/lib/hound/parser.rb +1 -1
- data/lib/hound/rules_updater.rb +46 -32
- data/lib/hound/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 454ad367bd7e0e30dbd8116cc19b4ff47e338932
|
|
4
|
+
data.tar.gz: dd94b1526e032629da0558cab1d2617944b52db6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f5153ffe726f7ff7c7257b09d126cbb0a1c8a630e8264712e7d3aae776c9fd0040da38339b179d77b4b9f45d260a812c666934dbb3280874e40027ff96e011f
|
|
7
|
+
data.tar.gz: e21c72eee152627b07c063fee3d748cf1e9cbd8d35ece1bf0ab7155a39f8221e0ccf0fc831f9dad60a154ab8e892b625418119a93373874cee89562f865986af
|
data/.travis.yml
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
sudo: false
|
|
2
1
|
language: ruby
|
|
3
2
|
rvm:
|
|
4
|
-
|
|
3
|
+
- 2.3.1
|
|
5
4
|
before_install: gem install bundler -v 1.12.5
|
|
5
|
+
deploy:
|
|
6
|
+
provider: rubygems
|
|
7
|
+
api_key:
|
|
8
|
+
secure: dHxqTlIlkQvCOMG5acKpJaD/Sh+5K7tQNYrvXjJjAByLeFRjRP9lTduVgJgMn8Dj+r71WwVWmKlAQ8NU4/syBUpBRnrXHZ3t9mt6jYDzBI+e0j6aOPLYrXlC9hEPgI/g9TrG9p45KAFgCK+1zg4wD6l9HAe4nHAJ8IyMCWJRcTtAEQcMiNBKzObA2V1ygyRkNR32wF3k025J+nMNlblZ9s5ptcU2UVcE4XT49R8kWtvXOZPX9k1TsRnJ3pSNCmyOz6mHOiTmSS587ds+gt4xSghIgKUTzVYBks5buY3fQ6eXs4QtebOE1JT3yVWJkvRaGBhiABBENidNHQCbo3METYaPy+5GkxmdZ+2TiZhF4cMfGdXJhwEnGkKfrbGdFGn0s/RcDWcUzb/J11wotj1gi8dQ2ZvlSF/gZaO9ZaYkkq67QewhgebLrTyuU8kfsqqad2tLMshPSUBNWO1zU+H2pJinP5KV/zGFcOCrKFkSPa25fmR4VyG13pCBck8A2dp9CeRTG9lkczg6e7OoIoX8lGN5uoQZ2ITFxi0/fSMUeyxxizJKg+HL7zTwioz9zp/TqQROgcpDYK9/0lFPIzG2Ru4LteMhuqsdkqvrFDpodt+F0WEhWzipEctjr7l2mt6wbibgcqfHPxw269bWZW05prOkzxfAf7WidKHeOhDfRhI=
|
|
9
|
+
gem: hound-cli
|
|
10
|
+
on:
|
|
11
|
+
tags: true
|
|
12
|
+
repo: platanus/hound-cli
|
data/README.md
CHANGED
|
@@ -56,17 +56,26 @@ You will get in your `$HOME` path the following files:
|
|
|
56
56
|
.scss-lint.yml
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Also, you can pass a linter's name to update rules for
|
|
59
|
+
Also, you can pass a linter's name to update rules for specific languages.
|
|
60
60
|
|
|
61
61
|
For example:
|
|
62
62
|
|
|
63
63
|
Running...
|
|
64
64
|
|
|
65
65
|
```
|
|
66
|
-
$ hound rules update ruby
|
|
66
|
+
$ hound rules update ruby tslint
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
You will get
|
|
69
|
+
You will get updated `.rubocop.yml` and `tslint.json` files in your `$HOME` path.
|
|
70
|
+
|
|
71
|
+
If you want to put the rules in the current path (your project's path) instead of `$HOME` you can run the command with `--local` option.
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
$ hound rules update --local
|
|
75
|
+
$ hound rules update ruby tslint --local
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> Running update with `--local` option will create a hound.yml file in the current path too.
|
|
70
79
|
|
|
71
80
|
## Contributing
|
|
72
81
|
|
|
File without changes
|
data/lib/hound/cli.rb
CHANGED
|
@@ -14,22 +14,18 @@ module Hound
|
|
|
14
14
|
|
|
15
15
|
def define_update_cmds
|
|
16
16
|
command("rules update") do |c|
|
|
17
|
-
c.syntax = "hound rules
|
|
18
|
-
c.
|
|
19
|
-
c.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
c.syntax = "hound rules update [#{ConfigCollection::LINTER_NAMES.join(' ')}] [options]"
|
|
18
|
+
c.option "--local", "Updates rules only for local project (current path)"
|
|
19
|
+
c.description = "Updates rules for enabled linters"
|
|
20
|
+
c.action do |linters, options|
|
|
21
|
+
linter_names = linters.empty? ? ConfigCollection::LINTER_NAMES : linters
|
|
22
|
+
RulesUpdater.update(linter_names, options.local || hound_yml_exist?)
|
|
23
|
+
end
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def
|
|
28
|
-
|
|
29
|
-
c.syntax = "hound rules update #{linter}"
|
|
30
|
-
c.description = "Update rules for #{linter} linter"
|
|
31
|
-
c.action { RulesUpdater.update(linter) }
|
|
32
|
-
end
|
|
27
|
+
def hound_yml_exist?
|
|
28
|
+
File.exist?(File.join(File.expand_path('.'), 'hound.yml'))
|
|
33
29
|
end
|
|
34
30
|
end
|
|
35
31
|
end
|
data/lib/hound/config/base.rb
CHANGED
|
@@ -7,8 +7,16 @@ module Hound
|
|
|
7
7
|
name_from_class
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def
|
|
11
|
-
|
|
10
|
+
def hound_yml_config
|
|
11
|
+
{
|
|
12
|
+
enabled: true,
|
|
13
|
+
config_file: linters_file_name
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def linters_file_path(local = false)
|
|
18
|
+
from = local ? "." : "~"
|
|
19
|
+
File.join(File.expand_path(from), linters_file_name)
|
|
12
20
|
end
|
|
13
21
|
|
|
14
22
|
def rules_url
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
module Hound
|
|
2
|
-
|
|
2
|
+
module ConfigCollection
|
|
3
|
+
extend self
|
|
4
|
+
|
|
3
5
|
LINTER_NAMES = %w{ruby eslint tslint scss}
|
|
4
6
|
|
|
5
|
-
def
|
|
7
|
+
def config_instances(linter_names = [])
|
|
6
8
|
linter_names = LINTER_NAMES if linter_names.empty?
|
|
7
9
|
linter_names.map do |linter|
|
|
8
10
|
ensure_valid_linter(linter)
|
|
@@ -10,13 +12,11 @@ module Hound
|
|
|
10
12
|
end
|
|
11
13
|
end
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
+
private
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
17
|
+
def ensure_valid_linter(linter)
|
|
18
|
+
if !LINTER_NAMES.include?(linter)
|
|
19
|
+
raise Hound::Error::InvalidLang.new("Invalid #{linter} linter")
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|
data/lib/hound/hound_config.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
module HoundConfig
|
|
2
|
+
extend self
|
|
3
|
+
|
|
2
4
|
CONFIG_FILE_REPOSITORY = "https://raw.githubusercontent.com/platanus/la-guia/master/"
|
|
3
5
|
|
|
4
|
-
def
|
|
6
|
+
def content
|
|
5
7
|
@@content ||= load_content
|
|
6
8
|
end
|
|
7
9
|
|
|
8
|
-
def
|
|
10
|
+
def enabled_for?(linter_name)
|
|
9
11
|
# disabled if linter_name key does not exist in hound.yml
|
|
10
12
|
return false unless content.key?(linter_name)
|
|
11
13
|
options = options_for(linter_name)
|
|
@@ -15,32 +17,30 @@ class HoundConfig
|
|
|
15
17
|
!!options["enabled"] || !!options["Enabled"]
|
|
16
18
|
end
|
|
17
19
|
|
|
18
|
-
def
|
|
20
|
+
def options_for(linter_name)
|
|
19
21
|
return content[linter_name] if content.respond_to?(:key?) && content.key?(linter_name)
|
|
20
22
|
Hash.new
|
|
21
23
|
end
|
|
22
24
|
|
|
23
|
-
def
|
|
25
|
+
def rules_url_for(linter_name)
|
|
24
26
|
path_in_repo = options_for(linter_name)["config_file"].to_s
|
|
25
27
|
HoundConfig::CONFIG_FILE_REPOSITORY + path_in_repo
|
|
26
28
|
end
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
+
private
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
def config_file_url
|
|
33
|
+
CONFIG_FILE_REPOSITORY + ".hound.yml"
|
|
34
|
+
end
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
def load_content
|
|
37
|
+
Hound::Parser.yaml(RestClient.get(config_file_url))
|
|
38
|
+
rescue RestClient::ResourceNotFound
|
|
39
|
+
inform_config_not_found(config_file_url)
|
|
40
|
+
Hash.new
|
|
41
|
+
end
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
end
|
|
43
|
+
def inform_config_not_found(url)
|
|
44
|
+
puts "config file not found in #{url}".red
|
|
45
45
|
end
|
|
46
46
|
end
|
data/lib/hound/parser.rb
CHANGED
data/lib/hound/rules_updater.rb
CHANGED
|
@@ -1,48 +1,62 @@
|
|
|
1
|
+
require "yaml"
|
|
2
|
+
|
|
1
3
|
module Hound
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
ConfigCollection.config_instances(linter_names).each do |linter_config|
|
|
5
|
-
get_rules(linter_config)
|
|
6
|
-
end
|
|
7
|
-
end
|
|
4
|
+
module RulesUpdater
|
|
5
|
+
extend self
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
def update(linter_names = [], local = false)
|
|
8
|
+
linter_configs = ConfigCollection.config_instances(linter_names)
|
|
9
|
+
write_rules(linter_configs, local)
|
|
10
|
+
write_hound_yml(linter_configs) if local
|
|
11
|
+
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
if !HoundConfig.enabled_for?(linter_config.name)
|
|
14
|
-
inform_disabled(linter_config)
|
|
15
|
-
return
|
|
16
|
-
end
|
|
13
|
+
private
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
def write_hound_yml(linter_configs)
|
|
16
|
+
hound_config = linter_configs.inject({}) do |memo, linter_config|
|
|
17
|
+
memo[linter_config.name] = linter_config.hound_yml_config
|
|
18
|
+
memo
|
|
22
19
|
end
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
inform_rules_not_found(linter_config)
|
|
28
|
-
end
|
|
21
|
+
hound_yml_path = File.join(File.expand_path('.'), 'hound.yml')
|
|
22
|
+
File.write(hound_yml_path, hound_config.to_yaml)
|
|
23
|
+
end
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
def write_rules(linter_configs, local)
|
|
26
|
+
linter_configs.each do |linter_config|
|
|
27
|
+
get_rules(linter_config, local)
|
|
32
28
|
end
|
|
29
|
+
end
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
def get_rules(linter_config, local)
|
|
32
|
+
if !HoundConfig.enabled_for?(linter_config.name)
|
|
33
|
+
inform_disabled(linter_config)
|
|
34
|
+
return
|
|
36
35
|
end
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
rules = get_rules_from_url(linter_config)
|
|
38
|
+
return unless rules
|
|
39
|
+
File.write(linter_config.linters_file_path(local), rules)
|
|
40
|
+
inform_update(linter_config)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def get_rules_from_url(linter_config)
|
|
44
|
+
RestClient.get(linter_config.rules_url)
|
|
45
|
+
rescue RestClient::ResourceNotFound
|
|
46
|
+
inform_rules_not_found(linter_config)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def inform_update(linter_config)
|
|
50
|
+
puts "#{linter_config.linters_file_name} (#{linter_config.name} style) was updated".green
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def inform_disabled(linter_config)
|
|
54
|
+
puts "#{linter_config.linters_file_name} (#{linter_config.name} style) wasn't updated \
|
|
40
55
|
because the style was undefined or disabled in .hound.yml file".yellow
|
|
41
|
-
|
|
56
|
+
end
|
|
42
57
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
end
|
|
58
|
+
def inform_rules_not_found(linter_config)
|
|
59
|
+
puts "rules for #{linter_config.name} not found in #{linter_config.rules_url}".red
|
|
46
60
|
end
|
|
47
61
|
end
|
|
48
62
|
end
|
data/lib/hound/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hound-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Platanus
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-12-
|
|
11
|
+
date: 2016-12-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: colorize
|
|
@@ -145,7 +145,7 @@ files:
|
|
|
145
145
|
- bin/console
|
|
146
146
|
- bin/setup
|
|
147
147
|
- exe/hound
|
|
148
|
-
- hound.gemspec
|
|
148
|
+
- hound-cli.gemspec
|
|
149
149
|
- lib/hound.rb
|
|
150
150
|
- lib/hound/cli.rb
|
|
151
151
|
- lib/hound/config/base.rb
|
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
179
179
|
version: '0'
|
|
180
180
|
requirements: []
|
|
181
181
|
rubyforge_project:
|
|
182
|
-
rubygems_version: 2.5
|
|
182
|
+
rubygems_version: 2.4.5
|
|
183
183
|
signing_key:
|
|
184
184
|
specification_version: 4
|
|
185
185
|
summary: Ruby CLI to generate style rules
|