crafti 0.0.1 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/crafti +12 -0
- data/{craft.gemspec → crafti.gemspec} +2 -2
- data/lib/crafti/cli.rb +33 -0
- data/lib/crafti/project.rb +3 -0
- data/lib/{craft → crafti}/version.rb +3 -3
- data/lib/{craft.rb → crafti.rb} +27 -4
- data/test/assets/dsl_test.rb +24 -0
- data/test/{craft_test.rb → crafti_test.rb} +13 -13
- metadata +13 -10
- data/bin/craft +0 -11
- data/lib/craft/project.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22c3ba1c7923cb40af5cebe34396d0a0a7ccb9c2
|
4
|
+
data.tar.gz: 99c8e9dc8640937722e6670201415e78488a3646
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 540cc1b56feb6ee3b42813ac1e6c2539ef8ae18e05f40c335e79516802d46526c0ae7e10eacee6dcebcdc1c737dd5766ab3101c93397fb1629cf7ee4574d1346
|
7
|
+
data.tar.gz: 62bb4ed855af1b8e26db6ecd73afcb3e5ef6e9fde4f615e4ee4e77bc373211f18efa2d8615eebac176c1ae0ccff1d1379d492859a0a106a8b802e20c12877cde
|
data/bin/crafti
ADDED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'crafti/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "crafti"
|
8
|
-
spec.version =
|
8
|
+
spec.version = Crafti.version
|
9
9
|
spec.authors = ["Robert Evans"]
|
10
10
|
spec.email = ["robert@codewranglers.org"]
|
11
11
|
spec.summary = %q{Generate directories and files with/out templates.}
|
data/lib/crafti/cli.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
module Crafti
|
5
|
+
class CLI
|
6
|
+
def self.parse(args)
|
7
|
+
options = OpenStruct.new
|
8
|
+
options.event = args.reverse.pop
|
9
|
+
|
10
|
+
opt_parser = OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: crafti generate -m ~/path/to/template.rb"
|
12
|
+
opts.separator ""
|
13
|
+
|
14
|
+
opts.on("-m", "--template", "Path to the application template") do |template|
|
15
|
+
options.template_path = template
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on_tail("-h", "--help", "Help message") do
|
19
|
+
puts opts
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on_tail("-v", "--version", "Show version number") do
|
24
|
+
puts "Crafti Version #{Crafti.version}"
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
opt_parser.parse!(args)
|
30
|
+
options
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/{craft.rb → crafti.rb}
RENAMED
@@ -1,16 +1,17 @@
|
|
1
|
-
require "
|
1
|
+
require "crafti/version"
|
2
|
+
require "crafti/cli"
|
2
3
|
|
3
4
|
require 'fileutils'
|
4
5
|
require 'pathname'
|
5
6
|
require 'erb'
|
6
7
|
require 'ostruct'
|
7
8
|
|
8
|
-
module
|
9
|
+
module Crafti
|
9
10
|
module KernelExtension
|
10
11
|
def self.extended(mod)
|
11
12
|
mod.module_eval do
|
12
13
|
def root(name, &block)
|
13
|
-
::
|
14
|
+
::Crafti::Root.root(name, &block)
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
@@ -82,6 +83,28 @@ module Craft
|
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
86
|
+
class FileReader
|
87
|
+
def self.read(file)
|
88
|
+
app = new(file)
|
89
|
+
end
|
90
|
+
|
91
|
+
attr_reader :content
|
92
|
+
def initialize(file)
|
93
|
+
@content = ::Pathname.new(file).expand_path.read
|
94
|
+
end
|
95
|
+
|
96
|
+
def evaluate
|
97
|
+
klass = Class.new do
|
98
|
+
Kernel.extend(Crafti::KernelExtension)
|
99
|
+
def self.execute(string)
|
100
|
+
eval string
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
klass.execute(content)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
85
108
|
class Root
|
86
109
|
include FileUtilsExtension
|
87
110
|
|
@@ -107,4 +130,4 @@ module Craft
|
|
107
130
|
end
|
108
131
|
|
109
132
|
end
|
110
|
-
end
|
133
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require_relative '../../lib/crafti'
|
3
|
+
|
4
|
+
CONTENT = <<-RUBY
|
5
|
+
root "appname" do
|
6
|
+
mkdir "log"
|
7
|
+
mkdir "test"
|
8
|
+
mkdir "config"
|
9
|
+
touch "Rakefile"
|
10
|
+
touch "Guardfile"
|
11
|
+
touch "test/test_helper.rb"
|
12
|
+
end
|
13
|
+
RUBY
|
14
|
+
|
15
|
+
class DSLTest < Minitest::Test
|
16
|
+
def test_file_evaluation
|
17
|
+
file = Crafti::FileReader.new(CONTENT)
|
18
|
+
file.evaluate
|
19
|
+
|
20
|
+
assert File.exists?("appname")
|
21
|
+
FileUtils.rm_rf("appname")
|
22
|
+
refute File.exists?("appname")
|
23
|
+
end
|
24
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require 'minitest/pride'
|
3
3
|
|
4
|
-
require_relative '../lib/
|
4
|
+
require_relative '../lib/crafti'
|
5
5
|
|
6
|
-
module
|
6
|
+
module Crafti
|
7
7
|
class RootTest < ::Minitest::Test
|
8
8
|
def test_create_root_directory
|
9
|
-
::
|
9
|
+
::Crafti::Root.root("appname")
|
10
10
|
|
11
11
|
assert ::File.exists?("appname")
|
12
12
|
|
@@ -15,7 +15,7 @@ module Craft
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_creating_subdirectories
|
18
|
-
::
|
18
|
+
::Crafti::Root.root("appname") do
|
19
19
|
mkdir "config"
|
20
20
|
mkdir "log"
|
21
21
|
mkdir "test"
|
@@ -31,7 +31,7 @@ module Craft
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_creating_multiple_subdirectories
|
34
|
-
::
|
34
|
+
::Crafti::Root.root("appname") do
|
35
35
|
mkdirs "config", "log", "test", mode: 0700
|
36
36
|
end
|
37
37
|
|
@@ -45,7 +45,7 @@ module Craft
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_touching_a_file
|
48
|
-
::
|
48
|
+
::Crafti::Root.root("appname") do
|
49
49
|
touch "Readme.mkd"
|
50
50
|
end
|
51
51
|
|
@@ -57,7 +57,7 @@ module Craft
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_touching_files
|
60
|
-
::
|
60
|
+
::Crafti::Root.root("appname") do
|
61
61
|
touch "Readme.mkd", "Rakefile", "Guardfile"
|
62
62
|
end
|
63
63
|
|
@@ -71,7 +71,7 @@ module Craft
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_copying_files
|
74
|
-
::
|
74
|
+
::Crafti::Root.root("appname") do
|
75
75
|
mkdir "test"
|
76
76
|
copy Pathname.new(__dir__).join("test_helper.rb"), "test"
|
77
77
|
end
|
@@ -85,7 +85,7 @@ module Craft
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_chmod
|
88
|
-
::
|
88
|
+
::Crafti::Root.root("appname") do
|
89
89
|
mkdir "test"
|
90
90
|
copy ::Pathname.new(__dir__).join("test_helper.rb"), "test"
|
91
91
|
chmod 0777, "test/test_helper.rb"
|
@@ -104,7 +104,7 @@ module Craft
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def test_chmod_r
|
107
|
-
::
|
107
|
+
::Crafti::Root.root("appname") do
|
108
108
|
mkdir "test"
|
109
109
|
copy ::Pathname.new(__dir__).join("test_helper.rb"), "test"
|
110
110
|
chmod_r 0777, "test"
|
@@ -123,7 +123,7 @@ module Craft
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_run
|
126
|
-
::
|
126
|
+
::Crafti::Root.root("appname") do
|
127
127
|
run "mkdir foobar"
|
128
128
|
end
|
129
129
|
|
@@ -138,7 +138,7 @@ module Craft
|
|
138
138
|
# I'm keeping this here though, so we can test it when we want to.
|
139
139
|
#
|
140
140
|
# def test_sudo
|
141
|
-
# ::
|
141
|
+
# ::Crafti::Root.root("appname") do
|
142
142
|
# sudo "echo 'RACK_ENV=development' > .env"
|
143
143
|
# end
|
144
144
|
|
@@ -151,7 +151,7 @@ module Craft
|
|
151
151
|
# end
|
152
152
|
|
153
153
|
def test_template
|
154
|
-
::
|
154
|
+
::Crafti::Root.root("appname") do
|
155
155
|
mkdir "test"
|
156
156
|
template "test/test_helper.rb",
|
157
157
|
::Pathname.new(__dir__).
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crafti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,7 +56,7 @@ description: Generate directories and files with/out templates.
|
|
56
56
|
email:
|
57
57
|
- robert@codewranglers.org
|
58
58
|
executables:
|
59
|
-
-
|
59
|
+
- crafti
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
@@ -65,14 +65,16 @@ files:
|
|
65
65
|
- LICENSE.txt
|
66
66
|
- README.md
|
67
67
|
- Rakefile
|
68
|
-
- bin/
|
69
|
-
-
|
70
|
-
- lib/
|
71
|
-
- lib/
|
72
|
-
- lib/
|
68
|
+
- bin/crafti
|
69
|
+
- crafti.gemspec
|
70
|
+
- lib/crafti.rb
|
71
|
+
- lib/crafti/cli.rb
|
72
|
+
- lib/crafti/project.rb
|
73
|
+
- lib/crafti/version.rb
|
73
74
|
- spike.rb
|
75
|
+
- test/assets/dsl_test.rb
|
74
76
|
- test/assets/test_helper.rb.erb
|
75
|
-
- test/
|
77
|
+
- test/crafti_test.rb
|
76
78
|
- test/test_helper.rb
|
77
79
|
homepage: ''
|
78
80
|
licenses:
|
@@ -99,6 +101,7 @@ signing_key:
|
|
99
101
|
specification_version: 4
|
100
102
|
summary: Generate directories and files with/out templates.
|
101
103
|
test_files:
|
104
|
+
- test/assets/dsl_test.rb
|
102
105
|
- test/assets/test_helper.rb.erb
|
103
|
-
- test/
|
106
|
+
- test/crafti_test.rb
|
104
107
|
- test/test_helper.rb
|
data/bin/craft
DELETED
data/lib/craft/project.rb
DELETED