npmdc 0.3.1 → 0.3.2

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: 3149d54b1f4c009a0a44ee9a966259ee15ac7453
4
- data.tar.gz: bce13cfe5366d363cd8cf416b6e3fda2eef6d490
3
+ metadata.gz: 8a56c417f7018f76df103bb2e55ffdf8a336a95e
4
+ data.tar.gz: 113c029da152241b908c6f6cdc19fd860871ec1f
5
5
  SHA512:
6
- metadata.gz: ae014c53a40240189f8a5f0d07550cc5fe01c8e9e53e3f7c8d94c6cbc13bae64b085948003cb459653d0699eec6ad067b38f89f64d4545626d0eaf731e5e4c25
7
- data.tar.gz: 889c62c84f4fb3c409ce736e865c1a83de609cae53c1eb9db8e3d44ffd86699be7e0752edaf722d896a270c3e7c6f331cfda7b87594ce6b9d425fd0b35e8b112
6
+ metadata.gz: 7b801894de357bbcdc00431b9c83530d6b9f6087feddd1db8da84a1b0d0d03ccc4d35f66f8bc61cfbb8361882e381b5ccdd89091111e056341b47899e72adb49
7
+ data.tar.gz: a10d71f989b3ace2c97bc9babba12778e3a6e174c3424d90021cfa095d8881efa6703679438cb73f356a905d5f0aab1cd3d0890664a3ce32b6a3a310620c64f4
data/CHANGELOG.md CHANGED
@@ -85,3 +85,10 @@ Thanks to @aderyabin !
85
85
  Thanks to @palkan !
86
86
 
87
87
  * Added support for Ruby >= 2.1 and Rails 3.2
88
+
89
+
90
+ ### 0.3.2
91
+
92
+ Thanks to @sponomarev !
93
+
94
+ * Added support for environment-based configuration
data/README.md CHANGED
@@ -20,7 +20,7 @@ npmdc
20
20
  Add this line to your application's Gemfile:
21
21
 
22
22
  ```ruby
23
- gem 'npmdc'
23
+ gem 'npmdc', group: :development
24
24
  ```
25
25
 
26
26
  And then execute:
@@ -37,10 +37,11 @@ Or install it yourself as:
37
37
 
38
38
  ```ruby
39
39
  YourApp::Application.configure do
40
- config.npmdc.path = "/path/to/your/frontend/code/dir" # `Rails.root` by default
41
- config.npmdc.format = "doc" # `short`, `doc`, `progress`. `short` by default
42
- config.npmdc.color = false # `true` by default
43
- config.npmdc.types = ["dependencies"] # `["dependencies", "devDependencies"]` by default
40
+ config.npmdc.path = "/path/to/your/frontend/code/dir" # `Rails.root` by default
41
+ config.npmdc.format = "doc" # `short`, `doc`, `progress`. `short` by default
42
+ config.npmdc.color = false # `true` by default
43
+ config.npmdc.types = ["dependencies"] # `["dependencies", "devDependencies"]` by default
44
+ config.npmdc.environments = ["development"] # `development` only by default
44
45
  end
45
46
  ```
46
47
 
data/lib/npmdc/config.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  module Npmdc
2
2
  class Config
3
3
  DEPEPENDENCY_TYPES = %w(dependencies devDependencies).freeze
4
+ ENVIRONMENTS = %w(development).freeze
4
5
 
5
- attr_accessor :color, :format, :output, :types
6
+ attr_accessor :color, :format, :output, :types, :environments
6
7
  attr_writer :path
7
8
 
8
9
  def initialize
@@ -10,6 +11,7 @@ module Npmdc
10
11
  @format = :short
11
12
  @output = STDOUT
12
13
  @types = DEPEPENDENCY_TYPES
14
+ @environments = ENVIRONMENTS
13
15
  end
14
16
 
15
17
  def path
@@ -0,0 +1,9 @@
1
+ module StringStripHeredoc
2
+ refine String do
3
+ def strip_heredoc
4
+ min = scan(/^[ \t]*(?=\S)/).min
5
+ indent = min ? min.size : 0
6
+ gsub(/^[ \t]{#{indent}}/, '')
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ require 'npmdc/core/string_strip_heredoc'
2
+
3
+ module Npmdc
4
+ class Railtie < Rails::Railtie # :nodoc:
5
+ using StringStripHeredoc
6
+
7
+ # Make config accessible through application config
8
+ config.npmdc = Npmdc.config
9
+
10
+ initializer "npmdc.initialize" do
11
+ Npmdc.config.path = Rails.root unless Npmdc.config.path?
12
+ end
13
+
14
+ initializer "npmdc.environment_check" do
15
+ unless config.npmdc.environments.include?(Rails.env)
16
+ abort <<-END.strip_heredoc
17
+ Npmdc is trying to be activated in the #{Rails.env} environment.
18
+ Probably, this is a mistake. To ensure it's only activated in development
19
+ mode, move it to the development group of your Gemfile:
20
+ gem 'npmdc', group: :development
21
+ If you still want to run it in the #{Rails.env} environment (and know
22
+ what you are doing), put this in your Rails application
23
+ configuration:
24
+ config.npmdc.environments = ['development', '#{Rails.env}']
25
+ END
26
+ end
27
+ end
28
+
29
+ initializer "npmdc.call" do
30
+ Npmdc.call
31
+ end
32
+ end
33
+ end
data/lib/npmdc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Npmdc
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
data/lib/npmdc.rb CHANGED
@@ -22,5 +22,5 @@ module Npmdc
22
22
  end
23
23
  end
24
24
 
25
- require "npmdc/engine" if defined?(Rails)
25
+ require "npmdc/railtie" if defined?(Rails)
26
26
  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.3.1
4
+ version: 0.3.2
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-18 00:00:00.000000000 Z
11
+ date: 2016-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -152,13 +152,14 @@ files:
152
152
  - lib/npmdc/checker.rb
153
153
  - lib/npmdc/cli.rb
154
154
  - lib/npmdc/config.rb
155
- - lib/npmdc/engine.rb
155
+ - lib/npmdc/core/string_strip_heredoc.rb
156
156
  - lib/npmdc/errors.rb
157
157
  - lib/npmdc/formatter.rb
158
158
  - lib/npmdc/formatters/base.rb
159
159
  - lib/npmdc/formatters/documentation.rb
160
160
  - lib/npmdc/formatters/progress.rb
161
161
  - lib/npmdc/formatters/short.rb
162
+ - lib/npmdc/railtie.rb
162
163
  - lib/npmdc/version.rb
163
164
  - npmdc.gemspec
164
165
  homepage: https://github.com/lysyi3m/npmdc
@@ -181,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
182
  version: '0'
182
183
  requirements: []
183
184
  rubyforge_project:
184
- rubygems_version: 2.5.2
185
+ rubygems_version: 2.4.5
185
186
  signing_key:
186
187
  specification_version: 4
187
188
  summary: Check for missed dependencies of NPM packages.
data/lib/npmdc/engine.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'npmdc'
2
-
3
- module Npmdc
4
- class Engine < Rails::Engine # :nodoc:
5
- # Make config accessible through application config
6
- config.npmdc = Npmdc.config
7
-
8
- initializer "npmdc.load_hook" do |_app|
9
- Npmdc.config.path = Rails.root unless Npmdc.config.path?
10
- Npmdc.call
11
- end
12
- end
13
- end