projectsimulator 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d48b4e25949ccbd4ae87be72f39091fd3b6ffe94b0222dd027f045288468b24c
4
+ data.tar.gz: cc8d40687884dc750ec041e65ea5982aec888bd80c288f863cc03330d396eacb
5
+ SHA512:
6
+ metadata.gz: 5fbc68d2b15cd3db89945c3257d415e966f5dbf1b22035fa60d52061c55a893fb9a49bf64c67cb6253d8cef116a30122a1a53000ef6ab972b04796dc11efbe05
7
+ data.tar.gz: 2d03532745effa29d59f1005b13f69ddc6f6c21349d93349517ace4eb0ce7587c35b87a878b4688f29fc65f3f5159c5a18d4975b748431c5ed7ecf0ece15bec9
@@ -0,0 +1,3 @@
1
+ �|� �b�n�LZ�!�G�0� 2�pDX�4�uU�.
2
+ ���fɏ�2k��*�*.���J��!� λ��2�vj
3
+  �8ioy��$Zn&D� wKZO��E�X>;l�ʜr���^�H �*0`�s��Y�N��r�ͅ��$ゾY}��4�����>E+�����Vh&_����\��W��b]B5����t��k�=U'�b�*�( ���3k�#P
Binary file
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: projectsimulator.rb
4
+
5
+ require 'easydom'
6
+ require 'app-routes'
7
+
8
+
9
+ module ProjectSimulator
10
+
11
+ class Model
12
+ include AppRoutes
13
+
14
+ def initialize()
15
+
16
+ super()
17
+
18
+ end
19
+
20
+ def build(raw_requests, root: 'building1')
21
+
22
+ @ed = EasyDom.new(debug: false, root: root)
23
+ raw_requests.lines.each {|line| request(line) }
24
+
25
+ end
26
+
27
+ def op()
28
+ @ed
29
+ end
30
+
31
+ def query(s)
32
+ @ed.e.element(s)
33
+ end
34
+
35
+ def to_sliml()
36
+ @ed.to_sliml
37
+ end
38
+
39
+ def xml(options=nil)
40
+ @ed.xml(pretty: true).gsub(' style=\'\'','')
41
+ end
42
+
43
+ protected
44
+
45
+ def requests(params)
46
+
47
+ get /(?:switch|turn) the ([^ ]+) +([^ ]+) +(on|off)$/ do |location, device, onoff|
48
+ {action: 'switch=', location: location, device: device, value: onoff}
49
+ end
50
+
51
+ end
52
+
53
+ private
54
+
55
+ def request(s)
56
+
57
+ params = {request: s}
58
+ requests(@params)
59
+ h = find_request(s)
60
+
61
+ a = h[:location].split(/ /)
62
+ a << h[:device]
63
+ a.inject(@ed) {|r,x| r.send(x)}.send(h[:action], h[:value])
64
+
65
+ end
66
+
67
+ alias find_request run_route
68
+
69
+
70
+ end
71
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: projectsimulator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwNTAyMTkzMjE2WhcN
15
+ MjEwNTAyMTkzMjE2WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDImL9V
17
+ RTawKPLQ+YSVnRMlrI909Qc7xDv7JZjM+AqtSLV1/OJcvZEq/8kFKM8qZI6buFuI
18
+ yMLZoaxo3WmS9u+KozUBiYt/9HsmQNL0yTIO01IMQ6iMsCCxphxadSZLewDfkcyj
19
+ L4WeFz+f+8bxljnBONHz1mtlcN6QkFzHvXctRWeVH5W/Wv0fYImoNOvWVGux+HLv
20
+ FVgy2DIrdbfk8AS8zJxePFbvWLQqHCuYjOuqmMMJbnCxABJT+yYBWhvt+K1OQ3wD
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aWaZwg
37
+ -----END CERTIFICATE-----
38
+ date: 2020-05-02 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: easydom
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.2'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.2.1
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.2'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.2.1
60
+ - !ruby/object:Gem::Dependency
61
+ name: app-routes
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.1'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.1.19
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.1'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.1.19
80
+ description:
81
+ email: james@jamesrobertson.eu
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - lib/projectsimulator.rb
87
+ homepage: https://github.com/jrobertson/projectsimulator
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.0.3
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Project Simulator (in development) aims to make it easier to observe triggers
110
+ and actions from an XML based model.
111
+ test_files: []
Binary file