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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 291450da560ad042fd30195c1d5af042c4ff48b4
4
- data.tar.gz: 1760e8efa915a578052e08cefc5873becf7a128d
3
+ metadata.gz: ea97a4f0bcc5c8db5ca1851c10b6fda3beb9d98b
4
+ data.tar.gz: 25b998519cde755b0b2816ad4177ef6d0d8dbbde
5
5
  SHA512:
6
- metadata.gz: 351fe385067754cccb985ae275e12616e5727dc6753a8c602a75542df3e5cc3a4ae33ffe41f7f85d01e98c1b6940d0a81d31122ccb8bce8feb4d43267e92f5f3
7
- data.tar.gz: 42568f36c2e279d3dd3cade31af8af0449a3f7483a3f03bfe5b0968ecc65de5d3f9202da209c60fda7536549f5d1d26c8a95c4863475ce96200d072686988a25
6
+ metadata.gz: 35a51a11647114eca0f2064ef24f11e554fd6f617410eca25173aabe055566be15c1403f0bd77511e210050f3f7bf6a5e1c2b22f58ce65fe4db1074b1da55aa0
7
+ data.tar.gz: b92030f7766b113e61f3674dab502b4eef4be1191947769278ac18f434d6ffcf28b49fdf1c3e1d37ad5ceb617ad829d2b90f666f9db99e805b39805176efbe2a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SnowSync
2
2
 
3
- [![Gem Version](https://img.shields.io/badge/gem-v2.0.7-brightgreen.svg)](https://rubygems.org/gems/snow_sync) [![Dependency Status](https://img.shields.io/badge/dependencies-up--to--date-orange.svg)](https://rubygems.org/gems/snow_sync) [![Downloads](https://img.shields.io/badge/downloads-3k%2B-brightgreen.svg)](https://rubygems.org/gems/snow_sync)
3
+ [![Gem Version](https://img.shields.io/badge/gem-v3.0.1-brightgreen.svg)](https://rubygems.org/gems/snow_sync) [![Dependency Status](https://img.shields.io/badge/dependencies-up--to--date-blue.svg)](https://rubygems.org/gems/snow_sync) [![Downloads](https://img.shields.io/badge/downloads-4k%2B-lightgrey.svg)](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
- * Only supports single table map configuration (multi coming soon...)
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
- * Create a test_configs.yml file
68
- * Create a test record in the instance (ex: a test script include)
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
@@ -13,3 +13,8 @@ table_map:
13
13
  table:
14
14
  sys_id:
15
15
  field:
16
+ scheduled_job:
17
+ name:
18
+ table:
19
+ sys_id:
20
+ field:
@@ -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 path
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("/").last.split(".").first.camelcase
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] file JS file path
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] file JS file path
153
- # @param [String] type Servicenow script type
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(file, type, table_hash)
157
- FileUtils.cd(file.split("/")[0..1].join("/"))
158
- script_body = File.open(file.split("/").last).read
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] files JS file paths
173
-
174
- def push_modifications(files)
175
- files.each do |file|
176
- file.downcase!
177
- type = file.split("/")[1]
178
- table_hash = table_lookup(file)
179
- merge_update(file, type, table_hash)
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"])
@@ -1,3 +1,3 @@
1
1
  module SnowSync
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -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
- cc = util.classify(js_file_path)
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("sync/script_include/test_class.js")
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/test_sub_dir")
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/test_sub_dir")
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/test_sub_dir/test_class.js"
153
- table_map = util.table_lookup(file)
154
- util.merge_update(file, "script_include", table_map)
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.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-07 00:00:00.000000000 Z
11
+ date: 2017-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler