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
32
33
34
35
36
37
# 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" }
  # Jeweler has a bug for bundler
  development_dependencies.delete_if { |k,v| k == "bundler" }
  development_dependencies.delete_if { |k,v| k == "jeweler" }
  development_dependencies << ["jeweler",'~> 1.8.4", :git => "https://github.com/technicalpickles/jeweler.git']
  development_dependencies << ["bundler", ">= 1.0.21"]
  # 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
  development_dependencies << ['systemu', '>=2.5.2'] if options[:wrapper]
end

Instance Method Details

#create_and_push_repoObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/bio-gem/mod/jeweler.rb', line 77

def create_and_push_repo
  puts "Please provide your Github password to create the Github repository"
  begin
     = github_username
    password = ask("Password: ") { |q| q.echo = false }
    github = Github.new(:login => .strip, :password => password.strip)
    github.repos.create(:name => github_repo_name, :description => summary)
  rescue Github::Error::Unauthorized
    puts "Wrong login/password! Please try again"
    retry
  rescue Github::Error::UnprocessableEntity
    raise GitRepoCreationFailed, "Can't create that repo. Does it already exist?"
  end
  # TODO do a HEAD request to see when it's ready?
  @repo.push('origin')
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



62
63
64
# File 'lib/bio-gem/mod/jeweler.rb', line 62

def create_files
  create_plugin_files
end

#original_create_filesObject



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

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



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

alias original_project_name project_name

#original_render_templateObject



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

alias original_render_template render_template

#project_nameObject



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

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

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



66
67
68
69
70
71
72
73
74
75
# File 'lib/bio-gem/mod/jeweler.rb', line 66

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



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

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



53
54
55
# File 'lib/bio-gem/mod/jeweler.rb', line 53

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