Skip to content

Commit

Permalink
Update June 30, 2023
Browse files Browse the repository at this point in the history
New version 1.4.0
- Lazarus support
- New methods to use the variable or a default value set on the method parameter
  • Loading branch information
rafael-figueiredo-alves committed Jul 1, 2023
1 parent 6eb2988 commit 953165e
Show file tree
Hide file tree
Showing 35 changed files with 2,150 additions and 13 deletions.
26 changes: 26 additions & 0 deletions Demo/Delphi - Horse/Servidor.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
program Servidor;

{$APPTYPE CONSOLE}

{$R *.res}

uses
System.SysUtils,
Horse,
DotEnv4Delphi;

begin
THorse.Get('/ping',
procedure(Req: THorseRequest; Res: THorseResponse)
begin
Res.Send('pong');
end);

{
No JavaScript, usando o ExpressJS, teriamos uma linha como:
app.listen(process.env.PORT || 3000);
A Linha abaixo tem a mesma funcionalidade, sendo que
DotEnv.PortorDefault(3000) é igual a process.env.PORT || 3000
}
THorse.Listen(DotEnv.PortOrDefault(3000));
end.
1,019 changes: 1,019 additions & 0 deletions Demo/Delphi - Horse/Servidor.dproj

Large diffs are not rendered by default.

Binary file added Demo/Delphi - Horse/Servidor.res
Binary file not shown.
22 changes: 22 additions & 0 deletions Demo/Delphi - Horse/boss-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"hash": "d41d8cd98f00b204e9800998ecf8427e",
"updated": "2023-06-30T22:00:57.8470623-03:00",
"installedModules": {
"github.com/hashload/horse": {
"name": "horse",
"version": "3.1.3",
"hash": "752c3b943782e4910cd0a3ac3beeb4ee",
"artifacts": {},
"failed": false,
"changed": false
},
"https://github.com/rafael-figueiredo-alves/dotenv4delphi": {
"name": "dotenv4delphi",
"version": "v1.4.0",
"hash": "55f3cbe2cbe03e20b930cd2249afef8b",
"artifacts": {},
"failed": false,
"changed": false
}
}
}
12 changes: 12 additions & 0 deletions Demo/Delphi - Horse/boss.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Servidor",
"description": "",
"version": "1.0.0",
"homepage": "",
"mainsrc": "./src",
"projects": [],
"dependencies": {
"github.com/hashload/horse": "^3.1.3",
"https://github.com/rafael-figueiredo-alves/dotenv4delphi": "^v1.4.0"
}
}
3 changes: 1 addition & 2 deletions Demo/Demo.dpr → Demo/Delphi/Demo.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ program Demo;

uses
Vcl.Forms,
uDemo in 'uDemo.pas' {Form2},
DotEnv4Delphi in '..\src\DotEnv4Delphi.pas';
uDemo in 'uDemo.pas' {Form2};

{$R *.res}

Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo.dproj → Demo/Delphi/Demo.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44>
<UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150>
<SanitizedProjectName>Demo</SanitizedProjectName>
<DCC_UnitSearchPath>modules\.dcp;modules\.dcu;modules;modules\dotenv4delphi\src;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_UsePackage>DBXSqliteDriver;IndyIPCommon;RESTComponents;bindcompdbx;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;bindcompvclsmp;tethering;svnui;bindcompvclwinx;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;TeeDB;FireDAC;vcltouch;vcldb;bindcompfmx;svn;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;inetdb;FMXTee;soaprtl;DbxCommonDriver;FmxTeeUI;ibxpress;fmx;FireDACIBDriver;fmxdae;xmlrtl;soapmidas;vcledge;fmxobj;vclwinx;ibxbindings;rtl;vclib;DbxClientDriver;Tee;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;FireDACCommon;IndyIPClient;Skia.Package.RTL;bindcompvcl;RESTBackendComponents;TeeUI;VCLRESTComponents;Skia.Package.VCL;soapserver;dbxcds;VclSmp;adortl;Skia.Package.FMX;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;IndyProtocols;inetdbxpress;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage)</DCC_UsePackage>
Expand Down Expand Up @@ -102,7 +103,6 @@
<Form>Form2</Form>
<FormType>dfm</FormType>
</DCCReference>
<DCCReference Include="..\src\DotEnv4Delphi.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions Demo/Delphi/boss-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"hash": "d41d8cd98f00b204e9800998ecf8427e",
"updated": "2023-06-29T21:25:00.4514542-03:00",
"installedModules": {
"https://github.com/rafael-figueiredo-alves/dotenv4delphi": {
"name": "dotenv4delphi",
"version": "v1.4.0",
"hash": "55f3cbe2cbe03e20b930cd2249afef8b",
"artifacts": {},
"failed": false,
"changed": false
}
}
}
11 changes: 11 additions & 0 deletions Demo/Delphi/boss.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Demo - DotEnv4Delphi - Delphi",
"description": "Demo",
"version": "1.0.0",
"homepage": "",
"mainsrc": "./src",
"projects": [],
"dependencies": {
"https://github.com/rafael-figueiredo-alves/dotenv4delphi": "^v1.4.0"
}
}
File renamed without changes.
3 changes: 3 additions & 0 deletions Demo/uDemo.pas → Demo/Delphi/uDemo.pas
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ procedure TForm2.Button4Click(Sender: TObject);
begin
//Exemplo de nova forma de obter alguns tipos de variáveis diretamente, sem precisar do comando env
Memo1.Lines.Add('Porta: ' + DotEnv.Port.ToString);

