-
Notifications
You must be signed in to change notification settings - Fork 93
Работа с конфигом в формате JSON #95
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
Conversation
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.
Отлично дополнение, JSON давно просился! Спасибо.
У меня есть некоторые замечания.
src/json-config.os
Outdated
КонецФункции | ||
|
||
|
||
Функция ВырезатьКомментарииИзТекстаJSON(Знач JsonСтрока) |
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.
Давайте вставим вырезку комментариев из JSON сразу в пакет JSON.
Сейчас вырезание дублируется в нескольких пакетах, например, здесь и в ванесса-раннер.
Кажется, еще где-то я юзал вырезание комментов
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.
Не против...
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.
Я скорей отрицательно отношусь к комментам, чем положительно в json
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.
Комментарии нужны... без них тяжко
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.
@artbear очень смешно.... oscript-library/json#4
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.
@Stepa86 done
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.
Вечером выпущу релиз json и можно будет поправить данный PR
src/json-config.os
Outdated
|
||
Для Каждого КлючИЗначение Из ЭлементМассива Цикл | ||
|
||
Если КлючИЗначение.Ключ = "name" Тогда |
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.
Предлагаю длиннющий список Если КлючИЗначение.Ключ = ??? Тогда
1 занести в спец.соответствие
2 и получать ключ через Ключ = СоответствиеКлючей[ИсходныйКлюч];
Долой множественный switch
Код будет намного проще.
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.
Сделал
src/json-config.os
Outdated
|
||
КонецПроцедуры | ||
|
||
Функция НекорректнаяСтруктураНастроек() |
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.
Предлагаю изменить имя на СтрокаНекорректнаяСтруктураНастроек
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.
Переименовал
src/multi-controller.os
Outdated
|
||
Процедура ПрочитатьНастройкиИзФайлаJSON(Знач ФайлНастроек) | ||
|
||
Конфиг = ЗагрузитьСценарий(ОбъединитьПути(ТекущийСценарий().Каталог, "json-config.os")); |
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.
Зачем пользоваться таким способом здесь и в тестах ?
Предлагаю явно добавить классы ЧтениеКонфигаXML_Гитсинк
и ЧтениеКонфигаJSON_Гитсинк
и юзать их в коде и в тестах
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.
Сделал классы
src/json-config.os
Outdated
|
||
Для Каждого КлючИЗначение Из ГлобальныеНастройки Цикл | ||
|
||
Если КлючИЗначение.Ключ = "email-domain" Тогда |
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.
Здесь также можно добавить спец.соответствие ключей и расшифровок
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.
Сделал
src/json-config.os
Outdated
|
||
КонецФункции // ВырезатьКомментарииИзТекстаJSON() | ||
|
||
Процедура ПрочитатьНастройкиРепозитория(ЭлементМассива) |
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.
Совершенно непонятно, что же скрывается в параметре ЭлементМассива
метода :(
Предлагаю переименовать.
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.
Переименовал
src/json-config.os
Outdated
КонецЕсли; | ||
|
||
Если ПустаяСтрока(КлючИЗначение.Значение) и мНастройки.Свойство(Ключ) Тогда | ||
КлючИЗначение.Значение = мНастройки[Ключ]; |
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.
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.
Предлагаю использовать промежуточную переменную вместо присвоения в КлючИЗначение.Значение
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.
Тем более, что здесь идет неявная работа - фактически этот код меняет содержание переданного параметра из ЭлементаМассива :(
это совсем нехорошо.
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.
Убрал
Утверждения.ПроверитьРавенство("каталог2", мНастройки.Репозитарии[1].КаталогХранилища1С); | ||
Утверждения.ПроверитьРавенство(мНастройки.ПутьGit, мНастройки.Репозитарии[1].ПутьGit); | ||
Утверждения.ПроверитьРавенство(мНастройки.ПутьКПлатформе83, мНастройки.Репозитарии[1].ПутьКПлатформе83); | ||
Утверждения.ПроверитьРавенство("server.com", мНастройки.Репозитарии[1].ДоменПочтыДляGit); |
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.
Вот здесь лучше явно указать
Утверждения.ПроверитьРавенство(мНастройки.ДоменПочтыДляGit, мНастройки.Репозитарии[1].ДоменПочтыДляGit);
как в строках выше
вместо использования "server.com"
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.
Это не надо править т.к. проверка корректная. Проверяется локальная настройка для репо.
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.
У тебя что глобальная, что локальная настройка совпадают :(
Я про это и писал.
Если ты хочешь проверить именно локальную настройку, тогда нужно в конфиг.json установить локальную настройку, например, localhost
вместо server.com
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.
И проверить именно локальную настройку, а не глобальную.
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.
Здесь будешь менять?
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.
Предлагаю добавить в настройку репозитория отдельную настройку для почты и убедиться, что локальная настройка переписывает глобальную
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.
Вообще проверки не мои (изначально) но подумаю, хотя на мой взгляд.. можно и так оставить
А вообще я лично планировал использовать пакет |
Вообще тут немного для другого используется... Хотя можно было прикрутить.. Но да ладно.... |
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.
Предлагаю упростить код, а не переусложнять его
tests/multi-controller-xml.os
Outdated
@@ -36,7 +38,17 @@ | |||
|
|||
Функция ПрочитатьТестовыеНастройки() | |||
ФайлНастроек = КаталогFixtures() + "/config.xml"; | |||
ЧтениеКонфига = Новый ЧтениеКонфига(); | |||
ЧтениеКонфига = Новый ЧтениеКонфигаXMLПакетнойСинхронизации(); |
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.
У кода
ЧтениеКонфига = Новый ЧтениеКонфигаXMLПакетнойСинхронизации();
ЧтениеКонфига.СоответствиеКлючамИПараметра = Контроллер.СоответствиеКлючамИПараметра();
куча проблем:
- введение лишней публичной переменной, которая не особо и нужна
- нарушение инкапсуляции класса и т.п.
Предлагаю сделать проще на базе конструктора ПриСозданииОбъекта(Соответствие)
ЧтениеКонфига = Новый ЧтениеКонфигаXMLПакетнойСинхронизации(Контроллер.СоответствиеКлючамИПараметра());
и такое же исправление для ЧтениеКонфигаJSONПакетнойСинхронизации
Процедура ПрочитатьНастройкиИзФайлаXML(Знач ФайлНастроек) | ||
|
||
Конфиг = Новый ЧтениеКонфигаXMLПакетнойСинхронизации; | ||
Конфиг.СоответствиеКлючамИПараметра = СоответствиеКлючамИПараметра(); |
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.
И здесь код упростится
Процедура ПрочитатьНастройкиИзФайлаJSON(Знач ФайлНастроек) | ||
|
||
Конфиг = Новый ЧтениеКонфигаJSONПакетнойСинхронизации; | ||
Конфиг.СоответствиеКлючамИПараметра = СоответствиеКлючамИПараметра(); |
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.
И здесь код упростится
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.
@khorevaa Я выпустил релиз 1.0.0 пакета json с пропуском комментариев
- Исправь в PR, плиз, зависимость гитсинка от версии 1.0.0 json
- убери код по вырезке комментариев
Все сделал, сэр.!! @artbear |
Если переходите на конструкторы классов, надо и версию движка повысить. Они появились только в 1.0.17 |
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.
Остались совсем мелкие замечания
СоответствиеКлючамИПараметра.Вставить("auto-set-tags", "АвтоматическаяУстановкаТэговПоВерсиям"); | ||
СоответствиеКлючамИПараметра.Вставить("process-fatform-modules", "ПереименовыватьФайлМодуляОбычнойФормы"); | ||
|
||
Возврат СоответствиеКлючамИПараметра; |
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.
Лучше возврать ФиксированноеСоответствие, так будет гарантия, что никто случайно не поменяет коллекцию
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.
Да поменяю..
Утверждения.ПроверитьРавенство("каталог2", мНастройки.Репозитарии[1].КаталогХранилища1С); | ||
Утверждения.ПроверитьРавенство(мНастройки.ПутьGit, мНастройки.Репозитарии[1].ПутьGit); | ||
Утверждения.ПроверитьРавенство(мНастройки.ПутьКПлатформе83, мНастройки.Репозитарии[1].ПутьКПлатформе83); | ||
Утверждения.ПроверитьРавенство("server.com", мНастройки.Репозитарии[1].ДоменПочтыДляGit); |
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.
Здесь будешь менять?
Не прошли 2 теста http://build.oscript.io/job/oscript-library/job/gitsync/job/PR-95/7/console
|
ошибка в пакете json. У меня локально все проходит |
@khorevaa LF вроде бы в какой-то из версий 1.0.17 чинили. У тебя последний stable семнашки? |
@nixel2007 у меня ночник.. - месячной давности |
@artbear Проверку теста решил не править. Остальных замечаний вроде нет. |
@artbear - Хочется дальше двигаться.. Что с этип PR? |
@artbear Так у меня все хорошо падает на тест сервер у Вас когда ПР проходит тестирование. |
Точно, там 17 версия. А обновлять нельзя, т.к в новых версиях есть проблема движка при прогоне фич через 1bdd :( /cc @dmpas @EvilBeaver |
выпустил новую версию json для работы на нашем CI |
Устал, формировать ручками xml и добавил как альтернативу работу с JSON
@artbear