-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ported to CoffeeScript 2 #268
Open
mitar
wants to merge
2
commits into
vsivsi:master
Choose a base branch
from
mitar:coffeescript2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ Package.describe({ | |
|
||
Package.onUse(function(api) { | ||
api.use('mrt:[email protected]', ['server','client']); | ||
api.use('[email protected]_1', ['server','client']); | ||
api.use('[email protected]_3', ['server','client']); | ||
api.use('[email protected]', ['server','client']); | ||
api.use('[email protected]', ['server','client']); | ||
api.use('[email protected]', ['server','client']); | ||
api.addFiles('job/src/job_class.coffee', ['server','client']); | ||
|
@@ -29,7 +30,8 @@ Package.onUse(function(api) { | |
Package.onTest(function (api) { | ||
api.use('vsivsi:job-collection@' + currentVersion, ['server','client']); | ||
api.use('mrt:[email protected]', ['server','client']); | ||
api.use('[email protected]_1', ['server','client']); | ||
api.use('[email protected]_3', ['server','client']); | ||
api.use('[email protected]', ['server','client']); | ||
api.use('[email protected]', ['server','client']); | ||
api.use('[email protected]', ['server','client']); | ||
api.use('[email protected]', ['server','client']); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,23 +78,22 @@ _validJobDoc = () -> | |
repeatWait: Match.OneOf(Match.Where(_validIntGTEZero), Match.Where(_validLaterJSObj)) | ||
created: Date | ||
|
||
class JobCollectionBase extends Mongo.Collection | ||
|
||
constructor: (@root = 'queue', options = {}) -> | ||
unless @ instanceof JobCollectionBase | ||
return new JobCollectionBase(@root, options) | ||
_getAllProperties = (obj) -> | ||
names = new Set() | ||
properties = [] | ||
while obj | ||
for name in Object.getOwnPropertyNames(obj) when name not in names | ||
properties.push([name, obj[name]]) | ||
names.add(name) | ||
obj = Object.getPrototypeOf(obj) | ||
properties | ||
|
||
unless @ instanceof Mongo.Collection | ||
throw new Meteor.Error 'The global definition of Mongo.Collection has changed since the job-collection package was loaded. Please ensure that any packages that redefine Mongo.Collection are loaded before job-collection.' | ||
|
||
unless Mongo.Collection is Mongo.Collection.prototype.constructor | ||
throw new Meteor.Error 'The global definition of Mongo.Collection has been patched by another package, and the prototype constructor has been left in an inconsistent state. Please see this link for a workaround: https://github.com/vsivsi/meteor-file-sample-app/issues/2#issuecomment-120780592' | ||
|
||
@later = later # later object, for convenience | ||
class JobCollectionBase extends Mongo.Collection | ||
|
||
constructor: (root = 'queue', options = {}) -> | ||
options.noCollectionSuffix ?= false | ||
|
||
collectionName = @root | ||
collectionName = root | ||
|
||
unless options.noCollectionSuffix | ||
collectionName += '.jobs' | ||
|
@@ -103,7 +102,20 @@ class JobCollectionBase extends Mongo.Collection | |
# calling Mongo.Collection constructor | ||
delete options.noCollectionSuffix | ||
|
||
Job.setDDP(options.connection, @root) | ||
Job.setDDP(options.connection, root) | ||
|
||
# Call super's constructor | ||
super collectionName, options | ||
|
||
unless @ instanceof Mongo.Collection | ||
throw new Meteor.Error 'The global definition of Mongo.Collection has changed since the job-collection package was loaded. Please ensure that any packages that redefine Mongo.Collection are loaded before job-collection.' | ||
|
||
unless Mongo.Collection is Mongo.Collection.prototype.constructor | ||
throw new Meteor.Error 'The global definition of Mongo.Collection has been patched by another package, and the prototype constructor has been left in an inconsistent state. Please see this link for a workaround: https://github.com/vsivsi/meteor-file-sample-app/issues/2#issuecomment-120780592' | ||
|
||
@root = root | ||
|
||
@later = later # later object, for convenience | ||
|
||
@_createLogEntry = (message = '', runId = null, level = 'info', time = new Date(), data = null) -> | ||
l = { time: time, runId: runId, message: message, level: level } | ||
|
@@ -128,9 +140,6 @@ class JobCollectionBase extends Mongo.Collection | |
level = if fatal then 'danger' else 'warning' | ||
@_createLogEntry msg, runId, level).bind(@) | ||
|
||
# Call super's constructor | ||
super collectionName, options | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No access to |
||
|
||
_validNumGTEZero: _validNumGTEZero | ||
_validNumGTZero: _validNumGTZero | ||
_validNumGTEOne: _validNumGTEOne | ||
|
@@ -222,7 +231,7 @@ class JobCollectionBase extends Mongo.Collection | |
_generateMethods: () -> | ||
methodsOut = {} | ||
methodPrefix = '_DDPMethod_' | ||
for methodName, methodFunc of @ when methodName[0...methodPrefix.length] is methodPrefix | ||
for [methodName, methodFunc] in _getAllProperties(@) when methodName[0...methodPrefix.length] is methodPrefix | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
baseMethodName = methodName[methodPrefix.length..] | ||
methodsOut["#{@root}_#{baseMethodName}"] = @_methodWrapper(baseMethodName, methodFunc.bind(@)) | ||
return methodsOut | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to hardcode this because I have no idea how to get to
__super__
equivalent in new CoffeeScript/JavaScript.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See: jashkenas/coffeescript#4858