//Comando similar ao anterior, mas com possibilidade de passar um valor padrão caso não seja encontrada a variável
Memo1.Lines.Add('Porta (com valor padrão): ' + DotEnv.PortOrDefault(50).ToString);
end;

procedure TForm2.FormCreate(Sender: TObject);
Expand Down
10 changes: 10 additions & 0 deletions Demo/Lazarus/.env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Comentário

MeuNome=Rafael Alves
DB_USERNAME=${MeuNome}\Developer # teste
Nome3=${MeuNome} - ${DB_USERNAME} - ${APPDATA} OK # teste poderoso
Development=True
Port=3001
BASE_URL=C:\Delphi
API_TOKEN=12346-aaas-djkmdsnf-111234
ConnectionString=database:Delphi
82 changes: 82 additions & 0 deletions Demo/Lazarus/backup/demo.lpi
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<Title Value="demo"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<BuildModes>
<Item Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
</RunParams>
<RequiredPackages>
<Item>
<PackageName Value="LCL"/>
</Item>
</RequiredPackages>
<Units>
<Unit>
<Filename Value="demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="unitmain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="FormMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="unitMain"/>
</Unit>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="modules\.dcp;modules\.dcu;modules;modules\dotenv4delphi\src"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions>
<Item>
<Name Value="EAbort"/>
</Item>
<Item>
<Name Value="ECodetoolError"/>
</Item>
<Item>
<Name Value="EFOpenError"/>
</Item>
</Exceptions>
</Debugging>
</CONFIG>
163 changes: 163 additions & 0 deletions Demo/Lazarus/backup/demo.lps
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectSession>
<PathDelim Value="\"/>
<Version Value="12"/>
<BuildModes Active="Default"/>
<Units>
<Unit>
<Filename Value="demo.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="-1"/>
<TopLine Value="-1"/>
<CursorPos X="-1" Y="-1"/>
<UsageCount Value="22"/>
</Unit>
<Unit>
<Filename Value="unitmain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="FormMain"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="unitMain"/>
<IsVisibleTab Value="True"/>
<TopLine Value="63"/>
<CursorPos X="28" Y="75"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit>
<Unit>
<Filename Value="modules\dotenv4delphi\src\DotEnv4Delphi.pas"/>
<EditorIndex Value="1"/>
<TopLine Value="465"/>
<CursorPos X="14" Y="66"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit>
</Units>
<JumpHistory HistoryIndex="28">
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="25" Column="20" TopLine="5"/>
</Position>
<Position>
<Filename Value="modules\dotenv4delphi\src\DotEnv4Delphi.pas"/>
<Caret Line="7" Column="26"/>
</Position>
<Position>
<Filename Value="modules\dotenv4delphi\src\DotEnv4Delphi.pas"/>
<Caret Line="71" Column="33" TopLine="59"/>
</Position>
<Position>
<Filename Value="modules\dotenv4delphi\src\DotEnv4Delphi.pas"/>
<Caret Line="5" Column="9"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="25" Column="20" TopLine="5"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="29" Column="20" TopLine="6"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="30" Column="20" TopLine="7"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="39" Column="5" TopLine="16"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="38" Column="43" TopLine="16"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="39" Column="43" TopLine="17"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="43" Column="73" TopLine="28"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="44" Column="73" TopLine="29"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="43" Column="73" TopLine="28"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="44" Column="73" TopLine="29"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="45" Column="73" TopLine="30"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="44" Column="73" TopLine="29"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="45" Column="73" TopLine="30"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="44" Column="73" TopLine="29"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="43" Column="73" TopLine="28"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="45" Column="73" TopLine="24"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="61" Column="54" TopLine="41"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="62" Column="54" TopLine="42"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="63" Column="54" TopLine="43"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="57" TopLine="47"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="72" Column="3" TopLine="58"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="88" Column="47"/>
</Position>
<Position>
<Filename Value="unitmain.pas"/>
<Caret Line="87" Column="61" TopLine="66"/>
</Position>
<Position>
<Filename Value="modules\dotenv4delphi\src\DotEnv4Delphi.pas"/>
<Caret Line="66" Column="14" TopLine="102"/>
</Position>
<Position>
<Filename Value="modules\dotenv4delphi\src\DotEnv4Delphi.pas"/>
<Caret Line="61" Column="14" TopLine="106"/>
</Position>
</JumpHistory>
<RunParams>
<FormatVersion Value="2"/>
<Modes ActiveMode=""/>
</RunParams>
</ProjectSession>
</CONFIG>
Loading

0 comments on commit 953165e

Please sign in to comment.