chrislee_test_gem 0.0.4 → 0.0.5pre
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 +6 -0
- data/lib/test_gem/myfile.rb +10 -2
- data/lib/test_gem/version.rb +1 -1
- data/lib/test_gem.rb +10 -1
- metadata +4 -4
data/bin/test_gem
CHANGED
@@ -6,9 +6,15 @@ when "first"
|
|
6
6
|
puts TestGem::MyFile.first(ARGV[1])
|
7
7
|
when "last"
|
8
8
|
puts TestGem::MyFile.last(ARGV[1])
|
9
|
+
when "--init"
|
10
|
+
TestGem.init_config
|
11
|
+
when nil
|
12
|
+
puts TestGem.configure.to_s
|
9
13
|
else
|
10
14
|
puts "test_gem can return the first or last line of a text file"
|
15
|
+
puts "--init will initialize the default config.yml"
|
11
16
|
puts "Usage:"
|
12
17
|
puts "test_gem first <file location>"
|
13
18
|
puts "test_gem last <file location>"
|
19
|
+
puts "test_gem --init"
|
14
20
|
end
|
data/lib/test_gem/myfile.rb
CHANGED
@@ -6,11 +6,19 @@ module TestGem
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.first file_location=@file_location
|
9
|
-
File.
|
9
|
+
if File.exist?(file_location)
|
10
|
+
File.open(file_location, "r"){|f| f.readlines[0].chomp}
|
11
|
+
else
|
12
|
+
raise RuntimeError, 'File Does not exist!'
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def self.last file_location=@file_location
|
13
|
-
File.
|
17
|
+
if File.exist?(file_location)
|
18
|
+
File.open(file_location,"r"){|f| f.readlines.last.chomp}
|
19
|
+
else
|
20
|
+
raise RuntimeError, 'File Does not exist!'
|
21
|
+
end
|
14
22
|
end
|
15
23
|
|
16
24
|
end
|
data/lib/test_gem/version.rb
CHANGED
data/lib/test_gem.rb
CHANGED
@@ -3,8 +3,17 @@ $LOAD_PATH.unshift File.expand_path("../test_gem", __FILE__)
|
|
3
3
|
require 'version'
|
4
4
|
require 'hello'
|
5
5
|
require 'myfile'
|
6
|
-
|
6
|
+
require 'yaml'
|
7
7
|
module TestGem
|
8
8
|
|
9
|
+
def self.init_config
|
10
|
+
def_config = { 'default_file_name' => 'default_file.txt', 'supported_types' => [ 'txt', 'pdf' ]}
|
11
|
+
File.open("./config.yml", "w") do |file|
|
12
|
+
file.write(def_config.to_yaml)
|
13
|
+
end
|
14
|
+
end
|
9
15
|
|
16
|
+
def self.configure
|
17
|
+
YAML::load( File.open("./config.yml"))
|
18
|
+
end
|
10
19
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chrislee_test_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.5pre
|
5
|
+
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Chris Lee
|
@@ -38,9 +38,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- - ! '
|
41
|
+
- - ! '>'
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 1.3.1
|
44
44
|
requirements: []
|
45
45
|
rubyforge_project:
|
46
46
|
rubygems_version: 1.8.24
|