jsfrost_test_gem 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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: "
@@ -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
@@ -2,6 +2,6 @@ module TestGem
2
2
 
3
3
  puts "file version.rb required"
4
4
 
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.3"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsfrost_test_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: