Food-Static-Data / sd

Food static data wrapper
GNU General Public License v3.0
9 stars 14 forks source link

convert image data to js object #135

Closed atherdon closed 5 years ago

atherdon commented 5 years ago

https://github.com/ChickenKyiv/awesome-food-measurements-information/blob/master/images/cooking-guide-apron-cu-cooking-times.jpg

@elnur004 you can grab it

atherdon commented 5 years ago

if you'll do it quickly and i will reply slow, you can also grab this image as well(each data should have separated file): https://github.com/ChickenKyiv/awesome-food-measurements-information/blob/master/images/c7cddf12c4969f80c77cd23d6d38243c.jpg

atherdon commented 5 years ago

Next stage will be to add tests for each new file

elnur004 commented 5 years ago

may you say how to do this, please?

atherdon commented 5 years ago

just similar to your previous task:

elnur004 commented 5 years ago

i want to know how to change import of data? how to trace files? is there any folder or JSON file? or just to trace import....from GroceriStar/sd/and file name?

elnur004 commented 5 years ago

hi, @atherdon what we need to do now? is there any task for me?

vadim9999 commented 5 years ago

@elnur004 I suppose you need to generate files. See how to generate it in https://github.com/GroceriStar/sd/issues/55#issuecomment-484837676 or in https://github.com/GroceriStar/sd#how-to-generate-additional-files

atherdon commented 5 years ago

@vadim I don't want to generate them :( please explain it to Elnur and follow him at this task

vadim9999 commented 5 years ago

@elnur004

i want to know how to change import of data? how to trace files? is there any folder or JSON file? or just to trace import....from GroceriStar/sd/and file name?

Have you copy paste data from another test files? If yes, then for example allergy.test.js has import

import allergies from '~/Allergy/allergies.json'

~ this symbol cut path(instead of this symbol babel add ./src/data), full path to file without this symbol will be

import allergies from './src/data/Allergy/allergies.json'

change this '~/Allergy/allergies.json' on your path that you have saved your file then change variable of import in example it allergies.

elnur004 commented 5 years ago

@vadim9999 for instance: i've done files like this way import dash from '~/GroceriStar/cd/dash.js' already. and so on other files... (they exist in test folder) if that way is correct let me know please, what to do then on?

vadim9999 commented 5 years ago

@atherdon it's task is done for elnur?

vadim9999 commented 5 years ago

if you'll do it quickly and i will reply slow, you can also grab this image as well(each data should have separated file): https://github.com/ChickenKyiv/awesome-food-measurements-information/blob/master/images/c7cddf12c4969f80c77cd23d6d38243c.jpg

@elnur004 Sorry for long reply I was very bussy. have you done this ?

elnur004 commented 5 years ago

hi, @vadim9999 no problem. yes, i've done this and they exist in task folder

atherdon commented 5 years ago

174 @elnur004 please show it to @vadim9999 he will supervise you, while i'm busy

vadim9999 commented 5 years ago

@elnur004 Can you give me a link of file where you converted data from image into object I can find it

vadim9999 commented 5 years ago

@atherdon tests doesn't work when using es6 import, working when using es5 require

elnur004 commented 5 years ago

@vadim9999 https://github.com/GroceriStar/sd/tree/master/src/data/__tests__ these are tests files

elnur004 commented 5 years ago

@elnur004 Can you give me a link of file where you converted data from image into object I can find it

@vadim9999 https://github.com/ChickenKyiv/awesome-food-measurements-information

elnur004 commented 5 years ago

@vadim9999 need we change these to es5?

vadim9999 commented 5 years ago

@vadim9999 need we change these to es5?

No, I have fix this please update your local repository

elnur004 commented 5 years ago

@vadim9999 No, I have fix this please update your local repository

sorry for question. but how to update local repository?

vadim9999 commented 5 years ago

