start_project 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ProjectStart +4 -0
- data/lib/start_project/downloader.rb +28 -0
- data/lib/start_project/options.rb +52 -0
- data/lib/start_project/runner.rb +15 -0
- metadata +78 -0
data/bin/ProjectStart
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#Stub for the entry class
|
2
|
+
require 'rubygems'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'zip/zip'
|
5
|
+
|
6
|
+
module StartProject
|
7
|
+
class Downloader
|
8
|
+
def self.download(source)
|
9
|
+
open("temp.zip",'wb') do |fo|
|
10
|
+
fo.print open(source).read
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.unzip_file (destination)
|
15
|
+
orig_name = ""
|
16
|
+
Zip::ZipFile.open("temp.zip") { |zip_file|
|
17
|
+
zip_file.each { |f|
|
18
|
+
f_path=File.join("./", f.name)
|
19
|
+
orig_name = f_path.split('/')[1]
|
20
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
21
|
+
zip_file.extract(f, f_path) unless File.exist?(f_path)
|
22
|
+
}
|
23
|
+
}
|
24
|
+
File.rename(orig_name, destination)
|
25
|
+
File.delete("temp.zip")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
module StartProject
|
3
|
+
class Options
|
4
|
+
# TODO
|
5
|
+
# 1. Create a class to store/read from YAML, all the different frameworks possible
|
6
|
+
# 2. Clean up the unpacking
|
7
|
+
# 3. Create Tests
|
8
|
+
# 4. Write documentation
|
9
|
+
|
10
|
+
|
11
|
+
DEFAULT_TYPE = "html5"
|
12
|
+
attr_reader :project_uri
|
13
|
+
attr_reader :project_name
|
14
|
+
|
15
|
+
def initialize(argv)
|
16
|
+
@project_uri = "https://github.com/h5bp/html5-boilerplate/zipball/master"
|
17
|
+
parse(argv)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def parse(argv)
|
22
|
+
OptionParser.new do |opts|
|
23
|
+
opts.banner = "Usage: ProjectStart -t [ html5 | bootstrap] -n projectName"
|
24
|
+
|
25
|
+
opts.on("-t","--type html5|bootstrap", String, "Type of project") do |type|
|
26
|
+
if(type=='bootstrap')
|
27
|
+
@project_uri = "https://github.com/twitter/bootstrap/zipball/master"
|
28
|
+
else
|
29
|
+
@project_uri = "https://github.com/h5bp/html5-boilerplate/zipball/master"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-n","--name projectName", String, "Name of project") do |name|
|
34
|
+
@project_name = name
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("-h", "--help", "Show this message") do
|
38
|
+
puts opts
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
42
|
+
begin
|
43
|
+
argv = ["-h"] if argv.empty?
|
44
|
+
opts.parse(argv)
|
45
|
+
rescue OptionParser::ParseError => e
|
46
|
+
STDERR.puts e.message, "\n", opts
|
47
|
+
exit(-1)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'start_project/downloader'
|
2
|
+
require 'start_project/options'
|
3
|
+
module StartProject
|
4
|
+
class Runner
|
5
|
+
def initialize(argv)
|
6
|
+
@options = Options.new(argv)
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
Downloader.download(@options.project_uri)
|
11
|
+
Downloader.unzip_file(@options.project_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: start_project
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Aonghus Flynn
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2012-08-24 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rubyzip
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
description: ""
|
33
|
+
email: developer@aonghusflynn.com
|
34
|
+
executables: []
|
35
|
+
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files: []
|
39
|
+
|
40
|
+
files:
|
41
|
+
- lib/start_project/downloader.rb
|
42
|
+
- lib//start_project/options.rb
|
43
|
+
- lib//start_project/runner.rb
|
44
|
+
- bin/ProjectStart
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://rubygems.org/gems/start_project
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 1
|
60
|
+
- 8
|
61
|
+
- 7
|
62
|
+
version: 1.8.7
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.3.6
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Create html projects
|
77
|
+
test_files: []
|
78
|
+
|