snow_sync 3.0.0 → 3.0.1
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 +15 -7
- data/lib/snow_sync/configs.yml +5 -0
- data/lib/snow_sync/sync_util.rb +22 -18
- data/lib/snow_sync/version.rb +1 -1
- data/spec/sync_util_spec.rb +12 -7
- 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: ea97a4f0bcc5c8db5ca1851c10b6fda3beb9d98b
|
4
|
+
data.tar.gz: 25b998519cde755b0b2816ad4177ef6d0d8dbbde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35a51a11647114eca0f2064ef24f11e554fd6f617410eca25173aabe055566be15c1403f0bd77511e210050f3f7bf6a5e1c2b22f58ce65fe4db1074b1da55aa0
|
7
|
+
data.tar.gz: b92030f7766b113e61f3674dab502b4eef4be1191947769278ac18f434d6ffcf28b49fdf1c3e1d37ad5ceb617ad829d2b90f666f9db99e805b39805176efbe2a
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SnowSync
|
2
2
|
|
3
|
-
[](https://rubygems.org/gems/snow_sync) [](https://rubygems.org/gems/snow_sync) [](https://rubygems.org/gems/snow_sync)
|
4
4
|
|
5
5
|
SnowSync is a file sync utility tool and API which provides a bridge for off platform ServiceNow development using an IDE or text editor locally.
|
6
6
|
|
@@ -8,8 +8,16 @@ SnowSync syncronizes configured fields (scripts) for a ServiceNow instance local
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
+
```bash
|
12
|
+
mkdir snow_sync
|
13
|
+
```
|
14
|
+
|
15
|
+
```bash
|
16
|
+
cd snow_sync
|
17
|
+
```
|
18
|
+
|
11
19
|
```ruby
|
12
|
-
gem install --install-dir <path> snow_sync
|
20
|
+
gem install --install-dir <path-to-the-snow_sync-dir> snow_sync
|
13
21
|
```
|
14
22
|
|
15
23
|
## Setup & Usage
|
@@ -19,10 +27,10 @@ gem install bundler
|
|
19
27
|
```
|
20
28
|
|
21
29
|
```bash
|
22
|
-
cd <path>/gems/snow_sync-<version>
|
30
|
+
cd <path-to-the-snow_sync-dir>/gems/snow_sync-<version>
|
23
31
|
```
|
24
32
|
|
25
|
-
Create a Gemfile and add the following:
|
33
|
+
Create a Gemfile and add the following Gem dependencies:
|
26
34
|
|
27
35
|
```ruby
|
28
36
|
source 'https://rubygems.org'
|
@@ -47,7 +55,7 @@ cd /lib/snow_sync
|
|
47
55
|
```
|
48
56
|
|
49
57
|
* Setup the configurations in the configs.yml
|
50
|
-
*
|
58
|
+
* Now supports multi-table map configurations
|
51
59
|
* Configuration path is the current working directory
|
52
60
|
* Append /api/now/table/ to the base_url
|
53
61
|
|
@@ -64,8 +72,8 @@ guard -i
|
|
64
72
|
cd <path>/gems/snow_sync-<version>
|
65
73
|
```
|
66
74
|
|
67
|
-
*
|
68
|
-
*
|
75
|
+
* Integration tests use a test record in the instance (e.g. a script include)
|
76
|
+
* Unit tests are all stubbed out
|
69
77
|
* Setup the test configurations in the test_configs.yml
|
70
78
|
* Configuration path is the current working directory
|
71
79
|
* Append /api/now/table/ to the base_url
|
data/lib/snow_sync/configs.yml
CHANGED
data/lib/snow_sync/sync_util.rb
CHANGED
@@ -128,34 +128,36 @@ module SnowSync
|
|
128
128
|
end
|
129
129
|
|
130
130
|
# Classifies a JS file by name
|
131
|
-
# @param [String] file JS file
|
131
|
+
# @param [String] file JS file by name
|
132
|
+
# @return classified JS file by name
|
132
133
|
|
133
134
|
def classify(file)
|
134
|
-
file = file.split("
|
135
|
+
file = file.split(".").first.camelcase
|
135
136
|
file[0] = file[0].capitalize
|
136
137
|
file
|
137
138
|
end
|
138
139
|
|
139
140
|
# Lookup returns the configured servicenow table hash
|
140
|
-
# @param [String]
|
141
|
+
# @param [String] type Config table label
|
142
|
+
# @param [String] file JS file by name
|
141
143
|
# @return configured servicenow table hash
|
142
144
|
|
143
|
-
def table_lookup(file)
|
145
|
+
def table_lookup(type, file)
|
144
146
|
@configs["table_map"].select do |key, value|
|
145
|
-
if value["name"].eql?(classify(file))
|
147
|
+
if key.eql?(type) and value["name"].eql?(classify(file))
|
146
148
|
return value
|
147
149
|
end
|
148
150
|
end
|
149
151
|
end
|
150
152
|
|
151
153
|
# Merges JS file changes with the encapsulated table response value
|
152
|
-
# @param [String]
|
153
|
-
# @param [String]
|
154
|
+
# @param [String] type Config table label
|
155
|
+
# @param [String] file JS file by name
|
154
156
|
# @param [Hash] table_hash Configured servicenow table hash
|
155
157
|
|
156
|
-
def merge_update(
|
157
|
-
FileUtils.cd(
|
158
|
-
script_body = File.open(file
|
158
|
+
def merge_update(type, file, table_hash)
|
159
|
+
FileUtils.cd("sync" + "/" + type)
|
160
|
+
script_body = File.open(file).read
|
159
161
|
@configs["table_map"][type]["mod"] = script_body
|
160
162
|
FileUtils.cd("../..")
|
161
163
|
end
|
@@ -169,14 +171,16 @@ module SnowSync
|
|
169
171
|
end
|
170
172
|
|
171
173
|
# Merges all JS file changes & pushes to the configured servicenow instance
|
172
|
-
# @param [Array]
|
173
|
-
|
174
|
-
def push_modifications(
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
174
|
+
# @param [Array] paths JS file paths
|
175
|
+
|
176
|
+
def push_modifications(paths)
|
177
|
+
paths.each do |path|
|
178
|
+
path.downcase!
|
179
|
+
path = path.split("/")
|
180
|
+
type = path[1]
|
181
|
+
file = path[2]
|
182
|
+
table_hash = table_lookup(type, file)
|
183
|
+
merge_update(type, file, table_hash)
|
180
184
|
begin
|
181
185
|
user = Base64.strict_decode64(@configs["creds"]["user"])
|
182
186
|
pass = Base64.strict_decode64(@configs["creds"]["pass"])
|
data/lib/snow_sync/version.rb
CHANGED
data/spec/sync_util_spec.rb
CHANGED
@@ -111,7 +111,8 @@ describe "classify" do
|
|
111
111
|
|
112
112
|
it "should convert snake_case string to CamelCase" do
|
113
113
|
js_file_path = "sync/script_include/test_class.js"
|
114
|
-
|
114
|
+
path = js_file_path.split("/")
|
115
|
+
cc = util.classify(path[2])
|
115
116
|
expect(cc).to eq "TestClass"
|
116
117
|
end
|
117
118
|
|
@@ -124,7 +125,7 @@ describe "table_lookup" do
|
|
124
125
|
end
|
125
126
|
|
126
127
|
it "should return configured SN table" do
|
127
|
-
table_map = util.table_lookup("
|
128
|
+
table_map = util.table_lookup("script_include", "test_class.js")
|
128
129
|
expect(table_map.keys).to eq ["name", "table", "sys_id", "field"]
|
129
130
|
expect(table_map["table"]).to eq "sys_script_include"
|
130
131
|
end
|
@@ -139,20 +140,24 @@ describe "merge_update" do
|
|
139
140
|
|
140
141
|
it "should merge script with the configs object" do
|
141
142
|
FileUtils.mkdir_p("sync")
|
142
|
-
FileUtils.mkdir_p("sync/
|
143
|
+
FileUtils.mkdir_p("sync/script_include")
|
143
144
|
json_resp = "var test = 'test'; \n" +
|
144
145
|
"var testing = function(arg) { \n\tgs.print(arg) \n}; \n" +
|
145
146
|
"testing('test');"
|
146
147
|
name = "TestClass".snakecase
|
147
148
|
path = proc do
|
148
|
-
FileUtils.cd("sync/
|
149
|
+
FileUtils.cd("sync/script_include")
|
149
150
|
end
|
150
151
|
util.create_file(name, json_resp, &path)
|
151
152
|
FileUtils.cd("../..")
|
152
|
-
file = "sync/
|
153
|
-
|
154
|
-
|
153
|
+
file = "sync/script_include/test_class.js"
|
154
|
+
path = file.split("/")
|
155
|
+
type = path[1]
|
156
|
+
file = path[2]
|
157
|
+
table_map = util.table_lookup(type, file)
|
158
|
+
util.merge_update(type, file, table_map)
|
155
159
|
expect(util.configs["table_map"]["script_include"]["mod"] != nil).to eq true
|
160
|
+
FileUtils.rm_rf("sync")
|
156
161
|
end
|
157
162
|
|
158
163
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snow_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Wallace
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|