Class: Provisional::Project
- Inherits:
-
Object
- Object
- Provisional::Project
- Defined in:
- lib/provisional/project.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options) ⇒ Project
constructor
A new instance of Project.
- #is_valid_url?(url) ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Project
Returns a new instance of Project.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/provisional/project.rb', line 9 def initialize() = HashWithIndifferentAccess.new if [:config] begin = .merge(YAML.load_file([:config])) rescue raise ArgumentError, "could not be loaded or parsed: #{options[:config]}" end end = .merge(.reject{|k,v| v.nil?}) [:scm] ||= 'git' [:template] ||= 'viget' unless is_valid_url?(['template']) if File.exist?(File.(['template'])) ['template_path'] = File.(['template']) else ['template_path'] = File.(File.join(File.dirname(__FILE__),'templates',"#{@options['template']}.rb")) end raise ArgumentError, "is not valid: #{@options['template']}" unless File.exist?(['template_path']) else ['template_path'] = ['template'] end raise ArgumentError, "name must be specified" unless ['name'] raise ArgumentError, "already exists: #{@options['name']}" if File.exist?(['name']) raise ArgumentError, "already exists: #{@options['name']}.repo" if ['scm'] == 'svn' && File.exist?("#{@options['name']}.repo") begin require "provisional/scm/#{@options['scm']}" rescue MissingSourceFile raise ArgumentError, "is not supported: #{@options['scm']}" end scm_class = "Provisional::SCM::#{@options['scm'].classify}".constantize scm = scm_class.new() scm.init scm.generate_rails scm.checkin end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/provisional/project.rb', line 7 def end |
Instance Method Details
#is_valid_url?(url) ⇒ Boolean
51 52 53 54 55 56 57 |
# File 'lib/provisional/project.rb', line 51 def is_valid_url?(url) begin [URI::HTTP, URI::HTTPS].include?(URI.parse(url).class) rescue URI::InvalidURIError false end end |