@elnur004 All of objects that you have added in root directory cooking-times.js, cup1-2.js .. etc. Now doesn't work because it's haven't exported. and tests because it's import is incorrect. I For example I will take dash.js and dash.test.js To fix this you need

  1. export object dash. to do this you need in dash.js in the end of file add
    export default dash;
  2. import this object in dash.test.js. Now dash.test.js has this frong path
    import dash from '~/GroceriStar/cd/dash.js'

    It's doesn't work because this path doesn't exist. You need make this

    import dash from '../../../dash'

    ../ this means that like "exit" from current folder for example you have this directory main |_ subfolder |_files.js |_manyfiles.js to open file manyfiles.js in folder main you will need use '../manyfyles' in files.js that is subfolder of main Make this changes for other files that you have added

vadim9999 commented 5 years ago

@vadim9999 No, I have fix this please update your local repository

sorry for question. but how to update local repository?

you just need in your project use

git pull https://github.com/GroceriStar/sd.git
elnur004 commented 5 years ago

@vadim9999

i stuck in cooking-times.js/cooking-times here. how i have to trace here? must i import cooking-times from in cooking-times.js file? for example: import cooking-times from '../cd/cooking-times.js' is this a correct tracking?

elnur004 commented 5 years ago

i want to understand from where we import the test

vadim9999 commented 5 years ago

@elnur004 we have tests in sd/src/data/tests sd is a folder project object cooking-times.js is in sd, also other objects is in this folder in cooking-times.js you have exported object that we can get access to it from other files

elnur004 commented 5 years ago

then, i have to trace import cooking-times from '../src/data/tests/cooking-times.js' right?

vadim9999 commented 5 years ago

@elnur004 but why you need to import tests? you need in file tests import object

vadim9999 commented 5 years ago

@elnur004 if you will write in dash.test.js import dash from '../../../dash'

this will work another variant doesn't work. in cooking-times.js import like below and change instead of dash cooking-times.js in result you import will be

import cooking-times from '../../../cooking-times'
elnur004 commented 5 years ago

i want to fill up that dots)) before the /cooking-times i don't know to show cooking-times.js or not

elnur004 commented 5 years ago

i have stuck in there

vadim9999 commented 5 years ago

just insert import

import cooking-times from '../../../cooking-times'

it will work

elnur004 commented 5 years ago

import cooking-times from '../src/data/tests/cooking-times'

like this?

vadim9999 commented 5 years ago

no in cooking-times.test.js insert

import cooking-times from '../../../cooking-times'
vadim9999 commented 5 years ago

don't fiil up dots

elnur004 commented 5 years ago

@vadim9999 may you explain please, why those dots wouldn't be filled up? it has been obscure for me

vadim9999 commented 5 years ago

ok, for example now you are in folder tests you need to get access to file that located in folder up to get access you should use ../ . if need to get access upper folder in result it will be ../../

vadim9999 commented 5 years ago

./ it get access to files that located in current folder but if you want to get file that located out of current folder using ../

vadim9999 commented 5 years ago

now you are in sd/src/data/tests using ./ you can get files related in folder tests. to get files related in data folder use ../ and if you want use files that located in folder srs use ../../ then if you want to get files from project folder ../../../

elnur004 commented 5 years ago

thanx, a lot @vadim9999 , it was very helpful for me

vadim9999 commented 5 years ago

@elnur004 Sorry I thouhgt in file cooking-times.js is one object. change export default cooking-time on this structure

export {
frenchBeans,
sprouts,
//..and so on add all object in this curl brackets that are in this files  
}

and change import in cooking-times.test.js instead of

import { frenchBeans, sprouts}  from '../../../cooking-times'
elnur004 commented 5 years ago

ok

elnur004 commented 5 years ago

need there to write default after export?

vadim9999 commented 5 years ago

no

elnur004 commented 5 years ago

why? what is the difference between previous and this?

vadim9999 commented 5 years ago

export default when you export one object and export { .. } some objects

elnur004 commented 5 years ago

i've caught it up but i want to grasp what is the meaning of default in here?

elnur004 commented 5 years ago

sorry i'm giving you trouble

vadim9999 commented 5 years ago

more information you can read in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export

vadim9999 commented 5 years ago

add more tests in block describe https://github.com/GroceriStar/sd/blob/master/src/data/__tests__/cooking_times.test.js