papers 1.3.2 → 1.4.0

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: 853ae8cf71390d0158e03316b260bfe0cdb6c0ca
4
- data.tar.gz: 71dcbec230a9bb2363eeb02dea72e3b961f591a4
3
+ metadata.gz: 602d2e8efd00f7bda59f79de438fa79552e746ca
4
+ data.tar.gz: 1f129b2abe8801b64282b66737335f57bc94d198
5
5
  SHA512:
6
- metadata.gz: da08736d68659f2b5929ca8fe0c58a5deaca3f7e73490fa334c3fd5b8878deeed6d687c31d54b7f29026077d1220a6b3ac26727215f139c031884c9a5f23f6a4
7
- data.tar.gz: 2faa06656c4dfc338d7ef6758a0079fb370fbde4cd3b2ce0a6266c99c22e7ba699d5ac6cf4e75352124c7f1083b270e935ae25b89c4217da4dc8f917b07c2cfd
6
+ metadata.gz: 41ed2f34f0bfb9fa62e2641be4db5f81fba749f00473449ffd2df6d7c126a94d93b53a51e47d27b97d986c8456845b705d46e95ad6c4a217c9da094243abcf3e
7
+ data.tar.gz: 6952d6905f4f021906cb994de7e010cc655fee265a96ec32b94a545d99004a011cbc510a18eb34c01a8b82bd476dc2f752300ee3223b810b96bb756770fae8f8
@@ -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["#{dir}/**/*.{js,coffee}"] }.flatten.map { |name| name.sub(root_regexp, '') }
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
@@ -1,8 +1,8 @@
1
1
  module Papers
2
2
  class Version
3
3
  MAJOR = 1
4
- MINOR = 3
5
- PATCH = 2
4
+ MINOR = 4
5
+ PATCH = 0
6
6
 
7
7
  def self.to_s
8
8
  [MAJOR, MINOR, PATCH].join('.')
@@ -13,8 +13,8 @@ describe 'NpmPackageSpecification' do
13
13
  ])
14
14
  end
15
15
 
16
- it "raises an error when package.json is not found" do
17
- expect { Papers::NpmPackage.full_introspected_entries }.to raise_error Errno::ENOENT
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.3.2
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-07-18 00:00:00.000000000 Z
15
+ date: 2014-08-12 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake