Module: Drumherum
- Defined in:
- lib/drumherum/smart_init.rb
Overview
You set up your release info once in your Rakefile. Like this:
require 'drumherum'
smart_init
require 'version'
require 'yard'
require 'drumherum/rake'
YARD::Rake::YardocTask.new
Drumherum.github_username = 'your_user_name'
smart_init detects your root directory and sets up the projectname and all other stuff.
Set this up in your Rakefile collapse
-
.github_username=(your_user_name) ⇒ void
Set your github username.
Release infos for DRY release automation collapse
-
.directory_main ⇒ Array
The root directory of your project (as array).
-
.directory_main=(mn) ⇒ void
Set the main directory (as array).
-
.github_username ⇒ String
(see #github_username=).
-
.host_os ⇒ Symbol
Host OS:
:windows
,:linux
or:other
. -
.loaded! ⇒ void
Indicates setup complete.
-
.loaded? ⇒ true, false
Setup complete? All require-statements done?.
-
.project_class ⇒ Class
Class of the actual project.
-
.project_name ⇒ String
Name of the actual project.
-
.project_version ⇒ String
Version of the actual project.
-
.ruby_dir ⇒ String
Path of Ruby installation.
-
.url_docs ⇒ String
URI to github (documentation).
-
.url_source ⇒ String
URI to github (source).
Class Method Details
.directory_main ⇒ Array
The root directory of your project (as array). It’s available whenever you called smart_init before. You can call smart_init from any location in your project directory.
-
main_dir = File.join(Drumherum.directory_main)
-
lib_dir = File.join(Drumherum.directory_main, ‘lib’)
-
test_dir = File.join(Drumherum.directory_main, ‘test’)
78 79 80 81 82 83 84 |
# File 'lib/drumherum/smart_init.rb', line 78 def directory_main if defined? @directory_main @directory_main else [] end end |
.directory_main=(mn) ⇒ void
This method returns an undefined value.
Returns Set the main directory (as array).
66 67 68 |
# File 'lib/drumherum/smart_init.rb', line 66 def directory_main=(mn) @directory_main = mn end |
.github_username ⇒ String
(see #github_username=)
60 61 62 |
# File 'lib/drumherum/smart_init.rb', line 60 def github_username @github_username || 'gleer' end |
.github_username=(your_user_name) ⇒ void
This method returns an undefined value.
Returns Set your github username.
23 24 25 |
# File 'lib/drumherum/smart_init.rb', line 23 def github_username=(your_user_name) @github_username = your_user_name end |
.host_os ⇒ Symbol
Returns Host OS: :windows
, :linux
or :other
.
116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/drumherum/smart_init.rb', line 116 def host_os return $host_os if defined? $host_os case RbConfig::CONFIG['host_os'] when /mswin|windows|mingw32|cygwin32/i $host_os = :windows when /linux/i $host_os = :linux else $host_os = :other end # case #puts "RbConfig::CONFIG['host_os']=#{RbConfig::CONFIG['host_os']}" #puts "$host_os=#{$host_os.inspect}" end |
.loaded! ⇒ void
This method returns an undefined value.
Returns indicates setup complete. All require-statements are done.
88 89 90 |
# File 'lib/drumherum/smart_init.rb', line 88 def loaded! @loaded = true end |
.loaded? ⇒ true, false
Returns setup complete? All require-statements done?.
94 95 96 |
# File 'lib/drumherum/smart_init.rb', line 94 def loaded? @loaded end |
.project_class ⇒ Class
Returns Class of the actual project.
41 42 43 44 45 46 47 |
# File 'lib/drumherum/smart_init.rb', line 41 def project_class classname = project_name.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ classname raise NameError, "#{classname.inspect} is not a valid constant name!" end Object.module_eval("::#{$1}", __FILE__, __LINE__) end |
.project_name ⇒ String
Returns Name of the actual project.
31 32 33 34 35 36 37 |
# File 'lib/drumherum/smart_init.rb', line 31 def project_name if @directory_main @directory_main[-1].strip else raise "start smart_init first" end end |
.project_version ⇒ String
Returns Version of the actual project.
50 51 52 |
# File 'lib/drumherum/smart_init.rb', line 50 def project_version project_class.const_get('VERSION') end |
.ruby_dir ⇒ String
Returns path of Ruby installation.
110 111 112 |
# File 'lib/drumherum/smart_init.rb', line 110 def ruby_dir RbConfig::CONFIG['prefix'] end |
.url_docs ⇒ String
Returns URI to github (documentation).
104 105 106 |
# File 'lib/drumherum/smart_init.rb', line 104 def url_docs "http://#{Drumherum.github_username}.github.com/#{Drumherum.project_name}/frames.html" end |
.url_source ⇒ String
Returns URI to github (source).
99 100 101 |
# File 'lib/drumherum/smart_init.rb', line 99 def url_source "https://github.com/#{Drumherum.github_username}/#{Drumherum.project_name}" end |