From 499ea04f991c9e290030df9d0b2f34d8359ee6fe Mon Sep 17 00:00:00 2001 From: Jared K. Smith Date: Feb 10 2016 18:07:53 +0000 Subject: Initial packaging --- diff --git a/.gitignore b/.gitignore index e69de29..d3bac50 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/for-in-0.1.4.tgz diff --git a/nodejs-for-in.spec b/nodejs-for-in.spec new file mode 100644 index 0000000..35fc8a0 --- /dev/null +++ b/nodejs-for-in.spec @@ -0,0 +1,73 @@ +%{?nodejs_find_provides_and_requires} + +%global packagename for-in +%global enable_tests 1 + +Name: nodejs-for-in +Version: 0.1.4 +Release: 1%{?dist} +Summary: Iterate over the own and inherited enumerable properties of an object + +License: MIT +URL: https://github.com/jonschlinkert/for-in.git +Source0: https://registry.npmjs.org/%{packagename}/-/%{packagename}-%{version}.tgz +# The test files are not included in the npm tarball. +# The 0.1.4 release hasn't been tagged in github, so pull from master for now +Source1: https://raw.githubusercontent.com/jonschlinkert/for-in/master/test.js + + +BuildArch: noarch +%if 0%{?fedora} >= 19 +ExclusiveArch: %{nodejs_arches} noarch +%else +ExclusiveArch: %{ix86} x86_64 %{arm} noarch +%endif + +BuildRequires: nodejs-packaging +%if 0%{?enable_tests} +BuildRequires: mocha +BuildRequires: npm(should) +%endif + +%description +Iterate over the own and inherited enumerable properties of an object, and +return an object with properties that evaluate to true from the callback. +Exit early by returning `false`. + + +%prep +%setup -q -n package +# setup the tests +cp -p %{SOURCE1} . + + +%build +# nothing to do! + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/%{packagename} +cp -pr package.json index.js \ + %{buildroot}%{nodejs_sitelib}/%{packagename} + +%nodejs_symlink_deps + +%check +%nodejs_symlink_deps --check +%{__nodejs} -e 'require("./")' +%if 0%{?enable_tests} +%{_bindir}/mocha -R spec +%else +%{_bindir}/echo "Tests disabled..." +%endif + + +%files +%{!?_licensedir:%global license %doc} +%doc *.md +%license LICENSE +%{nodejs_sitelib}/%{packagename} + + +%changelog +* Tue Feb 9 2016 Jared Smith - 0.1.4-1 +- Initial packaging diff --git a/sources b/sources index e69de29..6c50582 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +f2dba3ff30b9fb0528a588ad26abe982 for-in-0.1.4.tgz diff --git a/test.js b/test.js new file mode 100644 index 0000000..026c4a2 --- /dev/null +++ b/test.js @@ -0,0 +1,45 @@ +/*! + * for-in + * + * Copyright (c) 2014-2015, Jon Schlinkert. + * Licensed under the MIT License. + */ + +'use strict'; + +var should = require('should'); +var forIn = require('./'); + +describe('.forIn()', function () { + it('should loop through all properties in the object.', function () { + var obj = {a: 'foo', b: 'bar', c: 'baz'}; + var values = []; + var keys = []; + + forIn(obj, function (value, key, o) { + o.should.eql(obj); + keys.push(key); + values.push(value); + }); + + keys.should.eql(['a', 'b', 'c']); + values.should.eql(['foo', 'bar', 'baz']); + }); + + it('should break the loop early if `false` is returned.', function () { + var obj = {a: 'foo', b: 'bar', c: 'baz'}; + var values = []; + var keys = []; + + forIn(obj, function (value, key, o) { + if (key === 'b') { + return false; + } + keys.push(key); + values.push(value); + }); + + keys.should.eql(['a']); + values.should.eql(['foo']); + }); +});