trekky 0.0.7.rc2 → 0.0.7.rc3
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.
- checksums.yaml +4 -4
- data/lib/trekky.rb +1 -0
- data/lib/trekky/context.rb +11 -1
- data/lib/trekky/data.rb +56 -0
- data/lib/trekky/source.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b1b9aec1a5d263db19517c2dbae4a6b8860c16fb
|
|
4
|
+
data.tar.gz: eb8d218d698a83f6def8f82c8769c6151791a063
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 439ce4280105f0ce47a4e2aa070f9c23dacd60b1a768282c972930e9e29b2def2a49d1a45d7f61ccbde3c3d2701993070bda890fae311626155a86e932c4bf44
|
|
7
|
+
data.tar.gz: fbcd0e90819f05fdde98d4f42ca404ad1b076d34c4c21feb3e317cc9e82cb547dd76f4384adb1841875a53d236045350a1395405c06c54c276ac06ce1b6a7276
|
data/lib/trekky.rb
CHANGED
data/lib/trekky/context.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
require_relative 'data'
|
|
1
2
|
require_relative 'haml_source'
|
|
2
|
-
require_relative 'static_source'
|
|
3
3
|
require_relative 'sass_source'
|
|
4
|
+
require_relative 'static_source'
|
|
4
5
|
|
|
5
6
|
class Trekky
|
|
6
7
|
class Context
|
|
@@ -29,6 +30,10 @@ class Trekky
|
|
|
29
30
|
partials.find {|p| p.path == File.join(source_dir, name)}
|
|
30
31
|
end
|
|
31
32
|
|
|
33
|
+
def data
|
|
34
|
+
@data ||= Data.new(data_path)
|
|
35
|
+
end
|
|
36
|
+
|
|
32
37
|
private
|
|
33
38
|
|
|
34
39
|
def build
|
|
@@ -65,5 +70,10 @@ class Trekky
|
|
|
65
70
|
{ sass: SassSource, haml: HamlSource }
|
|
66
71
|
end
|
|
67
72
|
|
|
73
|
+
def data_path
|
|
74
|
+
File.join(Dir.pwd, 'data')
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
|
|
68
78
|
end
|
|
69
79
|
end
|
data/lib/trekky/data.rb
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'ostruct'
|
|
2
|
+
require 'yaml'
|
|
3
|
+
|
|
4
|
+
class Trekky
|
|
5
|
+
class Data
|
|
6
|
+
|
|
7
|
+
class DeepStruct < OpenStruct
|
|
8
|
+
|
|
9
|
+
def initialize(hash=nil)
|
|
10
|
+
@table = {}
|
|
11
|
+
@hash_table = {}
|
|
12
|
+
|
|
13
|
+
if hash
|
|
14
|
+
hash.each do |k,v|
|
|
15
|
+
@table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
|
|
16
|
+
@hash_table[k.to_sym] = v
|
|
17
|
+
|
|
18
|
+
new_ostruct_member(k)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def to_h
|
|
24
|
+
@hash_table
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def initialize(path)
|
|
30
|
+
@path = path
|
|
31
|
+
@data = Hash.new
|
|
32
|
+
super()
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def method_missing(method_name, *args)
|
|
36
|
+
if @data.has_key?(method_name)
|
|
37
|
+
@data[method_name]
|
|
38
|
+
else
|
|
39
|
+
@data[method_name] = load_data(method_name)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def load_data(name)
|
|
46
|
+
yaml = YAML.load_file(File.join(@path, "#{name}.yml"))
|
|
47
|
+
if yaml.respond_to?(:each)
|
|
48
|
+
yaml.map { |y| DeepStruct.new(y) }
|
|
49
|
+
else
|
|
50
|
+
DeepStruct.new(yaml)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
data/lib/trekky/source.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trekky
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.7.
|
|
4
|
+
version: 0.0.7.rc3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lucas Florio
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-09-
|
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: clap
|
|
@@ -78,6 +78,7 @@ files:
|
|
|
78
78
|
- bin/trekky
|
|
79
79
|
- lib/trekky.rb
|
|
80
80
|
- lib/trekky/context.rb
|
|
81
|
+
- lib/trekky/data.rb
|
|
81
82
|
- lib/trekky/haml_source.rb
|
|
82
83
|
- lib/trekky/sass_source.rb
|
|
83
84
|
- lib/trekky/source.rb
|