gloo-lang 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6746a91317e31e0a887b5c338cc22e14b92c739abbbb00273222d6b4180303ea
|
4
|
+
data.tar.gz: 39aa1c78c462853229b9e976f36a562a71ba44141160238408f364f3da9e919c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5417428f1a6d7f251003fac7b30fb9bc3f0fabbc0b1a90b851c7bb78e410278e5bd2947ace1e04c4f3a61934c3fab1e81b721d7e542326e43ba0981adc7dc21b
|
7
|
+
data.tar.gz: 167b5abaf8e6fb186f8886665f916b688a28b56c8b61f164275b7bd6f429bf2407b0e2e3de273de47297957fcf97837e3f475feade5709b39550c3f879367809
|
data/lib/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2022 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Disc based mechanism for files.
|
5
|
+
# Provides interaction between the persistance classes and the OS
|
6
|
+
# file and folder system.
|
7
|
+
# This class might be overiden elsewhere to provide other mechanism.
|
8
|
+
# For example, in gloo-web, there will be a db based mechanism.
|
9
|
+
#
|
10
|
+
|
11
|
+
module GlooLang
|
12
|
+
module Persist
|
13
|
+
class DiscMech
|
14
|
+
|
15
|
+
#
|
16
|
+
# Set up a disc based file mechanism.
|
17
|
+
#
|
18
|
+
def initialize( engine )
|
19
|
+
@engine = engine
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Get the default file extention.
|
24
|
+
#
|
25
|
+
def file_ext
|
26
|
+
return '.gloo'
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Get all the gloo files in the folder (partial path).
|
31
|
+
#
|
32
|
+
def get_all_files_in( folder )
|
33
|
+
pns = []
|
34
|
+
dir = File.join( @engine.settings.project_path, folder )
|
35
|
+
Dir.glob( "#{dir}*.gloo" ).each do |f|
|
36
|
+
pns << f
|
37
|
+
end
|
38
|
+
return pns
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Check if a file exists.
|
43
|
+
#
|
44
|
+
def exist?( file )
|
45
|
+
File.exist?( file )
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# Check to see if the file is valid.
|
50
|
+
#
|
51
|
+
def valid?( file )
|
52
|
+
return false unless file
|
53
|
+
return false unless File.exist?( file )
|
54
|
+
return false unless File.file?( file )
|
55
|
+
return false unless file.end_with?( self.file_ext )
|
56
|
+
|
57
|
+
return true
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Expand a single file path.
|
62
|
+
#
|
63
|
+
def expand( name )
|
64
|
+
ext_path = File.expand_path( name )
|
65
|
+
return [ ext_path ] if self.valid?( ext_path )
|
66
|
+
|
67
|
+
full_name = "#{name}#{file_ext}"
|
68
|
+
return [ File.join( @engine.settings.project_path, full_name ) ]
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Read in the contents of a single file.
|
73
|
+
#
|
74
|
+
def read( file )
|
75
|
+
return File.read( file )
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# Write data to the file.
|
80
|
+
#
|
81
|
+
def write( pn, data )
|
82
|
+
File.write( pn, data )
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -19,6 +19,7 @@ module GlooLang
|
|
19
19
|
#
|
20
20
|
def initialize( engine, pn )
|
21
21
|
@engine = engine
|
22
|
+
@mech = @engine.platform.getFileMech( @engine )
|
22
23
|
@pn = pn
|
23
24
|
@tabs = 0
|
24
25
|
@obj = nil
|
@@ -33,7 +34,7 @@ module GlooLang
|
|
33
34
|
# Load the objects from the file.
|
34
35
|
#
|
35
36
|
def load
|
36
|
-
unless
|
37
|
+
unless @mech.exist?( @pn )
|
37
38
|
@engine.log.error "File '#{@pn}' does not exist."
|
38
39
|
return
|
39
40
|
end
|
@@ -43,7 +44,7 @@ module GlooLang
|
|
43
44
|
@parent_stack = []
|
44
45
|
@parent = @engine.heap.root
|
45
46
|
@parent_stack.push @parent
|
46
|
-
f =
|
47
|
+
f = @mech.read( @pn )
|
47
48
|
f.each_line do |line|
|
48
49
|
next if skip_line? line
|
49
50
|
|
@@ -13,6 +13,7 @@ module GlooLang
|
|
13
13
|
#
|
14
14
|
def initialize( engine, pn, obj )
|
15
15
|
@engine = engine
|
16
|
+
@mech = @engine.platform.getFileMech( @engine )
|
16
17
|
@pn = pn
|
17
18
|
@obj = obj
|
18
19
|
end
|
@@ -22,7 +23,7 @@ module GlooLang
|
|
22
23
|
#
|
23
24
|
def save
|
24
25
|
data = get_obj( @obj )
|
25
|
-
|
26
|
+
@mech.write( @pn, data )
|
26
27
|
end
|
27
28
|
|
28
29
|
#
|
@@ -10,7 +10,7 @@ module GlooLang
|
|
10
10
|
module Persist
|
11
11
|
class PersistMan
|
12
12
|
|
13
|
-
attr_reader :maps
|
13
|
+
attr_reader :maps, :mech
|
14
14
|
|
15
15
|
#
|
16
16
|
# Contructor for the persistence manager.
|
@@ -18,6 +18,7 @@ module GlooLang
|
|
18
18
|
def initialize( engine )
|
19
19
|
@engine = engine
|
20
20
|
@maps = []
|
21
|
+
@mech = @engine.platform.getFileMech( @engine )
|
21
22
|
end
|
22
23
|
|
23
24
|
#
|
@@ -72,18 +73,9 @@ module GlooLang
|
|
72
73
|
return nil if name.strip.empty?
|
73
74
|
|
74
75
|
if name.strip[ -1 ] == '*'
|
75
|
-
|
76
|
-
dir = File.join( @engine.settings.project_path, name[ 0..-2 ] )
|
77
|
-
Dir.glob( "#{dir}*.gloo" ).each do |f|
|
78
|
-
pns << f
|
79
|
-
end
|
80
|
-
return pns
|
76
|
+
return @mech.get_all_files_in( name[ 0..-2 ] )
|
81
77
|
else
|
82
|
-
|
83
|
-
return [ ext_path ] if self.gloo_file?( ext_path )
|
84
|
-
|
85
|
-
full_name = "#{name}#{file_ext}"
|
86
|
-
return [ File.join( @engine.settings.project_path, full_name ) ]
|
78
|
+
return @mech.expand( name )
|
87
79
|
end
|
88
80
|
end
|
89
81
|
|
@@ -91,19 +83,14 @@ module GlooLang
|
|
91
83
|
# Check to see if a given path name refers to a gloo object file.
|
92
84
|
#
|
93
85
|
def gloo_file?( name )
|
94
|
-
return
|
95
|
-
return false unless File.exist?( name )
|
96
|
-
return false unless File.file?( name )
|
97
|
-
return false unless name.end_with?( self.file_ext )
|
98
|
-
|
99
|
-
return true
|
86
|
+
return @mech.valid?( name )
|
100
87
|
end
|
101
88
|
|
102
89
|
#
|
103
90
|
# Get the default file extention.
|
104
91
|
#
|
105
92
|
def file_ext
|
106
|
-
return
|
93
|
+
return @mech.file_ext
|
107
94
|
end
|
108
95
|
|
109
96
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gloo-lang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Crane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -274,6 +274,7 @@ files:
|
|
274
274
|
- lib/gloo_lang/objs/web/slack.rb
|
275
275
|
- lib/gloo_lang/objs/web/teams.rb
|
276
276
|
- lib/gloo_lang/objs/web/uri.rb
|
277
|
+
- lib/gloo_lang/persist/disc_mech.rb
|
277
278
|
- lib/gloo_lang/persist/file_loader.rb
|
278
279
|
- lib/gloo_lang/persist/file_saver.rb
|
279
280
|
- lib/gloo_lang/persist/file_storage.rb
|