crafti 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff0eda4f4fd8636e4ec38766b03079b63898f01b
4
- data.tar.gz: f4da25cc34eee8f28b5f6119074b82920fba12f1
3
+ metadata.gz: fcfd788057538060a82edf6c0e5f3f30ddfd4c1b
4
+ data.tar.gz: 92857272a5dadcc3ad4be05c5c5bc523ede00634
5
5
  SHA512:
6
- metadata.gz: 0bf2c21f73e289ee09df142f88e3208ee3f77e9ec30cf4a036594b0381a8b0d59ee8a869237f8236b45bc5d84738bf35a97727e9e2e29421c4f7e4abb0831234
7
- data.tar.gz: 9e71237a6195fd474687adb151935e115ffc5a3420caa292f6ff0a3ddf6c4cb8678113d05407e7474b257566ba5b13f03efbab9068bbd842f7e69ec34ed7c467
6
+ metadata.gz: 2fed4deb18bb7032bdc8e390520cb1a9ca98bdb6b15c9de8b78d6e21a8f10c3471735f0bee31cb57df4be226bc1c1a1c6c848c5c88b22de5d78415d79bdd1e01
7
+ data.tar.gz: b83a950a1faa53111a3df39b8429a791a9085ab44c846b8f202cb38632e144002c7086649f1cfa5fe88c3bebf0b06ab09eb530e4e8e96ffa297a1ab0c613c7fc
data/bin/crafti CHANGED
@@ -7,7 +7,7 @@ require 'crafti'
7
7
  options = Crafti::CLI.parse(ARGV)
8
8
 
9
9
  if options.event == "generate"
10
- Crafti::FileReader.generate(options.template_path)
10
+ Crafti::FileReader.generate(options.template_path, options.name)
11
11
  else
12
12
  puts "That command is not supported."
13
13
  exit
@@ -15,7 +15,10 @@ end
15
15
 
16
16
  # require 'pathname'
17
17
  # path = Pathname.new(options.template_path).expand_path
18
+ # puts "Options:\n"
19
+ # puts options.inspect
18
20
  # puts "Values:\n"
19
21
  # puts "path: #{path.to_s}"
22
+ # puts "Name: #{options.name}"
20
23
  # puts "\nContent:\n#{path.read}"
21
24
 
data/lib/crafti/cli.rb CHANGED
@@ -12,10 +12,16 @@ module Crafti
12
12
 
13
13
  *** Crafti - Application Generation Simplified ***
14
14
 
15
- Usage: crafti generate -m ~/path/to/template.rb
15
+ Usage: crafti generate -n appname -m ~/path/to/template.rb
16
+
16
17
  TEXT
17
18
  opts.separator ""
18
19
 
20
+ opts.on("-n", "--name NAME", "Name of the application you're creating. This overrides the name in the app template.") do |name|
21
+ name = nil if name.nil? || name == ''
22
+ options.name = name
23
+ end
24
+
19
25
  opts.on("-t", "--template PATH", "Path to the application template") do |path|
20
26
  options.template_path = path
21
27
  end
@@ -1,7 +1,7 @@
1
1
  module Crafti
2
2
  MAJOR = 0
3
3
  MINOR = 0
4
- PATCH = 15
4
+ PATCH = 16
5
5
 
6
6
  def self.version
7
7
  [
data/lib/crafti.rb CHANGED
@@ -86,20 +86,28 @@ module Crafti
86
86
  end
87
87
  end
88
88
 
89
+ module AppName
90
+ def self.name(appname = nil)
91
+ @name ||= appname
92
+ end
93
+ end
94
+
89
95
  class FileReader
90
- def self.generate(file)
91
- app = new(file)
96
+ def self.generate(file, app_name = nil)
97
+ app = new(file, app_name)
92
98
  app.evaluate
93
99
  end
94
100
 
95
101
  attr_reader :content
96
- def initialize(file)
97
- @content = ::Pathname.new(file.to_s).expand_path.read
102
+ def initialize(file, app_name = nil)
103
+ ::Crafti::AppName.name(app_name)
104
+ @content = ::Pathname.new(file.to_s).expand_path.read
98
105
  end
99
106
 
100
107
  def evaluate
101
108
  klass = Class.new do
102
109
  Kernel.extend(Crafti::KernelExtension)
110
+ Kernel.extend(Crafti::AppName)
103
111
  def self.execute(string)
104
112
  eval string
105
113
  end
@@ -113,7 +121,7 @@ module Crafti
113
121
  include FileUtilsExtension
114
122
 
115
123
  def self.root(appname, &block)
116
- app = new(appname)
124
+ app = new((::Crafti::AppName.name || appname))
117
125
  app.create_root_directory
118
126
  app.evaluate(&block) if block_given?
119
127
  end
@@ -0,0 +1,8 @@
1
+ root "appname" do
2
+ mkdir "log"
3
+ mkdir "test"
4
+ mkdir "config"
5
+ touch "Rakefile"
6
+ touch "Guardfile"
7
+ touch "test/test_helper.rb"
8
+ end
data/test/dsl_test.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+ require_relative '../lib/crafti'
3
+
4
+ class DSLTest < Minitest::Test
5
+ def template_file
6
+ Pathname.new(__dir__).expand_path.join("assets/app_template.rb")
7
+ end
8
+
9
+ def test_file_evaluation
10
+ file = Crafti::FileReader.new(template_file)
11
+ file.evaluate
12
+
13
+ assert File.exists?("appname")
14
+ FileUtils.rm_rf("appname")
15
+ refute File.exists?("appname")
16
+ end
17
+ end
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.15
4
+ version: 0.0.16
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-10 00:00:00.000000000 Z
11
+ date: 2014-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,9 +72,10 @@ files:
72
72
  - lib/crafti/project.rb
73
73
  - lib/crafti/version.rb
74
74
  - spike.rb
75
- - test/assets/dsl_test.rb
75
+ - test/assets/app_template.rb
76
76
  - test/assets/test_helper.rb.erb
77
77
  - test/crafti_test.rb
78
+ - test/dsl_test.rb
78
79
  - test/test_helper.rb
79
80
  homepage: ''
80
81
  licenses:
@@ -101,7 +102,8 @@ signing_key:
101
102
  specification_version: 4
102
103
  summary: Generate directories and files with/out templates.
103
104
  test_files:
104
- - test/assets/dsl_test.rb
105
+ - test/assets/app_template.rb
105
106
  - test/assets/test_helper.rb.erb
106
107
  - test/crafti_test.rb
108
+ - test/dsl_test.rb
107
109
  - test/test_helper.rb
@@ -1,24 +0,0 @@
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