dsx-dml 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +62 -7
- data/lib/dsx/dml.rb +3 -3
- data/lib/dsx/dml/version.rb +1 -1
- data/lib/dsx/operation.rb +12 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee65d248642ebe915e7779d3890c2ee7a626d7f7
|
4
|
+
data.tar.gz: 7c56bd0ae94de68ab040f80f22e4c02f43684bf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 997a72a1e468cc4b62716699dfc6a30d6a62107cd6829f94ccbc9bec18c0b21a9ad20e53ee127a98e7073f365cd06897a6a303c14a18ce48845f9f2d7d9411c5
|
7
|
+
data.tar.gz: 7a77e00e412a7ced0c56edae4ea3689ddc70f98a04829960b24948933924e49653cd5efb66395143dfdc711568a3996e8b70a66de38f75872739527634847dc6
|
data/README.md
CHANGED
@@ -18,13 +18,17 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
|
22
|
+
### Zones (Locations) and Changesets (Batches of commands)
|
23
|
+
|
21
24
|
```ruby
|
22
25
|
require 'dsx/dml'
|
23
26
|
|
24
27
|
|
25
|
-
# Declare what Location Number (zone) to make changes in and set the UDF field for UID string
|
28
|
+
# Declare what Location Number (zone) to make changes in and set the UDF field for UID string.
|
29
|
+
# Optionally include sftp credentials.
|
26
30
|
|
27
|
-
zone = Dsx::Dml::Zone.new(1111, 2)
|
31
|
+
zone = Dsx::Dml::Zone.new(1111, 2, {address: '127.0.0.1', user: 'dsx_user', password: 'dsx_password'})
|
28
32
|
|
29
33
|
|
30
34
|
# Use a unique identifier to create a changeset for that unique identifier
|
@@ -43,7 +47,7 @@ changeset_0.table('Names').write({
|
|
43
47
|
Notes: 'Often wears bowties'
|
44
48
|
}).table('UDF').write({
|
45
49
|
UdfNum: 2,
|
46
|
-
UdfText:
|
50
|
+
UdfText: '123456789100'
|
47
51
|
}).table('Cards').write({
|
48
52
|
Code: '123456789100',
|
49
53
|
PIN: 1234,
|
@@ -57,17 +61,68 @@ changeset_0.table('Names').write({
|
|
57
61
|
|
58
62
|
changeset_1 = zone.use('123456789101')
|
59
63
|
|
60
|
-
changeset_1.table('Cards').add_acl('Parking Garage')
|
64
|
+
changeset_1.table('Cards').add_acl('Parking Garage').write()
|
61
65
|
|
62
66
|
|
63
|
-
# Push changesets to SFTP receiver
|
67
|
+
# Push changesets to SFTP receiver (using the credentials passed to Zone.new)
|
64
68
|
|
65
|
-
changeset_0.net_sftp(
|
66
|
-
changeset_1.curl(
|
69
|
+
changeset_0.net_sftp() # Uses ruby Net::SFTP library
|
70
|
+
changeset_1.curl() # requires system curl with SFTP support
|
67
71
|
|
68
72
|
|
69
73
|
```
|
70
74
|
|
75
|
+
### Operations
|
76
|
+
|
77
|
+
`Dsx::Dml::Operation` is a wraper intended to make it easier to set up and use certain DML operations.
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
require 'dsx/operation'
|
81
|
+
|
82
|
+
op = Dsx::Dml::Operation.new({ location_num: 1111,
|
83
|
+
udf_num: 2,
|
84
|
+
first_name: 'Harry',
|
85
|
+
last_name: 'Bird',
|
86
|
+
company: 'Harry Bird Co',
|
87
|
+
identifier: '123456789100' },
|
88
|
+
{ address: '127.0.0.1',
|
89
|
+
user: 'dsx_user',
|
90
|
+
password: 'dsx_password' })
|
91
|
+
op.access_levels += ['Top Secret Lab 1', 'Top Secret Lab 2']
|
92
|
+
op.access_levels -= ['Super Secret Lab 0']
|
93
|
+
op.linking_level = 3
|
94
|
+
|
95
|
+
op.net_sftp()
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
### Writer
|
100
|
+
|
101
|
+
`Dsx::Dml::Writer` is used to push commands to DSX SFTP endpoints. Supports `Net::SFTP` and `curl`.
|
102
|
+
|
103
|
+
While writer credentials can be passed through to `Dsx::Dml::Operation` and `Dsx::Dml::Zone`, writers
|
104
|
+
can also be instantiated separately and passed at write time.
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
|
108
|
+
require 'dsx/operation'
|
109
|
+
require 'dsx/writer'
|
110
|
+
|
111
|
+
writer = Dsx::Dml::Writer.new({ address: '127.0.0.1',
|
112
|
+
user: 'dsx_user',
|
113
|
+
password: 'dsx_password' })
|
114
|
+
|
115
|
+
op = Dsx::Dml::Operation.new({ location_num: 1111,
|
116
|
+
udf_num: 2,
|
117
|
+
first_name: 'Harry',
|
118
|
+
last_name: 'Bird',
|
119
|
+
company: 'Harry Bird Co',
|
120
|
+
identifier: '123456789100' })
|
121
|
+
op.access_levels += ['Top Secret Lab 3']
|
122
|
+
|
123
|
+
op.net_sftp(writer)
|
124
|
+
|
125
|
+
```
|
71
126
|
|
72
127
|
|
73
128
|
## Contributing
|
data/lib/dsx/dml.rb
CHANGED
@@ -5,11 +5,11 @@ module Dsx
|
|
5
5
|
|
6
6
|
class Zone
|
7
7
|
|
8
|
-
def initialize(location_num, udf_field_num,
|
8
|
+
def initialize(location_num, udf_field_num, writer_options=false)
|
9
9
|
@location_num = location_num
|
10
10
|
@udf_field_num = udf_field_num
|
11
|
-
if(
|
12
|
-
@writer =
|
11
|
+
if(writer_options)
|
12
|
+
@writer = Dsx::Dml::Writer.new(writer_options)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
data/lib/dsx/dml/version.rb
CHANGED
data/lib/dsx/operation.rb
CHANGED
@@ -9,9 +9,9 @@ module Dsx
|
|
9
9
|
|
10
10
|
class Operation
|
11
11
|
|
12
|
-
def initialize(details,
|
12
|
+
def initialize(details, writer_options = false)
|
13
13
|
initialize_details(details)
|
14
|
-
initialize_command(
|
14
|
+
initialize_command(writer_options)
|
15
15
|
|
16
16
|
end
|
17
17
|
|
@@ -60,10 +60,18 @@ module Dsx
|
|
60
60
|
@changeset.to_s
|
61
61
|
end
|
62
62
|
|
63
|
+
def net_sftp(writer=false)
|
64
|
+
@changeset.net_sftp(writer)
|
65
|
+
end
|
66
|
+
|
67
|
+
def curl(writer=false)
|
68
|
+
@changeset.curl(writer)
|
69
|
+
end
|
70
|
+
|
63
71
|
private
|
64
72
|
|
65
|
-
def initialize_command(
|
66
|
-
@zone = (
|
73
|
+
def initialize_command(writer_options=false)
|
74
|
+
@zone = (writer_options) ? Zone.new(@location_num, @udf_num, writer_options) : Zone.new(@location_num, @udf_num)
|
67
75
|
changeset = @zone.use(@identifier)
|
68
76
|
changeset.table(:Names).write(FName: @first_name,
|
69
77
|
LName: @last_name,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dsx-dml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dgsan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|