hola-leco 0.0.10 → 0.0.11

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hola-leco/util.rb +37 -0
  3. data/lib/hola-leco.rb +16 -10
  4. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa1909cd6c4b7d54776300c913ba6e3965485bc9
4
- data.tar.gz: 72b1900707d602e8c1941d13c85854811049bffb
3
+ metadata.gz: 6eea5b8a2ebf4f5eddbe5c35b63b50c2732484de
4
+ data.tar.gz: 6d0e9ce3bdb03f0e0c1abacee28c304e097ace1a
5
5
  SHA512:
6
- metadata.gz: 51c384af4884e191dcc1d7f8231b8b51741495c0c76a7c5c42c32fd0c678a0d1a0de13377892f5cfe17d9828373be1a0c0ce58e89124aad0f4338a5b6c9cb649
7
- data.tar.gz: d4398efa84431614851d6ce12cc1cfb08f2935b78c0c0e22b28df34f4ecbee16b73ff8063a61720fef81f656dd95fb3602ed000feaeadb6d781d24776dd071d6
6
+ metadata.gz: 26791da6455db60f9721564a80086f73257d977cf9fc845f1ec786dc268bbc407d22f89fb6cda7b402bf62968837fd206497635c1e5f82e09aa9df658cf33e41
7
+ data.tar.gz: 84bbf8db29a40134dcdf6f6f1c69be5a7af891aaacffe470960a2f1e80d157e7391ae0db4774143cb1be5239fbfde1222c2beadf010812d7d3dfd5bc9db0caf8
@@ -0,0 +1,37 @@
1
+ # module Hola
2
+ module Util
3
+ extend self
4
+ def get_options
5
+ config_dir = File.join(".", "config")
6
+ config_file_path = nil
7
+ %w[trackers.yml trackers.yml.erb].each do |config_file|
8
+ path = File.join(config_dir, config_file)
9
+ config_file_path ||= path if File.exist?(path)
10
+ end
11
+
12
+ opts = parse_config(config_file_path) if config_file_path
13
+ puts opts
14
+ opts
15
+ end
16
+
17
+ def parse_config(path)
18
+ opts = YAML.load(ERB.new(File.read(path)).result) || {}
19
+
20
+ if opts.respond_to? :deep_symbolize_keys!
21
+ opts.deep_symbolize_keys!
22
+ else
23
+ symbolize_keys_deep!(opts)
24
+ end
25
+
26
+ opts
27
+ end
28
+
29
+ def symbolize_keys_deep!(hash)
30
+ hash.keys.each do |k|
31
+ symkey = k.respond_to?(:to_sym) ? k.to_sym : k
32
+ hash[symkey] = hash.delete k
33
+ symbolize_keys_deep! hash[symkey] if hash[symkey].is_a? Hash
34
+ end
35
+ end
36
+ end
37
+ # end
data/lib/hola-leco.rb CHANGED
@@ -1,16 +1,22 @@
1
1
  require 'bcrypt'
2
-
3
- # The main Hola driver
2
+ require "fileutils"
3
+ require "erb"
4
+ require "yaml"
5
+ require "hola-leco/util"
4
6
 
5
7
  class Hola
6
- # Say hi to the world!
7
- #
8
- # Example:
9
- # >> Hola.hi("spanish")
10
- # => hola mundo
11
- #
12
- # Arguments:
13
- # language: (String)
8
+ include Util
9
+ # include Singleton
10
+ @@options = nil
11
+
12
+ def self.greet(name)
13
+ puts "hello #{name}"
14
+ end
15
+
16
+ def self.options
17
+ @@options = Util.get_options if !@@options
18
+ @@options
19
+ end
14
20
 
15
21
  def self.hi(language = "english")
16
22
  my_password = BCrypt::Password.create("my password")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hola-leco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Quaranto
@@ -66,6 +66,7 @@ extra_rdoc_files: []
66
66
  files:
67
67
  - lib/hola-leco.rb
68
68
  - lib/hola-leco/translator.rb
69
+ - lib/hola-leco/util.rb
69
70
  homepage: https://rubygems.org/gems/hola
70
71
  licenses:
71
72
  - MIT