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

Release infos for DRY release automation collapse

Class Method Details

.directory_mainArray

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’)

Returns:

  • (Array)


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_usernameString

(see #github_username=)

Returns:

  • (String)

    Your 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_osSymbol

Returns Host OS: :windows, :linux or :other.

Returns:

  • (Symbol)

    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?.

Returns:

  • (true, false)

    setup complete? All require-statements done?



94
95
96
# File 'lib/drumherum/smart_init.rb', line 94

def loaded?
  @loaded 
end

.project_classClass

Returns Class of the actual project.

Returns:

  • (Class)

    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_nameString

Returns Name of the actual project.

Returns:

  • (String)

    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_versionString

Returns Version of the actual project.

Returns:

  • (String)

    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_dirString

Returns path of Ruby installation.

Returns:

  • (String)

    path of Ruby installation



110
111
112
# File 'lib/drumherum/smart_init.rb', line 110

def ruby_dir
  RbConfig::CONFIG['prefix']
end

.url_docsString

Returns URI to github (documentation).

Returns:

  • (String)

    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_sourceString

Returns URI to github (source).

Returns:

  • (String)

    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