framer 0.0.1
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/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +53 -0
- data/Rakefile +6 -0
- data/bin/framer +4 -0
- data/framer.gemspec +24 -0
- data/lib/framer.rb +13 -0
- data/lib/framer/builder.rb +23 -0
- data/lib/framer/cli.rb +15 -0
- data/lib/framer/parser.rb +12 -0
- data/lib/framer/version.rb +3 -0
- data/spec/framer/builder_spec.rb +26 -0
- data/spec/framer/parser_spec.rb +14 -0
- data/spec/framer_spec.rb +12 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/framer_example.yml +10 -0
- metadata +96 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Andrew Hare
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Framer
|
|
2
|
+
|
|
3
|
+
Framer creates directory structures from YAML files.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem "framer"
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install framer
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Framer is designed to take a YAML file and turn it into a directory structure on disk.
|
|
22
|
+
|
|
23
|
+
First you need to have a YAML file that describes your directory structure:
|
|
24
|
+
|
|
25
|
+
# framer.yml
|
|
26
|
+
---
|
|
27
|
+
:root1:
|
|
28
|
+
:root1_dir1:
|
|
29
|
+
:root1_dir1_sub1: {}
|
|
30
|
+
:root1_dir2: {}
|
|
31
|
+
:root2:
|
|
32
|
+
:root2_dir1: {}
|
|
33
|
+
:root2_dir2:
|
|
34
|
+
:root2_dir2_sub1: {}
|
|
35
|
+
:root2_dir2_sub2: {}
|
|
36
|
+
|
|
37
|
+
Then you can use either the API to generate the structure:
|
|
38
|
+
|
|
39
|
+
Framer.frame "path_to_yaml_file", "path_to_output_dir"
|
|
40
|
+
|
|
41
|
+
Or you can generate the same structure from the comand line:
|
|
42
|
+
|
|
43
|
+
$ framer frame "path_to_yaml_file", "path_to_output_dir"
|
|
44
|
+
|
|
45
|
+
*NOTE:* You can execute `$ framer frame` without any arguments and Framer will look for a "framer.yml" in the current directory and build the output in the current directory by default.
|
|
46
|
+
|
|
47
|
+
## Contributing
|
|
48
|
+
|
|
49
|
+
1. Fork it
|
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/framer
ADDED
data/framer.gemspec
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "framer/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = "framer"
|
|
8
|
+
s.version = Framer::VERSION
|
|
9
|
+
s.authors = "Andrew Hare"
|
|
10
|
+
s.email = ""
|
|
11
|
+
s.description = "A simple gem for creating directory structures from YAML files."
|
|
12
|
+
s.summary = "A simple gem for creating directory structures from YAML files."
|
|
13
|
+
s.homepage = ""
|
|
14
|
+
s.license = "MIT"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split($/)
|
|
17
|
+
s.test_files = "spec"
|
|
18
|
+
s.require_paths = ["lib"]
|
|
19
|
+
s.executables = "framer"
|
|
20
|
+
|
|
21
|
+
s.add_dependency "thor"
|
|
22
|
+
|
|
23
|
+
s.add_development_dependency "rspec"
|
|
24
|
+
end
|
data/lib/framer.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "fileutils"
|
|
2
|
+
|
|
3
|
+
module Framer
|
|
4
|
+
class Builder
|
|
5
|
+
attr_reader :dirs
|
|
6
|
+
|
|
7
|
+
def initialize(path, tree)
|
|
8
|
+
@dirs = get_dirs(path, tree)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def build
|
|
12
|
+
FileUtils.mkdir_p @dirs
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_dirs(root, tree)
|
|
16
|
+
tree.map do |key, value|
|
|
17
|
+
new_root = File.join(root, key.to_s)
|
|
18
|
+
[new_root, get_dirs(new_root, value)]
|
|
19
|
+
end.flatten
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
data/lib/framer/cli.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "thor"
|
|
2
|
+
require "framer"
|
|
3
|
+
|
|
4
|
+
module Framer
|
|
5
|
+
class CLI < Thor
|
|
6
|
+
|
|
7
|
+
desc "frame YAML_PATH, BUILD_PATH", "Build the frame."
|
|
8
|
+
method_option :yaml_path, default: "framer.yml"
|
|
9
|
+
method_option :build_path, default: "./"
|
|
10
|
+
def frame(yaml_path, build_path)
|
|
11
|
+
Framer.frame yaml_path, build_path
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "fileutils"
|
|
3
|
+
|
|
4
|
+
describe Framer::Builder do
|
|
5
|
+
|
|
6
|
+
def directory_hash(main_path)
|
|
7
|
+
all = Dir.glob(main_path + '/**/*')
|
|
8
|
+
dirs = all.select {|f| File.directory?(f) }
|
|
9
|
+
parts = dirs.map {|path| path.sub(main_path+ "/", "").split("/") }
|
|
10
|
+
parts.reduce({}) {|acc, path_parts|
|
|
11
|
+
path_parts.reduce(acc) do |acc2, dir|
|
|
12
|
+
acc2[dir.to_sym] ||= {}
|
|
13
|
+
end
|
|
14
|
+
acc
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "#build" do
|
|
19
|
+
it "should build the tree" do
|
|
20
|
+
builder = Framer::Builder.new(@build_path, @tree)
|
|
21
|
+
builder.build
|
|
22
|
+
directory_hash(@build_path).should eq @tree
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
data/spec/framer_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "framer"
|
|
3
|
+
|
|
4
|
+
RSpec.configure do |config|
|
|
5
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
6
|
+
config.run_all_when_everything_filtered = true
|
|
7
|
+
config.filter_run :focus
|
|
8
|
+
config.order = "random"
|
|
9
|
+
|
|
10
|
+
config.before :each do
|
|
11
|
+
@build_path = "tmp/build"
|
|
12
|
+
@yaml_path = "tmp/framer_example.yml"
|
|
13
|
+
@tree = {
|
|
14
|
+
root1: {
|
|
15
|
+
root1_dir1: {
|
|
16
|
+
root1_dir1_sub1: {}
|
|
17
|
+
},
|
|
18
|
+
root1_dir2: {}
|
|
19
|
+
},
|
|
20
|
+
root2: {
|
|
21
|
+
root2_dir1: {},
|
|
22
|
+
root2_dir2: {
|
|
23
|
+
root2_dir2_sub1: {},
|
|
24
|
+
root2_dir2_sub2: {}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
FileUtils.remove_dir "tmp", true
|
|
29
|
+
FileUtils.mkdir_p @build_path
|
|
30
|
+
IO.write(@yaml_path, YAML.dump(@tree))
|
|
31
|
+
end
|
|
32
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: framer
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Andrew Hare
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-01-20 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: thor
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: rspec
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
description: A simple gem for creating directory structures from YAML files.
|
|
47
|
+
email: ''
|
|
48
|
+
executables:
|
|
49
|
+
- framer
|
|
50
|
+
extensions: []
|
|
51
|
+
extra_rdoc_files: []
|
|
52
|
+
files:
|
|
53
|
+
- .gitignore
|
|
54
|
+
- .rspec
|
|
55
|
+
- Gemfile
|
|
56
|
+
- LICENSE.txt
|
|
57
|
+
- README.md
|
|
58
|
+
- Rakefile
|
|
59
|
+
- bin/framer
|
|
60
|
+
- framer.gemspec
|
|
61
|
+
- lib/framer.rb
|
|
62
|
+
- lib/framer/builder.rb
|
|
63
|
+
- lib/framer/cli.rb
|
|
64
|
+
- lib/framer/parser.rb
|
|
65
|
+
- lib/framer/version.rb
|
|
66
|
+
- spec/framer/builder_spec.rb
|
|
67
|
+
- spec/framer/parser_spec.rb
|
|
68
|
+
- spec/framer_spec.rb
|
|
69
|
+
- spec/spec_helper.rb
|
|
70
|
+
- spec/support/framer_example.yml
|
|
71
|
+
homepage: ''
|
|
72
|
+
licenses:
|
|
73
|
+
- MIT
|
|
74
|
+
post_install_message:
|
|
75
|
+
rdoc_options: []
|
|
76
|
+
require_paths:
|
|
77
|
+
- lib
|
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
|
+
none: false
|
|
80
|
+
requirements:
|
|
81
|
+
- - ! '>='
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0'
|
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
|
+
none: false
|
|
86
|
+
requirements:
|
|
87
|
+
- - ! '>='
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
requirements: []
|
|
91
|
+
rubyforge_project:
|
|
92
|
+
rubygems_version: 1.8.23
|
|
93
|
+
signing_key:
|
|
94
|
+
specification_version: 3
|
|
95
|
+
summary: A simple gem for creating directory structures from YAML files.
|
|
96
|
+
test_files: []
|