-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
105 changed files
with
1,924 additions
and
719 deletions.
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
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
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
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const object = require('../../../../runtime/object') | ||
const {LAMBDA, RHO} = require('../../../../runtime/attribute/specials'); | ||
const {STRING} = require('../../../../runtime/types'); | ||
const fs = require('fs'); | ||
const dataized = require('../../../../runtime/dataized'); | ||
const data = require('../../../../runtime/data') | ||
|
||
/** | ||
* Dir.made.mkdir. | ||
* @return {Object} - Dir.made.mkdir object | ||
*/ | ||
const dir$made$mkdir = function() { | ||
const obj = object('dir$made$mkdir') | ||
obj.assets[LAMBDA] = function(self) { | ||
fs.mkdirSync( | ||
String(dataized(self.take(RHO).take(RHO).take('file'), STRING)), | ||
{recursive: true} | ||
) | ||
return data.toObject(true) | ||
} | ||
return obj | ||
} | ||
|
||
module.exports = dir$made$mkdir |
69 changes: 69 additions & 0 deletions
69
eo2js-runtime/src/objects/org/eolang/fs/dir$tmpfile$touch.js
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const object = require('../../../../runtime/object') | ||
const {LAMBDA, RHO} = require('../../../../runtime/attribute/specials'); | ||
const {STRING} = require('../../../../runtime/types'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const dataized = require('../../../../runtime/dataized'); | ||
const data = require('../../../../runtime/data') | ||
|
||
/** | ||
* Random chars sequence. | ||
* @type {string} | ||
*/ | ||
const RANDOM_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' | ||
|
||
/** | ||
* Random name generator based on crypto. | ||
* Adapted from https://github.com/raszi/node-tmp/blob/5f0b2525ed6f6a977ea0cc272d4903d9d2216059/lib/tmp.js#L411 | ||
* @param {number} amount - Amount of generated name | ||
* @return {string} - The generated random name | ||
*/ | ||
function randomChars(amount) { | ||
const value = [] | ||
let rnd | ||
try { | ||
rnd = crypto.randomBytes(amount); | ||
} catch (e) { | ||
rnd = crypto.pseudoRandomBytes(amount); | ||
} | ||
for (let idx = 0; idx < amount; idx++) { | ||
value.push(RANDOM_CHARS[rnd[idx] % RANDOM_CHARS.length]); | ||
} | ||
return value.join(''); | ||
} | ||
|
||
/** | ||
* Generate temporary file name full path. | ||
* @param {string} dir - Directory | ||
* @return {string} - Temporary file name full path | ||
*/ | ||
function tmpfilePath(dir) { | ||
const name = [ | ||
'tmp-', | ||
process.pid, | ||
'-', | ||
randomChars(12), | ||
].join(''); | ||
return path.join(dir, name); | ||
} | ||
|
||
/** | ||
* Dir.tmpfile.touch. | ||
* @return {Object} - Dir.tmpfile.touch object | ||
*/ | ||
const dir$tmpfile$touch = function() { | ||
const obj = object('dir$tmpfile$touch') | ||
obj.assets[LAMBDA] = function(self) { | ||
const path = tmpfilePath( | ||
dataized(self.take(RHO).take(RHO).take('path'), STRING) | ||
) | ||
fs.appendFileSync( | ||
tmpfilePath(path), | ||
'' | ||
) | ||
return data.toObject(path) | ||
} | ||
return obj | ||
} | ||
|
||
module.exports = dir$tmpfile$touch |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const object = require('../../../../runtime/object') | ||
const {LAMBDA} = require('../../../../runtime/attribute/specials'); | ||
const at_void = require('../../../../runtime/attribute/at-void'); | ||
const ErFailure = require('../../../../runtime/error/ErFailure'); | ||
|
||
/** | ||
* Dir.walk. | ||
* @return {Object} - Dir.walk object | ||
* @todo #3:30min Implement dir$walk atom. We need to implement the atom and make sure it | ||
* works. For the details of implementation check the Java analogue on | ||
* https://github.com/objectionary/eo/tree/master/eo-runtime/src/main/java/EOorg/EOeolang | ||
*/ | ||
const dir$walk = function() { | ||
const obj = object('dir$walk') | ||
obj.attrs['glob'] = at_void('glob') | ||
obj.assets[LAMBDA] = function(_) { | ||
throw new ErFailure( | ||
`Atom dir$walk is not implemented yet` | ||
) | ||
} | ||
return obj | ||
} | ||
|
||
module.exports = dir$walk |
24 changes: 24 additions & 0 deletions
24
eo2js-runtime/src/objects/org/eolang/fs/file$deleted$delete.js
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const object = require('../../../../runtime/object') | ||
const {LAMBDA, RHO} = require('../../../../runtime/attribute/specials'); | ||
const {STRING} = require('../../../../runtime/types'); | ||
const fs = require('fs'); | ||
const dataized = require('../../../../runtime/dataized'); | ||
const data = require('../../../../runtime/data') | ||
|
||
/** | ||
* File.deleted.delete. | ||
* @return {Object} - File.deleted.delete object | ||
*/ | ||
const file$deleted$delete = function() { | ||
const obj = object('file$deleted$delete') | ||
obj.assets[LAMBDA] = function(self) { | ||
fs.rmSync( | ||
String(dataized(self.take(RHO).take(RHO).take('path'), STRING)), | ||
{recursive: true} | ||
) | ||
return data.toObject(true) | ||
} | ||
return obj | ||
} | ||
|
||
module.exports = file$deleted$delete |
Oops, something went wrong.
5ec35f4
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.
Puzzle
3-432203ad
disappeared fromeo2js-runtime/src/objects/org/eolang/io/stdin$next_line.js
), that's why I closed #57. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.5ec35f4
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.
Puzzle
3-81f48fea
disappeared fromeo2js-runtime/src/objects/org/eolang/io/stdin$φ.js
), that's why I closed #58. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.5ec35f4
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.
Puzzle
3-5a478edf
disappeared fromeo2js/test/it/runtime-tests.test.js
), that's why I closed #71. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.5ec35f4
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.
Puzzle
3-ff9a15e3
disappeared fromeo2js-runtime/src/runtime/bytes-of.js
), that's why I closed #73. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.5ec35f4
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.
Puzzle
3-d0b4ae5d
discovered ineo2js/test/it/runtime-tests.test.js
) and submitted as #109. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.5ec35f4
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.
Puzzle
3-5dd33586
discovered ineo2js-runtime/src/objects/org/eolang/fs/dir$walk.js
) and submitted as #110. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.5ec35f4
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.
Puzzle
3-fb434073
discovered ineo2js-runtime/src/objects/org/eolang/fs/file$open$file-stream$read$read-bytes.js
) and submitted as #111. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.5ec35f4
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.
Puzzle
3-2d5631ef
discovered ineo2js-runtime/src/objects/org/eolang/fs/file$open$file-stream$write$written-bytes.js
) and submitted as #112. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.5ec35f4
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.
Puzzle
3-19bd2881
discovered ineo2js-runtime/src/objects/org/eolang/fs/file$open$process-file.js
) and submitted as #113. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.5ec35f4
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.
Puzzle
3-6e5ab181
discovered ineo2js-runtime/src/objects/org/eolang/sys/posix$φ.js
) and submitted as #114. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.5ec35f4
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 wasn't able to retrieve PDD puzzles from the code base and submit them to github. If you think that it's a bug on our side, please submit it to yegor256/0pdd:
Please, copy and paste this stack trace to GitHub:
5ec35f4
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 wasn't able to retrieve PDD puzzles from the code base and submit them to github. If you think that it's a bug on our side, please submit it to yegor256/0pdd:
Please, copy and paste this stack trace to GitHub: