dsx-dml 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c0267af52f6079d2061168946dfbfedf3fdb5d5
4
- data.tar.gz: b667fcf06038eba5823c6d5c3fb27c226f4448ba
3
+ metadata.gz: ee65d248642ebe915e7779d3890c2ee7a626d7f7
4
+ data.tar.gz: 7c56bd0ae94de68ab040f80f22e4c02f43684bf1
5
5
  SHA512:
6
- metadata.gz: 30f256ae7964fb6409af0741443c40f567e6db6aa54672d297e851159aa65190f8976cb1869e5e8196c05ed8d044bf1ef2772c6793f63f943864a0448a218d13
7
- data.tar.gz: 0f1c0aae389746b2d12f1eb7af8d761ca8c8c4a67df21924a8decbb369b60cdbc3913d54a0efd94d467b983498c7c26bbffe3b36452b268e1bf2e500bbddf8d1
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: number
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({address: '127.0.0.1', user: 'dsx_user', password: 'dsx_password' })
66
- changeset_1.curl({address: '127.0.0.1', user: 'dsx_user', password: 'dsx_password' })
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
@@ -5,11 +5,11 @@ module Dsx
5
5
 
6
6
  class Zone
7
7
 
8
- def initialize(location_num, udf_field_num, writer = false)
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(writer)
12
- @writer = writer
11
+ if(writer_options)
12
+ @writer = Dsx::Dml::Writer.new(writer_options)
13
13
  end
14
14
  end
15
15
 
@@ -1,5 +1,5 @@
1
1
  module Dsx
2
2
  module Dml
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -9,9 +9,9 @@ module Dsx
9
9
 
10
10
  class Operation
11
11
 
12
- def initialize(details, writer = false)
12
+ def initialize(details, writer_options = false)
13
13
  initialize_details(details)
14
- initialize_command(writer)
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(writer=false)
66
- @zone = (writer) ? Zone.new(@location_num, @udf_num, writer) : Zone.new(@location_num, @udf_num)
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.2
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-25 00:00:00.000000000 Z
11
+ date: 2013-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler