jsfrost_test_gem 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.
- data/bin/test_gem +10 -0
- data/lib/test_gem.rb +23 -0
- data/lib/test_gem/version.rb +1 -1
- metadata +1 -1
data/bin/test_gem
CHANGED
@@ -8,6 +8,16 @@ puts ARGV[0]
|
|
8
8
|
print "Working with file: "
|
9
9
|
puts ARGV[0]
|
10
10
|
|
11
|
+
if ARGV.include? '--init'
|
12
|
+
TestGem.init_config
|
13
|
+
else
|
14
|
+
my_hash = { "key1" => "value1",
|
15
|
+
"key2" => "value2",
|
16
|
+
"key3" => "value3" }
|
17
|
+
|
18
|
+
TestGem.configure my_hash
|
19
|
+
end
|
20
|
+
|
11
21
|
returnVal = TestGem::File.first ARGV[0]
|
12
22
|
|
13
23
|
print "The chomped first line of that file is: "
|
data/lib/test_gem.rb
CHANGED
@@ -3,9 +3,32 @@ $LOAD_PATH.unshift File.expand_path("../test_gem", __FILE__)
|
|
3
3
|
require 'version'
|
4
4
|
require 'hello'
|
5
5
|
require 'file'
|
6
|
+
require 'yaml'
|
6
7
|
|
7
8
|
module TestGem
|
8
9
|
|
9
10
|
puts "module TestGem defined"
|
10
11
|
|
12
|
+
class MyArgumentError < ArgumentError; end
|
13
|
+
|
14
|
+
def self.init_config
|
15
|
+
defaults = { "default_file_name" => "default_file.txt",
|
16
|
+
"supported_types" => ['txt', 'pdf'] }
|
17
|
+
open("config.yml", "w") {|f| f.write(defaults.to_yaml) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.configure the_hash=nil
|
21
|
+
if not FileTest.exist?("config.yml")
|
22
|
+
raise MyArgumentError, 'Could not locate config.yml'
|
23
|
+
end
|
24
|
+
|
25
|
+
parsed = begin
|
26
|
+
YAML.load(File.open("config.yml"))
|
27
|
+
rescue MyArgumentError => e
|
28
|
+
puts "Could not parse YAML: #{e.message}"
|
29
|
+
end
|
30
|
+
|
31
|
+
puts "Those parsed values are: #{parsed}"
|
32
|
+
end
|
33
|
+
|
11
34
|
end
|
data/lib/test_gem/version.rb
CHANGED