nrodruck_test_gem 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/test_gem +15 -1
- data/lib/test_gem.rb +23 -1
- data/lib/test_gem/version.rb +1 -1
- metadata +1 -1
data/bin/test_gem
CHANGED
@@ -4,5 +4,19 @@ require 'test_gem'
|
|
4
4
|
|
5
5
|
puts "test_gem script executing"
|
6
6
|
puts ARGV[0]
|
7
|
+
puts "Here!"
|
8
|
+
if ARGV[0] == "--init"
|
9
|
+
TestGem::init_config
|
10
|
+
else
|
11
|
+
begin
|
12
|
+
counter = 1
|
13
|
+
file = File.new("program.config", "r")
|
14
|
+
while (line = file.gets)
|
15
|
+
puts "#{counter}: #{line}"
|
16
|
+
counter += 1
|
17
|
+
end
|
18
|
+
rescue
|
19
|
+
raise TestGem::MyFile.MyError
|
20
|
+
end
|
21
|
+
end
|
7
22
|
|
8
|
-
puts TestGem::MyFile.first( ARGV[0] )
|
data/lib/test_gem.rb
CHANGED
@@ -2,12 +2,30 @@ $LOAD_PATH.unshift File.expand_path("../test_gem", __FILE__)
|
|
2
2
|
|
3
3
|
require 'version'
|
4
4
|
require 'hello'
|
5
|
+
require 'yaml'
|
5
6
|
|
6
7
|
module TestGem
|
7
8
|
|
9
|
+
@default_file_name
|
10
|
+
@supported_types
|
11
|
+
|
8
12
|
puts "module TestGem defined"
|
9
13
|
|
10
|
-
|
14
|
+
def self.init_config
|
15
|
+
data = {:default_file_name => "default.txt",
|
16
|
+
:supported_types => [:key => 'txt', :key2 => 'pdf']}
|
17
|
+
|
18
|
+
File.open('program.config', "w") do |f|
|
19
|
+
YAML.dump(data, f)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class MyFile
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
default_file_name = 'default'
|
27
|
+
supported_types = ['txt', 'pdf']
|
28
|
+
end
|
11
29
|
|
12
30
|
def self.first(filename)
|
13
31
|
File.open(filename, "r") {|f| f.readline}
|
@@ -16,5 +34,9 @@ module TestGem
|
|
16
34
|
def self.last(filename)
|
17
35
|
File.open(filename, "r")[-1]
|
18
36
|
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class MyError < StandardError
|
40
|
+
puts "Standard Error"
|
19
41
|
end
|
20
42
|
end
|
data/lib/test_gem/version.rb
CHANGED