npmdc 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7eada3811dc31b5a240495eba981289843e70a7
4
- data.tar.gz: e4c1bf4e93e6d0b56682a4403c1aee1b7c7fa412
3
+ metadata.gz: c1fd0abf8808ba29b1d65b59667cd47319ce76e6
4
+ data.tar.gz: d5d195c20a74dc5e8536de5d0519cd7bf32092d7
5
5
  SHA512:
6
- metadata.gz: 7ec1aad5bcae24fbd540061ac20caa085e3e69c04e045bac1352d53b1d3e2921135187ab747f47f395c15dd19c883c1c08d3a3c730d8888f8a1e1fc43b7965f3
7
- data.tar.gz: 277912a03de5824c67f3a857408aaa9c55d7943e210ee0a8d210216115e3c549f76f12df517bfa4a3266747a2b6fbe4cc1896dbaf5f7641f83b97326cba06062
6
+ metadata.gz: 9c94b169047a5d883c55d58c6894a1f33cd82110304d09a9346958e51e9a161086c0d82eaa42178615c97373c0da7ed9237ed6116975b68444a9c2f2401520f2
7
+ data.tar.gz: 89e042a0604efa0c992b9eb31a7b6c0e7c619c6f1d7c253d840aced2be3c2cfbf7e6ee363ff02cecd3395a80606d0fed7c47c75dede087c8d039fc954e1d5484
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.1.0 First release
1
+ ### 0.1.0
2
2
 
3
3
  Initial implementation of Npmdc gem with following features:
4
4
 
@@ -9,7 +9,7 @@ Initial implementation of Npmdc gem with following features:
9
9
  * Standalone CLI tool
10
10
 
11
11
 
12
- ### 0.1.1 Compatibility improvemnts
12
+ ### 0.1.1
13
13
 
14
14
  * Now works with Ruby >= 2.2.0
15
15
 
@@ -43,15 +43,22 @@ Thanks to @aderyabin !
43
43
 
44
44
  ### 0.2.2
45
45
 
46
- Thanks to @palkan !
47
-
48
46
  * Fixed runtime dependencies
49
47
 
50
48
 
51
49
  ### 0.2.3
52
50
 
51
+ Thanks to @palkan !
52
+
53
53
  * Improved Rails integration
54
54
 
55
55
  * Add Rails integration specs
56
56
 
57
57
  * Minor improvemnts
58
+
59
+
60
+ ### 0.2.4
61
+
62
+ * Fixed Rails integration
63
+
64
+ * Fixed options handling from config
data/README.md CHANGED
@@ -34,12 +34,9 @@ Or install it yourself as:
34
34
 
35
35
  ```ruby
36
36
  YourApp::Application.configure do
37
- config.npmdc = {
38
- :path => "/path/to/your/frontend/code/dir" # `Rails.root` by default,
39
- :verbose => true # `false` by default
40
- :'no-color' => true # `false` by default
41
- :format => "doc" # `short`, `doc`, `progress`. `short` by default
42
- }
37
+ config.npmdc.path = "/path/to/your/frontend/code/dir" # `Rails.root` by default
38
+ config.npmdc.format = "doc" # `short`, `doc`, `progress`. `short` by default
39
+ config.npmdc.color = false # `true` by default
43
40
  end
44
41
  ```
45
42
 
@@ -54,11 +51,9 @@ _Options:_
54
51
 
55
52
  * --path PATH - Path to frontend code
56
53
 
57
- * -V, --verbose - Set the verbose level of output
54
+ * --color - Disable color formatting of output
58
55
 
59
- * --no-color - Disable color formatting of output
60
-
61
- * --format FORMAT - Set format of output
56
+ * -f, --format FORMAT - Set format of output
62
57
 
63
58
 
64
59
  ## Development
data/bin/npmdc CHANGED
@@ -3,4 +3,5 @@
3
3
  require 'bundler/setup'
4
4
  require 'npmdc/cli'
5
5
 
6
- Npmdc::Cli.start(ARGV)
6
+ result = Npmdc::Cli.start(ARGV)
7
+ exit(result ? 0 : 1)
data/lib/npmdc/checker.rb CHANGED
@@ -14,7 +14,7 @@ module Npmdc
14
14
  DEPENDENCIES = %w(dependencies devDependencies).freeze
15
15
 
16
16
  def initialize(options)
17
- @path = options[:path] || Dir.pwd
17
+ @path = options.fetch('path', Npmdc.config.path)
18
18
  @formatter = Npmdc::Formatter.(options)
19
19
  @dependencies_count = 0
20
20
  @missing_dependencies = Set.new
data/lib/npmdc/cli.rb CHANGED
@@ -8,7 +8,9 @@ module Npmdc
8
8
  desc 'check', 'Run check'
9
9
  method_option :path, desc: 'Path to package.json config'
10
10
  method_option :color, desc: 'Enable color', type: :boolean, default: true
11
- method_option :format, desc: "Output format, possible values: #{Npmdc::Formatter::FORMATTERS.keys.join(", ")}"
11
+ method_option :format, aliases: [:f],
12
+ desc: "Output format,
13
+ possible values: #{Npmdc::Formatter::FORMATTERS.keys.join(", ")}"
12
14
 
13
15
  def check
14
16
  Npmdc.call(options)
@@ -0,0 +1,20 @@
1
+ module Npmdc
2
+ class Config
3
+ attr_accessor :color, :format, :output
4
+ attr_writer :path
5
+
6
+ def initialize
7
+ @color = true
8
+ @format = :short
9
+ @output = STDOUT
10
+ end
11
+
12
+ def path
13
+ @path ||= Dir.pwd
14
+ end
15
+
16
+ def path?
17
+ instance_variable_defined?(:@path)
18
+ end
19
+ end
20
+ end
data/lib/npmdc/engine.rb CHANGED
@@ -2,12 +2,12 @@ require 'npmdc'
2
2
 
3
3
  module Npmdc
4
4
  class Engine < Rails::Engine # :nodoc:
5
- config.npmdc = ActiveSupport::OrderedOptions.new
5
+ # Make config accessible through application config
6
+ config.npmdc = Npmdc.config
6
7
 
7
- initializer "npmdc.load_hook" do |app|
8
- options = app.config.npmdc
9
- options.path ||= Rails.root
10
- Npmdc.call(options)
8
+ initializer "npmdc.load_hook" do |_app|
9
+ Npmdc.config.path = Rails.root unless Npmdc.config.path?
10
+ Npmdc.call
11
11
  end
12
12
  end
13
13
  end
@@ -11,11 +11,9 @@ module Npmdc
11
11
  short: Npmdc::Formatters::Short
12
12
  }.freeze
13
13
 
14
- DEFAULT_FORMAT = :short
15
-
16
14
  class << self
17
15
  def call(options)
18
- fmt = options.fetch(:format, DEFAULT_FORMAT)
16
+ fmt = options.fetch('format', Npmdc.config.format)
19
17
  FORMATTERS[fmt.to_sym].new(options)
20
18
  end
21
19
  end
@@ -11,10 +11,10 @@ module Npmdc
11
11
  info: :white
12
12
  }.freeze
13
13
 
14
- def initialize(options, output = Npmdc.output)
14
+ def initialize(options, output = Npmdc.config.output)
15
15
  @options = options
16
16
  @output = output
17
- @disable_colorization = !@options.fetch(:color, true)
17
+ @disable_colorization = !@options.fetch('color', Npmdc.config.color)
18
18
  end
19
19
 
20
20
  def output(message, status = nil)
data/lib/npmdc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Npmdc
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
data/lib/npmdc.rb CHANGED
@@ -1,17 +1,21 @@
1
- require "npmdc/checker"
2
- require "npmdc/engine" if defined?(Rails)
3
- require "npmdc/version"
4
-
5
1
  module Npmdc
6
- class << self
7
- attr_writer :output
2
+ require "npmdc/config"
3
+ require "npmdc/checker"
4
+ require "npmdc/version"
8
5
 
6
+ class << self
9
7
  def call(options = {})
10
8
  Npmdc::Checker.new(options).call
11
9
  end
12
10
 
13
- def output
14
- @output ||= STDOUT
11
+ def config
12
+ @config ||= Config.new
13
+ end
14
+
15
+ def configure
16
+ yield config
15
17
  end
16
18
  end
19
+
20
+ require "npmdc/engine" if defined?(Rails)
17
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: npmdc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Kashkevich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-05 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -136,6 +136,7 @@ files:
136
136
  - lib/npmdc.rb
137
137
  - lib/npmdc/checker.rb
138
138
  - lib/npmdc/cli.rb
139
+ - lib/npmdc/config.rb
139
140
  - lib/npmdc/engine.rb
140
141
  - lib/npmdc/errors.rb
141
142
  - lib/npmdc/formatter.rb
@@ -144,7 +145,6 @@ files:
144
145
  - lib/npmdc/formatters/progress.rb
145
146
  - lib/npmdc/formatters/short.rb
146
147
  - lib/npmdc/version.rb
147
- - log/test.log
148
148
  - npmdc.gemspec
149
149
  homepage: https://github.com/lysyi3m/npmdc
150
150
  licenses:
data/log/test.log DELETED
File without changes