Class: Rag

Inherits:
Thor show all
Includes:
Thor::Actions
Defined in:
lib/rag.rb,
lib/rag.rb,
lib/rag/ui.rb,
lib/rag/aur.rb,
lib/rag/new.rb,
lib/rag/ruby.rb,
lib/rag/util.rb,
lib/rag/version.rb,
lib/rag/ruby/doc.rb,
lib/rag/ruby/gem.rb,
lib/rag/util/erb.rb,
lib/rag/ruby/test.rb

Overview

Project Template DSL

Defined Under Namespace

Modules: Util Classes: DSL, Project, Template, UI

Constant Summary collapse

Error =
Class.new Exception
ENoTemplate =
Class.new Error
RagError =
Class.new Exception
Rc =
Optimism.require "rag/rc", "~/.ragrc"
VERSION =
"1.3.0"

Class Attribute Summary collapse

Instance Method Summary collapse

Methods included from Thor::Actions

#directory2, #template2

Class Attribute Details

.uiObject

Returns the value of attribute ui.



27
28
29
# File 'lib/rag.rb', line 27

def ui
  @ui
end

Instance Method Details

#buildObject



20
21
22
# File 'lib/rag/ruby/gem.rb', line 20

def build
	system "gem build #{Rc.o.project}.gemspec", :verbose => true
end

#docObject



3
4
5
# File 'lib/rag/ruby/doc.rb', line 3

def doc
	system "yard server --reload", :verbose => true
end

#installObject



12
13
14
15
16
17
# File 'lib/rag/ruby/gem.rb', line 12

def install
	sudo = Process.uid == 0 ? "" : "sudo"
	system "gem build #{Rc.o.project}.gemspec", :verbose => true
	system "#{sudo} gem install #{Rc.o.project}-#{Rc.o.version}.gem", :verbose => true
	Pa.rm "#{Rc.o.project}-#{Rc.o.version}.gem", :verbose => true
end

#new(template_name, app_path) ⇒ Object

Raises:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/rag.rb', line 51

def new(template_name, app_path)
   o = options.dup
   template_name = template_name.dup
   app_path = Pa(app_path.dup)
   require "rag/new"
   
   template_name, *exts = template_name.split(".")
   template_dir = o[:dir] || Rc.p.home
   exts = exts.empty? ? ["default"] : exts
   root = Pa("#{template_dir}/#{template_name}").a
   raise ENoTemplate, "can't find '#{template_name}' at #{template_dir}" unless root.exists?

   app_path = Pa.absolute(app_path)
   o["name"] ||= app_path.fname 
   o["klass"] ||= o["name"].classify
   Rc << {
     template_name: template_name,
     app_path: app_path,
     project: o["name"],
     klass: o["klass"],
     exts: exts,
     ext: exts[0]
   }

   Pa.mkdir(app_path)
   Pa.cd(app_path)

   source = File.read("#{root}/Buildfile")
   DSL.source_root root.p
   dsl = DSL.new(template_name, app_path, o)
   dsl.destination_root = ""
   dsl.instance_eval source
end

#releaseObject



2
3
4
# File 'lib/rag/aur.rb', line 2

def release
  `aurploader pkg.`
end