hmstools 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. data/lib/hmstools.rb +91 -0
  2. metadata +3 -3
data/lib/hmstools.rb CHANGED
@@ -55,6 +55,15 @@ module HMSTools
55
55
  @total = @total.to_i
56
56
  end
57
57
 
58
+ # Starts the process of counting lines of code
59
+ #
60
+ # Example:
61
+ # >> LOCReader.run "./my_project/*", ".rb"
62
+ #
63
+ # Arguments:
64
+ # dir: (String) The directory you want to search. Include /* on the end.
65
+ # ext: (String) List of file extensions. Comma seperated
66
+
58
67
  def run(dir, ext = "")
59
68
  unless ext == ""
60
69
  @ext = ext.split(',')
@@ -63,6 +72,14 @@ module HMSTools
63
72
  get_files dir
64
73
  @total = @lines - @blank_lines
65
74
  end
75
+
76
+ # Grabs the directory and loops through the files. This is recursive to grab all sub directories
77
+ #
78
+ # Example
79
+ # >> LOCReader.get_files "./my_project/*"
80
+ #
81
+ # Arguments:
82
+ # dir: (String) The directory you want to search. Include /* on the end.
66
83
 
67
84
  def get_files(dir)
68
85
 
@@ -83,6 +100,15 @@ module HMSTools
83
100
  end
84
101
  end
85
102
 
103
+ # Reads the files and counts the lines
104
+ #
105
+ # Example
106
+ # >> LOCReader.read_lines "./helloworld.rb"
107
+ # => Hello World
108
+ #
109
+ # Arguments:
110
+ # file: (String)
111
+
86
112
  def read_lines(file)
87
113
  begin
88
114
  ofile = File.new(file, "r")
@@ -98,14 +124,33 @@ module HMSTools
98
124
  end
99
125
  end
100
126
 
127
+ # Returns an array of the number of files, total lines, blank lines, and actual lines
128
+ # Example
129
+ # >> LOCReader.print_array
130
+ # => [3, 90, 10, 100]
131
+
101
132
  def print_array
102
133
  [@num_files, @total, @blank_lines, @lines]
103
134
  end
135
+
136
+ # Returns a hash of the number of files, total lines, blank lines, and actual lines
137
+ # Example
138
+ # >> LOCReader.print_hash
139
+ # => {"files" => 3, "loc" => 90, "bloc" => 10, "lines" => 100}
104
140
 
105
141
  def print_hash
106
142
  {"files" => @num_files, "loc" => @total, "bloc" => @blank_lines, "lines" => @lines}
107
143
  end
108
144
 
145
+
146
+ # prints the number of files, total lines, blank lines, and actual lines
147
+ # Example
148
+ # >> LOCReader.print_output
149
+ # => Files 3
150
+ # => Lines of Code: 90
151
+ # => Blank Lines: 10
152
+ # => Total Lines: 10
153
+
109
154
  def print_output
110
155
  print "Files: #@num_files \n"
111
156
  print "Lines of Code: #@total \n"
@@ -117,11 +162,26 @@ module HMSTools
117
162
 
118
163
  class XFDL
119
164
 
165
+ # Base64 decodes a given string
166
+ # Example
167
+ # >> XFDL.b64decode_it "randommishmash"
168
+ # => "Not So Random Mish Mash"
169
+ #
170
+ # Arguments
171
+ # contents: (String)
120
172
  def b64decode_it(contents = nil)
121
173
  x = Base64.decode64(contents)
122
174
  return x
123
175
  end
124
176
 
177
+ # Base64 encodes a given string
178
+ # Example
179
+ # >> XFDL.b64eecode_it "Not So Random Mish Mash"
180
+ # => "randommishmash"
181
+ #
182
+ # Arguments
183
+ # contents: (String)
184
+
125
185
  def b64encode_it(contents = nil)
126
186
  unless contents.nil?
127
187
  x = Base64.encode64(contents)
@@ -129,6 +189,16 @@ module HMSTools
129
189
  end
130
190
  end
131
191
 
192
+
193
+ # Searches for all xml files in a directory and turns them into xfdl files
194
+ # Example
195
+ # >> XFDL.build_and_write_xfdl_from_directory "myxmlfiles/*", "myxfdlfiles"
196
+ # => Packaging Form1.xml to Form1.xfdl - Complete
197
+ # => 1 out of 1 were XML files and processed to the XFDL format!
198
+ #
199
+ # Arguments
200
+ # xmldirectory: (String) A directory where all the xml files are stored
201
+ # xfdldirectory: (String) A directory where all the xfdl files will be written to
132
202
  def build_and_write_xfdl_from_directory(xmldirectory, xfdldirectory)
133
203
  @files = Dir.glob(xmldirectory)
134
204
  numfiles = 0
@@ -148,6 +218,14 @@ module HMSTools
148
218
  print "\n" + numxmlfiles.to_s + " out of " + numfiles.to_s + " were XML files and processed to the XFDL format!"
149
219
  end
150
220
 
221
+
222
+ # Turns an xml file into an xfdl file
223
+ # Example
224
+ # >> XFDL.build_and_write_xfdl_from_xml "myform.xml", "myform.xfdl"
225
+ #
226
+ # Arguments
227
+ # xmlfile: (String) The xml file you want to convert
228
+ # xfdlfile: (String) The name of the xfdl file you want to save.
151
229
  def build_and_write_xfdl_from_xml(xmlfile, xfdlfile)
152
230
  # 1. Gzip
153
231
  # 2. Base64
@@ -176,6 +254,13 @@ module HMSTools
176
254
 
177
255
  end
178
256
 
257
+ # Turns an xfdl file into an xml file
258
+ # Example
259
+ # >> XFDL.deconstruct_and_write_xml "myform.xfdl", "myform.xml"
260
+ #
261
+ # Arguments
262
+ # old_filename: (String) The xfdl file you want to convert
263
+ # new_filename: (String) The name of the xml file
179
264
  def deconstruct_and_write_xml(old_filename, new_filename)
180
265
 
181
266
  if File.exists?(old_filename)
@@ -197,6 +282,12 @@ module HMSTools
197
282
  end
198
283
 
199
284
 
285
+ # Turns an xfdl file into an xml file
286
+ # Example
287
+ # >> XFDL.get_xml "Some Fun Stuff"
288
+ #
289
+ # Arguments
290
+ # contents: (String) The base 64 encoded string after opening the xfdl file and stripping the content type information
200
291
  def get_xml(contents)
201
292
  b64_decoded = ''
202
293
  xml_contents = ''
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hmstools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Kreitner