papers 1.3.2 → 1.4.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/lib/papers/configuration.rb +2 -0
- data/lib/papers/dependency_specification/javascript.rb +6 -1
- data/lib/papers/version.rb +2 -2
- data/spec/npm_package_spec.rb +2 -2
- data/spec/papers_spec.rb +29 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 602d2e8efd00f7bda59f79de438fa79552e746ca
|
4
|
+
data.tar.gz: 1f129b2abe8801b64282b66737335f57bc94d198
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41ed2f34f0bfb9fa62e2641be4db5f81fba749f00473449ffd2df6d7c126a94d93b53a51e47d27b97d986c8456845b705d46e95ad6c4a217c9da094243abcf3e
|
7
|
+
data.tar.gz: 6952d6905f4f021906cb994de7e010cc655fee265a96ec32b94a545d99004a011cbc510a18eb34c01a8b82bd476dc2f752300ee3223b810b96bb756770fae8f8
|
data/lib/papers/configuration.rb
CHANGED
@@ -11,6 +11,7 @@ module Papers
|
|
11
11
|
attr_accessor :validate_npm_packages
|
12
12
|
|
13
13
|
attr_accessor :javascript_paths
|
14
|
+
attr_accessor :whitelist_javascript_paths
|
14
15
|
attr_accessor :bower_components_path
|
15
16
|
attr_accessor :npm_package_json_path
|
16
17
|
|
@@ -42,6 +43,7 @@ module Papers
|
|
42
43
|
File.join(Dir.pwd, 'lib', 'assets', 'javascripts'),
|
43
44
|
File.join(Dir.pwd, 'vendor', 'assets', 'javascripts')
|
44
45
|
]
|
46
|
+
@whitelist_javascript_paths = []
|
45
47
|
|
46
48
|
@bower_components_path = File.join(Dir.pwd, 'vendor', 'assets', 'components')
|
47
49
|
|
@@ -11,10 +11,15 @@ module Papers
|
|
11
11
|
|
12
12
|
def self.introspected
|
13
13
|
dirs = Papers.config.javascript_paths
|
14
|
+
whitelist_dirs = Papers.config.whitelist_javascript_paths
|
14
15
|
|
15
16
|
# TODO: add logic for determining rails. Is Rails.root better than Dir.pwd for such a case?
|
16
17
|
root_regexp = /^#{Regexp.escape Dir.pwd.to_s}\//
|
17
|
-
dirs.map { |dir| Dir
|
18
|
+
files = dirs.map { |dir| Dir.glob("#{dir}/**/*.{js,coffee}") }.flatten.map do |name|
|
19
|
+
name = name.sub(root_regexp, '')
|
20
|
+
name unless whitelist_dirs.any? { |dir| name.start_with?(dir) }
|
21
|
+
end
|
22
|
+
files.compact
|
18
23
|
end
|
19
24
|
|
20
25
|
def self.manifest_key
|
data/lib/papers/version.rb
CHANGED
data/spec/npm_package_spec.rb
CHANGED
@@ -13,8 +13,8 @@ describe 'NpmPackageSpecification' do
|
|
13
13
|
])
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
expect
|
16
|
+
it "returns an empty list if package.json is not found" do
|
17
|
+
expect(Papers::NpmPackage.full_introspected_entries).to eq([])
|
18
18
|
end
|
19
19
|
|
20
20
|
it "raises an error when package.json does not parse properly" do
|
data/spec/papers_spec.rb
CHANGED
@@ -307,4 +307,33 @@ describe 'Papers' do
|
|
307
307
|
gemspec = Papers::Gem.new(name: 'foo')
|
308
308
|
expect('foo').to eq(gemspec.name_without_version)
|
309
309
|
end
|
310
|
+
|
311
|
+
it 'is OK with whitelisting javascript javascript_paths' do
|
312
|
+
# contents of javascript dir and no gems
|
313
|
+
Dir.stub(:glob){[
|
314
|
+
'app/javascripts/node_modules/should_be_whitelisted.js',
|
315
|
+
'app/javascripts/test.js'
|
316
|
+
]}
|
317
|
+
Papers::Gem.stub(:introspected).and_return([])
|
318
|
+
|
319
|
+
Papers::LicenseValidator.any_instance.stub(:manifest).and_return({
|
320
|
+
'javascripts' => {
|
321
|
+
'app/javascripts/test.js' => {
|
322
|
+
'license' => 'MIT',
|
323
|
+
'license_url' => nil,
|
324
|
+
'project_url' => nil
|
325
|
+
}
|
326
|
+
},
|
327
|
+
'gems' => {}
|
328
|
+
})
|
329
|
+
Papers::Configuration.any_instance.stub(:javascript_paths).and_return(['app/javascripts/'])
|
330
|
+
|
331
|
+
# whitelist this directory
|
332
|
+
Papers::Configuration.any_instance.stub(:whitelist_javascript_paths).and_return(['app/javascripts/node_modules'])
|
333
|
+
|
334
|
+
expect(Papers::Javascript.introspected).to_not include('app/javascripts/node_modules/should_be_whitelisted.js')
|
335
|
+
expect(validator).to be_valid
|
336
|
+
end
|
337
|
+
|
338
|
+
|
310
339
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: papers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ralph Bodenner
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-
|
15
|
+
date: 2014-08-12 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|