makit 0.0.35 → 0.0.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/makit/apache.rb +32 -32
- data/lib/makit/cli/clean.rb +14 -14
- data/lib/makit/cli/clone.rb +59 -59
- data/lib/makit/cli/init.rb +38 -38
- data/lib/makit/cli/main.rb +33 -33
- data/lib/makit/cli/make.rb +54 -54
- data/lib/makit/cli/new.rb +37 -37
- data/lib/makit/cli/nuget_cache.rb +38 -38
- data/lib/makit/cli/pull.rb +31 -31
- data/lib/makit/cli/setup.rb +71 -71
- data/lib/makit/cli/work.rb +21 -21
- data/lib/makit/command_runner.rb +391 -353
- data/lib/makit/commands.rb +21 -21
- data/lib/makit/content/default_gitignore.rb +5 -5
- data/lib/makit/content/default_gitignore.txt +222 -222
- data/lib/makit/content/default_rakefile.rb +11 -11
- data/lib/makit/content/gem_rakefile.rb +14 -14
- data/lib/makit/data.rb +50 -50
- data/lib/makit/directories.rb +140 -140
- data/lib/makit/directory.rb +184 -184
- data/lib/makit/dotnet.rb +156 -156
- data/lib/makit/environment.rb +127 -127
- data/lib/makit/fileinfo.rb +16 -16
- data/lib/makit/files.rb +47 -47
- data/lib/makit/git.rb +86 -86
- data/lib/makit/gitlab_runner.rb +60 -60
- data/lib/makit/humanize.rb +112 -112
- data/lib/makit/indexer.rb +56 -0
- data/lib/makit/logging.rb +96 -96
- data/lib/makit/markdown.rb +75 -75
- data/lib/makit/mp/basic_object_mp.rb +16 -16
- data/lib/makit/mp/command_request.mp.rb +16 -16
- data/lib/makit/mp/project_mp.rb +210 -210
- data/lib/makit/mp/string_mp.rb +122 -122
- data/lib/makit/nuget.rb +57 -57
- data/lib/makit/protoc.rb +104 -104
- data/lib/makit/serializer.rb +115 -115
- data/lib/makit/show.rb +76 -77
- data/lib/makit/storage.rb +131 -131
- data/lib/makit/symbols.rb +149 -149
- data/lib/makit/tasks.rb +60 -60
- data/lib/makit/tree.rb +37 -37
- data/lib/makit/v1/makit.v1_pb.rb +33 -33
- data/lib/makit/v1/makit.v1_services_pb.rb +25 -25
- data/lib/makit/version.rb +12 -12
- data/lib/makit/wix.rb +95 -95
- data/lib/makit/zip.rb +17 -17
- data/lib/makit.rb +267 -267
- metadata +4 -5
- data/lib/generated/makit/v1/makit.v1_pb.rb +0 -34
- data/lib/generated/makit/v1/web/link_pb.rb +0 -20
data/lib/makit/commands.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "English"
|
4
|
-
require "open3"
|
5
|
-
require "socket"
|
6
|
-
require "etc"
|
7
|
-
require "logger"
|
8
|
-
|
9
|
-
# This module provides classes for the Makit gem.
|
10
|
-
module Makit
|
11
|
-
# This class provide methods running commands.
|
12
|
-
#
|
13
|
-
class Commands < Array
|
14
|
-
|
15
|
-
# Generate the commands based on the current directory.
|
16
|
-
def auto_generate
|
17
|
-
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: ["install"]) if File.exist?("Gemfile")
|
18
|
-
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: ["exec", "rake"]) if File.exist?("Rakefile")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "English"
|
4
|
+
require "open3"
|
5
|
+
require "socket"
|
6
|
+
require "etc"
|
7
|
+
require "logger"
|
8
|
+
|
9
|
+
# This module provides classes for the Makit gem.
|
10
|
+
module Makit
|
11
|
+
# This class provide methods running commands.
|
12
|
+
#
|
13
|
+
class Commands < Array
|
14
|
+
|
15
|
+
# Generate the commands based on the current directory.
|
16
|
+
def auto_generate
|
17
|
+
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: ["install"]) if File.exist?("Gemfile")
|
18
|
+
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: ["exec", "rake"]) if File.exist?("Rakefile")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module Makit
|
2
|
-
module Content
|
3
|
-
GITIGNORE = File.read(File.join(__dir__, "default_gitignore.txt"))
|
4
|
-
end # module Content
|
5
|
-
end # module Makit
|
1
|
+
module Makit
|
2
|
+
module Content
|
3
|
+
GITIGNORE = File.read(File.join(__dir__, "default_gitignore.txt"))
|
4
|
+
end # module Content
|
5
|
+
end # module Makit
|
@@ -1,222 +1,222 @@
|
|
1
|
-
# General
|
2
|
-
[Aa]rtifacts/
|
3
|
-
[Ii]ntermediate/
|
4
|
-
[Gg]enerated/
|
5
|
-
third_party/
|
6
|
-
|
7
|
-
# Ruby
|
8
|
-
*.gem
|
9
|
-
*.rbc
|
10
|
-
/.config
|
11
|
-
/coverage/
|
12
|
-
/InstalledFiles
|
13
|
-
/pkg/
|
14
|
-
/spec/reports/
|
15
|
-
/spec/examples.txt
|
16
|
-
/test/tmp/
|
17
|
-
/test/version_tmp/
|
18
|
-
/tmp/
|
19
|
-
/.yardoc/
|
20
|
-
/_yardoc/
|
21
|
-
/doc/
|
22
|
-
/rdoc/
|
23
|
-
/.bundle/
|
24
|
-
/vendor/bundle
|
25
|
-
/lib/bundler/man/
|
26
|
-
.rvmrc
|
27
|
-
|
28
|
-
# Rust
|
29
|
-
/target/
|
30
|
-
Cargo.lock
|
31
|
-
**/*.rs.bk
|
32
|
-
/target
|
33
|
-
/Cargo.lock
|
34
|
-
|
35
|
-
# DotNet
|
36
|
-
*.rsuser
|
37
|
-
*.suo
|
38
|
-
*.user
|
39
|
-
*.userosscache
|
40
|
-
*.sln.docstates
|
41
|
-
*.txt
|
42
|
-
*.userprefs
|
43
|
-
BenchmarkDotNet.Artifacts/
|
44
|
-
[Dd]ebug/
|
45
|
-
[Dd]ebugPublic/
|
46
|
-
[Rr]elease/
|
47
|
-
[Rr]eleases/
|
48
|
-
x64/
|
49
|
-
x86/
|
50
|
-
[Aa][Rr][Mm]/
|
51
|
-
[Aa][Rr][Mm]64/
|
52
|
-
bld/
|
53
|
-
[Bb]in/
|
54
|
-
[Oo]bj/
|
55
|
-
[Ll]og/
|
56
|
-
[Aa]rtifacts/
|
57
|
-
.vs/
|
58
|
-
Generated\ Files/
|
59
|
-
[Tt]est[Rr]esult*/
|
60
|
-
[Bb]uild[Ll]og.*
|
61
|
-
*.VisualState.xml
|
62
|
-
TestResult.xml
|
63
|
-
[Dd]ebugPS/
|
64
|
-
[Rr]eleasePS/
|
65
|
-
dlldata.c
|
66
|
-
BenchmarkDotNet.Artifacts/
|
67
|
-
|
68
|
-
project.lock.json
|
69
|
-
project.fragment.lock.json
|
70
|
-
artifacts/
|
71
|
-
StyleCopReport.xml
|
72
|
-
*_i.c
|
73
|
-
*_p.c
|
74
|
-
*_h.h
|
75
|
-
*.ilk
|
76
|
-
*.meta
|
77
|
-
*.obj
|
78
|
-
*.iobj
|
79
|
-
*.pch
|
80
|
-
*.pdb
|
81
|
-
*.ipdb
|
82
|
-
*.pgc
|
83
|
-
*.pgd
|
84
|
-
*.rsp
|
85
|
-
*.sbr
|
86
|
-
*.tlb
|
87
|
-
*.tli
|
88
|
-
*.tlh
|
89
|
-
*.tmp
|
90
|
-
*.tmp_proj
|
91
|
-
*_wpftmp.csproj
|
92
|
-
*.log
|
93
|
-
*.vspscc
|
94
|
-
*.vssscc
|
95
|
-
.builds
|
96
|
-
*.pidb
|
97
|
-
*.svclog
|
98
|
-
*.scc
|
99
|
-
_Chutzpah*
|
100
|
-
ipch/
|
101
|
-
*.aps
|
102
|
-
*.ncb
|
103
|
-
*.opendb
|
104
|
-
*.opensdf
|
105
|
-
*.sdf
|
106
|
-
*.cachefile
|
107
|
-
*.VC.db
|
108
|
-
*.VC.VC.opendb
|
109
|
-
*.psess
|
110
|
-
*.vsp
|
111
|
-
*.vspx
|
112
|
-
*.sap
|
113
|
-
*.e2e
|
114
|
-
$tf/
|
115
|
-
*.gpState
|
116
|
-
_ReSharper*/
|
117
|
-
*.[Rr]e[Ss]harper
|
118
|
-
*.DotSettings.user
|
119
|
-
.JustCode
|
120
|
-
_TeamCity*
|
121
|
-
*.dotCover
|
122
|
-
.axoCover/*
|
123
|
-
!.axoCover/settings.json
|
124
|
-
*.coverage
|
125
|
-
*.coveragexml
|
126
|
-
_NCrunch_*
|
127
|
-
.*crunch*.local.xml
|
128
|
-
nCrunchTemp_*
|
129
|
-
*.mm.*
|
130
|
-
AutoTest.Net/
|
131
|
-
.sass-cache/
|
132
|
-
[Ee]xpress/
|
133
|
-
DocProject/buildhelp/
|
134
|
-
DocProject/Help/*.HxT
|
135
|
-
DocProject/Help/*.HxC
|
136
|
-
DocProject/Help/*.hhc
|
137
|
-
DocProject/Help/*.hhk
|
138
|
-
DocProject/Help/*.hhp
|
139
|
-
DocProject/Help/Html2
|
140
|
-
DocProject/Help/html
|
141
|
-
publish/
|
142
|
-
*.[Pp]ublish.xml
|
143
|
-
*.azurePubxml
|
144
|
-
*.pubxml
|
145
|
-
*.publishproj
|
146
|
-
PublishScripts/
|
147
|
-
*.nupkg
|
148
|
-
**/[Pp]ackages/*
|
149
|
-
!**/[Pp]ackages/build/
|
150
|
-
*.nuget.props
|
151
|
-
*.nuget.targets
|
152
|
-
csx/
|
153
|
-
*.build.csdef
|
154
|
-
ecf/
|
155
|
-
rcf/
|
156
|
-
AppPackages/
|
157
|
-
BundleArtifacts/
|
158
|
-
Package.StoreAssociation.xml
|
159
|
-
_pkginfo.txt
|
160
|
-
*.appx
|
161
|
-
*.[Cc]ache
|
162
|
-
# but keep track of directories ending in .cache
|
163
|
-
!*.[Cc]ache/
|
164
|
-
ClientBin/
|
165
|
-
~$*
|
166
|
-
*~
|
167
|
-
*.dbmdl
|
168
|
-
*.dbproj.schemaview
|
169
|
-
*.jfm
|
170
|
-
*.pfx
|
171
|
-
*.publishsettings
|
172
|
-
orleans.codegen.cs
|
173
|
-
**/wwwroot/lib/
|
174
|
-
Generated_Code/
|
175
|
-
_UpgradeReport_Files/
|
176
|
-
Backup*/
|
177
|
-
UpgradeLog*.XML
|
178
|
-
UpgradeLog*.htm
|
179
|
-
ServiceFabricBackup/
|
180
|
-
*.rptproj.bak
|
181
|
-
*.mdf
|
182
|
-
*.ldf
|
183
|
-
*.ndf
|
184
|
-
*.rdl.data
|
185
|
-
*.bim.layout
|
186
|
-
*.bim_*.settings
|
187
|
-
*.rptproj.rsuser
|
188
|
-
FakesAssemblies/
|
189
|
-
*.GhostDoc.xml
|
190
|
-
.ntvs_analysis.dat
|
191
|
-
node_modules/
|
192
|
-
*.plg
|
193
|
-
*.opt
|
194
|
-
*.vbw
|
195
|
-
**/*.HTMLClient/GeneratedArtifacts
|
196
|
-
**/*.DesktopClient/GeneratedArtifacts
|
197
|
-
**/*.DesktopClient/ModelManifest.xml
|
198
|
-
**/*.Server/GeneratedArtifacts
|
199
|
-
**/*.Server/ModelManifest.xml
|
200
|
-
_Pvt_Extensions
|
201
|
-
.paket/paket.exe
|
202
|
-
paket-files/
|
203
|
-
.fake/
|
204
|
-
.idea/
|
205
|
-
*.sln.iml
|
206
|
-
.cr/personal
|
207
|
-
__pycache__/
|
208
|
-
*.pyc
|
209
|
-
tools/**
|
210
|
-
!tools/packages.config
|
211
|
-
*.tss
|
212
|
-
*.jmconfig
|
213
|
-
*.btp.cs
|
214
|
-
*.btm.cs
|
215
|
-
*.odx.cs
|
216
|
-
*.xsd.cs
|
217
|
-
OpenCover/
|
218
|
-
ASALocalRun/
|
219
|
-
*.binlog
|
220
|
-
*.nvuser
|
221
|
-
.mfractor/
|
222
|
-
.localhistory/
|
1
|
+
# General
|
2
|
+
[Aa]rtifacts/
|
3
|
+
[Ii]ntermediate/
|
4
|
+
[Gg]enerated/
|
5
|
+
third_party/
|
6
|
+
|
7
|
+
# Ruby
|
8
|
+
*.gem
|
9
|
+
*.rbc
|
10
|
+
/.config
|
11
|
+
/coverage/
|
12
|
+
/InstalledFiles
|
13
|
+
/pkg/
|
14
|
+
/spec/reports/
|
15
|
+
/spec/examples.txt
|
16
|
+
/test/tmp/
|
17
|
+
/test/version_tmp/
|
18
|
+
/tmp/
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
/.bundle/
|
24
|
+
/vendor/bundle
|
25
|
+
/lib/bundler/man/
|
26
|
+
.rvmrc
|
27
|
+
|
28
|
+
# Rust
|
29
|
+
/target/
|
30
|
+
Cargo.lock
|
31
|
+
**/*.rs.bk
|
32
|
+
/target
|
33
|
+
/Cargo.lock
|
34
|
+
|
35
|
+
# DotNet
|
36
|
+
*.rsuser
|
37
|
+
*.suo
|
38
|
+
*.user
|
39
|
+
*.userosscache
|
40
|
+
*.sln.docstates
|
41
|
+
*.txt
|
42
|
+
*.userprefs
|
43
|
+
BenchmarkDotNet.Artifacts/
|
44
|
+
[Dd]ebug/
|
45
|
+
[Dd]ebugPublic/
|
46
|
+
[Rr]elease/
|
47
|
+
[Rr]eleases/
|
48
|
+
x64/
|
49
|
+
x86/
|
50
|
+
[Aa][Rr][Mm]/
|
51
|
+
[Aa][Rr][Mm]64/
|
52
|
+
bld/
|
53
|
+
[Bb]in/
|
54
|
+
[Oo]bj/
|
55
|
+
[Ll]og/
|
56
|
+
[Aa]rtifacts/
|
57
|
+
.vs/
|
58
|
+
Generated\ Files/
|
59
|
+
[Tt]est[Rr]esult*/
|
60
|
+
[Bb]uild[Ll]og.*
|
61
|
+
*.VisualState.xml
|
62
|
+
TestResult.xml
|
63
|
+
[Dd]ebugPS/
|
64
|
+
[Rr]eleasePS/
|
65
|
+
dlldata.c
|
66
|
+
BenchmarkDotNet.Artifacts/
|
67
|
+
|
68
|
+
project.lock.json
|
69
|
+
project.fragment.lock.json
|
70
|
+
artifacts/
|
71
|
+
StyleCopReport.xml
|
72
|
+
*_i.c
|
73
|
+
*_p.c
|
74
|
+
*_h.h
|
75
|
+
*.ilk
|
76
|
+
*.meta
|
77
|
+
*.obj
|
78
|
+
*.iobj
|
79
|
+
*.pch
|
80
|
+
*.pdb
|
81
|
+
*.ipdb
|
82
|
+
*.pgc
|
83
|
+
*.pgd
|
84
|
+
*.rsp
|
85
|
+
*.sbr
|
86
|
+
*.tlb
|
87
|
+
*.tli
|
88
|
+
*.tlh
|
89
|
+
*.tmp
|
90
|
+
*.tmp_proj
|
91
|
+
*_wpftmp.csproj
|
92
|
+
*.log
|
93
|
+
*.vspscc
|
94
|
+
*.vssscc
|
95
|
+
.builds
|
96
|
+
*.pidb
|
97
|
+
*.svclog
|
98
|
+
*.scc
|
99
|
+
_Chutzpah*
|
100
|
+
ipch/
|
101
|
+
*.aps
|
102
|
+
*.ncb
|
103
|
+
*.opendb
|
104
|
+
*.opensdf
|
105
|
+
*.sdf
|
106
|
+
*.cachefile
|
107
|
+
*.VC.db
|
108
|
+
*.VC.VC.opendb
|
109
|
+
*.psess
|
110
|
+
*.vsp
|
111
|
+
*.vspx
|
112
|
+
*.sap
|
113
|
+
*.e2e
|
114
|
+
$tf/
|
115
|
+
*.gpState
|
116
|
+
_ReSharper*/
|
117
|
+
*.[Rr]e[Ss]harper
|
118
|
+
*.DotSettings.user
|
119
|
+
.JustCode
|
120
|
+
_TeamCity*
|
121
|
+
*.dotCover
|
122
|
+
.axoCover/*
|
123
|
+
!.axoCover/settings.json
|
124
|
+
*.coverage
|
125
|
+
*.coveragexml
|
126
|
+
_NCrunch_*
|
127
|
+
.*crunch*.local.xml
|
128
|
+
nCrunchTemp_*
|
129
|
+
*.mm.*
|
130
|
+
AutoTest.Net/
|
131
|
+
.sass-cache/
|
132
|
+
[Ee]xpress/
|
133
|
+
DocProject/buildhelp/
|
134
|
+
DocProject/Help/*.HxT
|
135
|
+
DocProject/Help/*.HxC
|
136
|
+
DocProject/Help/*.hhc
|
137
|
+
DocProject/Help/*.hhk
|
138
|
+
DocProject/Help/*.hhp
|
139
|
+
DocProject/Help/Html2
|
140
|
+
DocProject/Help/html
|
141
|
+
publish/
|
142
|
+
*.[Pp]ublish.xml
|
143
|
+
*.azurePubxml
|
144
|
+
*.pubxml
|
145
|
+
*.publishproj
|
146
|
+
PublishScripts/
|
147
|
+
*.nupkg
|
148
|
+
**/[Pp]ackages/*
|
149
|
+
!**/[Pp]ackages/build/
|
150
|
+
*.nuget.props
|
151
|
+
*.nuget.targets
|
152
|
+
csx/
|
153
|
+
*.build.csdef
|
154
|
+
ecf/
|
155
|
+
rcf/
|
156
|
+
AppPackages/
|
157
|
+
BundleArtifacts/
|
158
|
+
Package.StoreAssociation.xml
|
159
|
+
_pkginfo.txt
|
160
|
+
*.appx
|
161
|
+
*.[Cc]ache
|
162
|
+
# but keep track of directories ending in .cache
|
163
|
+
!*.[Cc]ache/
|
164
|
+
ClientBin/
|
165
|
+
~$*
|
166
|
+
*~
|
167
|
+
*.dbmdl
|
168
|
+
*.dbproj.schemaview
|
169
|
+
*.jfm
|
170
|
+
*.pfx
|
171
|
+
*.publishsettings
|
172
|
+
orleans.codegen.cs
|
173
|
+
**/wwwroot/lib/
|
174
|
+
Generated_Code/
|
175
|
+
_UpgradeReport_Files/
|
176
|
+
Backup*/
|
177
|
+
UpgradeLog*.XML
|
178
|
+
UpgradeLog*.htm
|
179
|
+
ServiceFabricBackup/
|
180
|
+
*.rptproj.bak
|
181
|
+
*.mdf
|
182
|
+
*.ldf
|
183
|
+
*.ndf
|
184
|
+
*.rdl.data
|
185
|
+
*.bim.layout
|
186
|
+
*.bim_*.settings
|
187
|
+
*.rptproj.rsuser
|
188
|
+
FakesAssemblies/
|
189
|
+
*.GhostDoc.xml
|
190
|
+
.ntvs_analysis.dat
|
191
|
+
node_modules/
|
192
|
+
*.plg
|
193
|
+
*.opt
|
194
|
+
*.vbw
|
195
|
+
**/*.HTMLClient/GeneratedArtifacts
|
196
|
+
**/*.DesktopClient/GeneratedArtifacts
|
197
|
+
**/*.DesktopClient/ModelManifest.xml
|
198
|
+
**/*.Server/GeneratedArtifacts
|
199
|
+
**/*.Server/ModelManifest.xml
|
200
|
+
_Pvt_Extensions
|
201
|
+
.paket/paket.exe
|
202
|
+
paket-files/
|
203
|
+
.fake/
|
204
|
+
.idea/
|
205
|
+
*.sln.iml
|
206
|
+
.cr/personal
|
207
|
+
__pycache__/
|
208
|
+
*.pyc
|
209
|
+
tools/**
|
210
|
+
!tools/packages.config
|
211
|
+
*.tss
|
212
|
+
*.jmconfig
|
213
|
+
*.btp.cs
|
214
|
+
*.btm.cs
|
215
|
+
*.odx.cs
|
216
|
+
*.xsd.cs
|
217
|
+
OpenCover/
|
218
|
+
ASALocalRun/
|
219
|
+
*.binlog
|
220
|
+
*.nvuser
|
221
|
+
.mfractor/
|
222
|
+
.localhistory/
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module Makit
|
2
|
-
module Content
|
3
|
-
RAKEFILE = <<~HEREDOC
|
4
|
-
require "makit"
|
5
|
-
|
6
|
-
task :default do
|
7
|
-
end
|
8
|
-
|
9
|
-
HEREDOC
|
10
|
-
end # module Content
|
11
|
-
end # module Makit
|
1
|
+
module Makit
|
2
|
+
module Content
|
3
|
+
RAKEFILE = <<~HEREDOC
|
4
|
+
require "makit"
|
5
|
+
|
6
|
+
task :default do
|
7
|
+
end
|
8
|
+
|
9
|
+
HEREDOC
|
10
|
+
end # module Content
|
11
|
+
end # module Makit
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module Makit
|
2
|
-
module Content
|
3
|
-
GEM_RAKEFILE = <<~HEREDOC
|
4
|
-
require "bundler/gem_tasks" # for build, install and release tasks
|
5
|
-
require "minitest/test_task"
|
6
|
-
Minitest::TestTask.create
|
7
|
-
require "makit"
|
8
|
-
|
9
|
-
task :default => [:build, :install] do
|
10
|
-
end
|
11
|
-
|
12
|
-
HEREDOC
|
13
|
-
end # module Content
|
14
|
-
end # module Makit
|
1
|
+
module Makit
|
2
|
+
module Content
|
3
|
+
GEM_RAKEFILE = <<~HEREDOC
|
4
|
+
require "bundler/gem_tasks" # for build, install and release tasks
|
5
|
+
require "minitest/test_task"
|
6
|
+
Minitest::TestTask.create
|
7
|
+
require "makit"
|
8
|
+
|
9
|
+
task :default => [:build, :install] do
|
10
|
+
end
|
11
|
+
|
12
|
+
HEREDOC
|
13
|
+
end # module Content
|
14
|
+
end # module Makit
|
data/lib/makit/data.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "digest"
|
3
|
-
# This module provides classes for the Makit gem.
|
4
|
-
module Makit
|
5
|
-
# This class provide methods for managing persistent data for the makit gem
|
6
|
-
class Data
|
7
|
-
attr_accessor :directory, :use_jsonks
|
8
|
-
|
9
|
-
def initialize(attributes = {})
|
10
|
-
@directory = attributes[:directory] || File.join(Dir.home, ".makit")
|
11
|
-
@use_json = false
|
12
|
-
attributes.each do |key, value|
|
13
|
-
instance_variable_set("@#{key}", value) if self.class.method_defined?("#{key}=")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# remove all data
|
18
|
-
def clear
|
19
|
-
# remove the data directory
|
20
|
-
FileUtils.rm_rf(@directory) if Dir.exist?(@directory)
|
21
|
-
end
|
22
|
-
|
23
|
-
def get_content_id(item)
|
24
|
-
# get the content id for the item
|
25
|
-
bytes_string = item.to_proto.bytes.pack("C*") # Convert the byte array to a string
|
26
|
-
Digest::SHA256.hexdigest(bytes_string)
|
27
|
-
end
|
28
|
-
|
29
|
-
# save the content
|
30
|
-
# data.save_content(git_version)
|
31
|
-
def save(item)
|
32
|
-
content_id = get_content_id(item)
|
33
|
-
# save the content
|
34
|
-
if @use_json
|
35
|
-
# save the content to a json file
|
36
|
-
File.open(File.join(@directory, "#{content_id}.json"), "w") do |file|
|
37
|
-
file.write(item.to_json)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def get_content(content_id)
|
43
|
-
nil
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.gem_db_filename
|
47
|
-
gem_data_directory = File.join(Dir.home, ".makit", "makit.db")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "digest"
|
3
|
+
# This module provides classes for the Makit gem.
|
4
|
+
module Makit
|
5
|
+
# This class provide methods for managing persistent data for the makit gem
|
6
|
+
class Data
|
7
|
+
attr_accessor :directory, :use_jsonks
|
8
|
+
|
9
|
+
def initialize(attributes = {})
|
10
|
+
@directory = attributes[:directory] || File.join(Dir.home, ".makit")
|
11
|
+
@use_json = false
|
12
|
+
attributes.each do |key, value|
|
13
|
+
instance_variable_set("@#{key}", value) if self.class.method_defined?("#{key}=")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# remove all data
|
18
|
+
def clear
|
19
|
+
# remove the data directory
|
20
|
+
FileUtils.rm_rf(@directory) if Dir.exist?(@directory)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_content_id(item)
|
24
|
+
# get the content id for the item
|
25
|
+
bytes_string = item.to_proto.bytes.pack("C*") # Convert the byte array to a string
|
26
|
+
Digest::SHA256.hexdigest(bytes_string)
|
27
|
+
end
|
28
|
+
|
29
|
+
# save the content
|
30
|
+
# data.save_content(git_version)
|
31
|
+
def save(item)
|
32
|
+
content_id = get_content_id(item)
|
33
|
+
# save the content
|
34
|
+
if @use_json
|
35
|
+
# save the content to a json file
|
36
|
+
File.open(File.join(@directory, "#{content_id}.json"), "w") do |file|
|
37
|
+
file.write(item.to_json)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_content(content_id)
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.gem_db_filename
|
47
|
+
gem_data_directory = File.join(Dir.home, ".makit", "makit.db")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|