app_stack 1.2.1 → 1.3.0
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 +15 -0
- data/.app_stack.yml +14 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.md +14 -0
- data/app_stack.gemspec +1 -0
- data/bin/config_assets +3 -0
- data/bin/stackup +8 -0
- data/file.erb +0 -0
- data/lib/app_stack/cli_options.rb +52 -0
- data/lib/app_stack/copy_list_builder.rb +144 -0
- data/lib/app_stack/local_files_parser.rb +95 -0
- data/lib/app_stack/stack_app.rb +114 -0
- data/lib/app_stack/version.rb +1 -1
- data/lib/app_stack.rb +13 -22
- data/tags +45 -0
- metadata +16 -62
- data/doc/coverage/.last_run.json +0 -1
- data/doc/coverage/.resultset.json +0 -1
- data/doc/coverage/assets/0.7.1/application.css +0 -1110
- data/doc/coverage/assets/0.7.1/application.js +0 -626
- data/doc/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
- data/doc/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
- data/doc/coverage/assets/0.7.1/favicon_green.png +0 -0
- data/doc/coverage/assets/0.7.1/favicon_red.png +0 -0
- data/doc/coverage/assets/0.7.1/favicon_yellow.png +0 -0
- data/doc/coverage/assets/0.7.1/loading.gif +0 -0
- data/doc/coverage/assets/0.7.1/magnify.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/doc/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/doc/coverage/index.html +0 -2480
- data/lib/app_stack/config.rb +0 -132
data/lib/app_stack/config.rb
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
module AppStack
|
5
|
-
class ParseError < RuntimeError; end
|
6
|
-
|
7
|
-
# an object represent information from .app_stack.yml file
|
8
|
-
class Config
|
9
|
-
attr_reader :filename, :copy_list
|
10
|
-
|
11
|
-
def initialize(file)
|
12
|
-
@filename = File.expand_path(file)
|
13
|
-
yml = YAML.load(File.open(@filename, 'r:utf-8').read)
|
14
|
-
|
15
|
-
# default configuration, also restrict known keys and data type
|
16
|
-
@config = {
|
17
|
-
stack: [],
|
18
|
-
export: [],
|
19
|
-
exclude: [],
|
20
|
-
attrs: {},
|
21
|
-
stack_dir: '../',
|
22
|
-
tpl_ext: %w[.erb .haml .liquid]
|
23
|
-
}
|
24
|
-
|
25
|
-
# use yaml file to set configuration
|
26
|
-
yml.each do |k, v|
|
27
|
-
raise ParseError,
|
28
|
-
"unkown option `#{k}` in #{@filename}" unless @config[k.to_sym]
|
29
|
-
raise ParseError,
|
30
|
-
"'#{k}' must be a #{@config[k.to_sym].class.to_s}" unless
|
31
|
-
v.is_a?(@config[k.to_sym].class)
|
32
|
-
@config[k.to_sym] = v
|
33
|
-
end
|
34
|
-
|
35
|
-
# convert stack dir to relative path:
|
36
|
-
@config[:stack_dir] = File.expand_path(@config[:stack_dir],
|
37
|
-
File.dirname(@filename))
|
38
|
-
|
39
|
-
# define reader accessors:
|
40
|
-
@config.each do |k, v|
|
41
|
-
self.class.send(:define_method, k.to_sym) { v }
|
42
|
-
end
|
43
|
-
|
44
|
-
# copy list from merge's view point
|
45
|
-
@copy_list = {}
|
46
|
-
end
|
47
|
-
|
48
|
-
def directory
|
49
|
-
File.expand_path('../', filename)
|
50
|
-
end
|
51
|
-
|
52
|
-
# use the direct name of the config file as app name
|
53
|
-
def app_name
|
54
|
-
File.basename(File.dirname(File.expand_path(filename)))
|
55
|
-
end
|
56
|
-
|
57
|
-
def attr_vars
|
58
|
-
@config[:attrs]
|
59
|
-
end
|
60
|
-
|
61
|
-
# get export files list (copy_from => copy_to hash) for a specific group
|
62
|
-
def export_files(group = 'default')
|
63
|
-
@export_files ||= parse_export_files
|
64
|
-
group = 'default' if group.to_s == 'defaults' # back-compatibility
|
65
|
-
@export_files[group.to_s]
|
66
|
-
end
|
67
|
-
|
68
|
-
def exclude_files
|
69
|
-
@export_files ||= find_files(@config[:exclude], false)
|
70
|
-
end
|
71
|
-
|
72
|
-
def add_copy_list(fhsh)
|
73
|
-
if fhsh.is_a?(Hash)
|
74
|
-
fhsh.each do |fr, to|
|
75
|
-
fr = File.expand_path(fr, directory)
|
76
|
-
@copy_list[fr] = to
|
77
|
-
end
|
78
|
-
else
|
79
|
-
@copy_list.merge! export_files(fhsh) # the group's name
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
# get all exported files in groups
|
86
|
-
def parse_export_files
|
87
|
-
# 'file_group_name' => { copy_from => copy_to_base_name }
|
88
|
-
@export_files ||= {}
|
89
|
-
export.each do |p_list| # pattern list
|
90
|
-
if p_list.is_a?(Hash) # group, file list
|
91
|
-
p_list.each do |n, p|
|
92
|
-
@export_files[n] ||= {}
|
93
|
-
@export_files[n].merge! find_files(p)
|
94
|
-
end
|
95
|
-
else
|
96
|
-
@export_files['default'] ||= {}
|
97
|
-
@export_files['default'].merge! find_files(p_list)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
@export_files
|
101
|
-
end
|
102
|
-
|
103
|
-
# from file pattern to copy_from => copy_to (remove directory header) hash
|
104
|
-
def glob_files(dir, allow_hash)
|
105
|
-
fhsh = {}
|
106
|
-
if dir.is_a?(Hash)
|
107
|
-
raise 'Can not use hash here for ' + dir.keys.join.to_s + ' in file ' +
|
108
|
-
filename unless allow_hash
|
109
|
-
dir.each do |f, t|
|
110
|
-
t = '/' + t.gsub(/^\//, '')
|
111
|
-
fhsh[File.expand_path(f, directory)] = t
|
112
|
-
end
|
113
|
-
else
|
114
|
-
Dir[File.expand_path(dir, directory)].each do |f|
|
115
|
-
fhsh[f] = f.gsub(/^#{directory}/, '')
|
116
|
-
end
|
117
|
-
end
|
118
|
-
fhsh
|
119
|
-
end
|
120
|
-
|
121
|
-
# from array (or string) of file patterns, glob files and build a
|
122
|
-
# large array
|
123
|
-
def find_files(group, allow_hash = true)
|
124
|
-
group = [ group ] unless group.is_a?(Array)
|
125
|
-
fhsh = {}
|
126
|
-
group.each do |file_pattern|
|
127
|
-
fhsh.merge! glob_files(file_pattern, allow_hash)
|
128
|
-
end
|
129
|
-
fhsh
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|