Class: Jeweler::Generator

Inherits:
Object
  • Object
show all
Includes:
Biogem::Github, Biogem::Naming, Biogem::Path, Biogem::Render
Defined in:
lib/bio-gem/mod/jeweler.rb,
lib/bio-gem/mod/jeweler/options.rb,
lib/bio-gem/mod/jeweler/github_mixin.rb

Defined Under Namespace

Modules: GithubMixin Classes: Options

Instance Method Summary collapse

Methods included from Biogem::Render

#after_render_template, #create_bin, #create_db_structure, #create_ffi_structure, #create_lib, #create_meta, #create_plugin_files, #create_rails_engine, #create_test_data, #output_template_in_target_generic, #output_template_in_target_generic_append, #render_template_generic, #template_dir_biogem

Methods included from Biogem::Path

#bin_dir, #bin_name, #db_dir, #exists_dir?, #ext_dir, #lib_dir, #lib_filename, #lib_plugin_dir, #lib_plugin_filename, #path, #require_name, #short_name, #test_data_dir

Methods included from Biogem::Naming

#engine_dirs, #engine_filename, #engine_module_name, #engine_name, #engine_name_prefix, #engine_namespace, #lib_sub_module, #sub_module

Constructor Details

#initialize(options = {}) ⇒ Generator

Returns a new instance of Generator.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bio-gem/mod/jeweler.rb', line 18

def initialize(options = {})
  original_initialize(options)
  # RCov is not properly supported in Ruby 1.9.2, so we remove it
  development_dependencies.delete_if { |k,v| k == "rcov" }
  # development_dependencies << ["bio-logger"]
  development_dependencies << ["bio", ">= 1.4.2"]
  # we add rdoc because of an upgrade of rake RDocTask causing errors
  development_dependencies << ["rdoc","~> 3.12"]
  if options[:biogem_db]
    development_dependencies << ["activerecord", ">= 3.0.7"]
    development_dependencies << ["activesupport", ">= 3.0.7"]
    development_dependencies << ["sqlite3", ">= 1.3.3"]
  end
end

Instance Method Details

#create_and_push_repoObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/bio-gem/mod/jeweler.rb', line 71

def create_and_push_repo
  return if $UNITTEST  # skip github create when testing
  begin 
    Net::HTTP.post_form URI.parse('http://github.com/api/v2/yaml/repos/create'),
    'login' => github_username,
    'token' => github_token,
    'description' => summary,
    'name' => github_repo_name
    # BY DEFAULT THE REPO IS CREATED
    # DO NOT PUSH THE REPO BECAUSE USER MUST ADD INFO TO CONFIGURATION FILES
    # TODO do a HEAD request to see when it's ready?
    #@repo.push('origin')
  rescue  SocketError => se
    puts_template_message("Seems you are not connected to Internet, can't create a remote repository. Do not forget to create it by hand, from GitHub, and sync it with this project.")
  end
end

#create_filesObject

this is the default directory for storing library datasets creates a data directory for every needs. the options are defined in mod/jeweler/options.rb



56
57
58
# File 'lib/bio-gem/mod/jeweler.rb', line 56

def create_files
  create_plugin_files
end

#original_create_filesObject



52
# File 'lib/bio-gem/mod/jeweler.rb', line 52

alias original_create_files create_files

#original_initializeObject



17
# File 'lib/bio-gem/mod/jeweler.rb', line 17

alias original_initialize initialize

#original_project_nameObject



33
# File 'lib/bio-gem/mod/jeweler.rb', line 33

alias original_project_name project_name

#original_render_templateObject



40
# File 'lib/bio-gem/mod/jeweler.rb', line 40

alias original_render_template render_template

#project_nameObject



34
35
36
37
38
# File 'lib/bio-gem/mod/jeweler.rb', line 34

def project_name
  name = original_project_name
  return 'bio-'+name if name !~ /^bio-/
  name
end

#puts_template_message(message, length = 70, padding = 4) ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/bio-gem/mod/jeweler.rb', line 60

def puts_template_message(message, length=70, padding=4)
  puts "*"*(length+padding*2+2)
  puts "*"+" "*(length+padding*2)+"*"
  message=message.join("\n") if message.kind_of? Array
  message.scan(/.{1,70}/).map do |sub_message|
    puts "*"+" "*padding+sub_message+" "*(length-sub_message.size+padding)+"*"
  end
  puts "*"+" "*(length+padding*2)+"*"
  puts "*"*(length+padding*2+2)
end

#render_template(source) ⇒ Object



41
42
43
44
45
# File 'lib/bio-gem/mod/jeweler.rb', line 41

def render_template(source)
  buf = original_render_template(source)
  # call hook (returns edited buf)
  after_render_template(source,buf)
end

#target_dirObject Also known as: github_repo_name



47
48
49
# File 'lib/bio-gem/mod/jeweler.rb', line 47

def target_dir
  project_name.sub('bio','bioruby')
end