loom 0.0.2 → 0.0.43
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -0
- data/Gemfile.lock +33 -0
- data/README.rdoc +1 -1
- data/Rakefile +7 -0
- data/VERSION +1 -1
- data/bin/loom +42 -2
- data/lib/helper.rb +228 -0
- data/lib/loom/config.rb +48 -0
- data/lib/loom/init.rb +18 -0
- data/lib/loom/login.rb +36 -0
- data/lib/loom/logout.rb +16 -0
- data/lib/loom/new.rb +46 -0
- data/lib/loom/ping.rb +41 -0
- data/lib/loom/run.rb +22 -0
- data/lib/loom/sdk.rb +113 -0
- data/lib/loom/use.rb +95 -0
- data/lib/templates/Main.build.erb +11 -0
- data/lib/templates/Program.ls.erb +13 -0
- data/loom.gemspec +35 -12
- metadata +79 -6
- data/lib/loom.rb +0 -60
- data/test/helper.rb +0 -18
- data/test/test_loom.rb +0 -7
data/Gemfile
CHANGED
@@ -3,6 +3,9 @@ source "http://rubygems.org"
|
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
5
|
|
6
|
+
gem "commander"
|
7
|
+
gem "rubyzip"
|
8
|
+
|
6
9
|
# Add dependencies to develop your gem here.
|
7
10
|
# Include everything needed to run rake, tests, features, etc.
|
8
11
|
group :development do
|
@@ -11,4 +14,6 @@ group :development do
|
|
11
14
|
gem "bundler"
|
12
15
|
gem "jeweler"
|
13
16
|
gem "simplecov"
|
17
|
+
gem "cucumber"
|
18
|
+
gem "aruba"
|
14
19
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,27 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
aruba (0.4.11)
|
5
|
+
childprocess (>= 0.2.3)
|
6
|
+
cucumber (>= 1.1.1)
|
7
|
+
ffi (>= 1.0.11)
|
8
|
+
rspec (>= 2.7.0)
|
9
|
+
builder (3.0.0)
|
10
|
+
childprocess (0.3.4)
|
11
|
+
ffi (~> 1.0, >= 1.0.6)
|
12
|
+
commander (4.1.2)
|
13
|
+
highline (~> 1.6.11)
|
14
|
+
cucumber (1.2.1)
|
15
|
+
builder (>= 2.1.2)
|
16
|
+
diff-lcs (>= 1.1.3)
|
17
|
+
gherkin (~> 2.11.0)
|
18
|
+
json (>= 1.4.6)
|
19
|
+
diff-lcs (1.1.3)
|
20
|
+
ffi (1.1.3)
|
21
|
+
gherkin (2.11.1)
|
22
|
+
json (>= 1.4.6)
|
4
23
|
git (1.2.5)
|
24
|
+
highline (1.6.13)
|
5
25
|
jeweler (1.8.4)
|
6
26
|
bundler (~> 1.0)
|
7
27
|
git (>= 1.2.5)
|
@@ -12,6 +32,15 @@ GEM
|
|
12
32
|
rake (0.9.2.2)
|
13
33
|
rdoc (3.12)
|
14
34
|
json (~> 1.4)
|
35
|
+
rspec (2.11.0)
|
36
|
+
rspec-core (~> 2.11.0)
|
37
|
+
rspec-expectations (~> 2.11.0)
|
38
|
+
rspec-mocks (~> 2.11.0)
|
39
|
+
rspec-core (2.11.1)
|
40
|
+
rspec-expectations (2.11.2)
|
41
|
+
diff-lcs (~> 1.1.3)
|
42
|
+
rspec-mocks (2.11.1)
|
43
|
+
rubyzip (0.9.9)
|
15
44
|
shoulda (3.0.1)
|
16
45
|
shoulda-context (~> 1.0.0)
|
17
46
|
shoulda-matchers (~> 1.0.0)
|
@@ -26,8 +55,12 @@ PLATFORMS
|
|
26
55
|
ruby
|
27
56
|
|
28
57
|
DEPENDENCIES
|
58
|
+
aruba
|
29
59
|
bundler
|
60
|
+
commander
|
61
|
+
cucumber
|
30
62
|
jeweler
|
31
63
|
rdoc
|
64
|
+
rubyzip
|
32
65
|
shoulda
|
33
66
|
simplecov
|
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -21,6 +21,7 @@ Jeweler::Tasks.new do |gem|
|
|
21
21
|
gem.description = %Q{Command-line interface for the Loom Game Engine, brought to you by The Engine Co. (http://theengine.co)}
|
22
22
|
gem.email = "support@theengine.co"
|
23
23
|
gem.authors = ["The Engine Co."]
|
24
|
+
gem.files.exclude "features/**/*"
|
24
25
|
# dependencies defined in Gemfile
|
25
26
|
end
|
26
27
|
Jeweler::RubygemsDotOrgTasks.new
|
@@ -43,3 +44,9 @@ Rake::RDocTask.new do |rdoc|
|
|
43
44
|
rdoc.rdoc_files.include('README*')
|
44
45
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
46
|
end
|
47
|
+
|
48
|
+
require "cucumber"
|
49
|
+
require 'cucumber/rake/task'
|
50
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
51
|
+
t.cucumber_opts = "features"
|
52
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.43
|
data/bin/loom
CHANGED
@@ -1,5 +1,45 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
if(ENV['LIB_DIR'])
|
4
|
+
$LOAD_PATH << File.expand_path(ENV['LIB_DIR'])
|
5
|
+
else
|
6
|
+
$LOAD_PATH << "./lib"
|
7
|
+
end
|
4
8
|
|
5
|
-
|
9
|
+
require 'rubygems'
|
10
|
+
require 'commander/import'
|
11
|
+
require 'loom/config'
|
12
|
+
require 'helper'
|
13
|
+
|
14
|
+
#commands
|
15
|
+
require 'loom/new'
|
16
|
+
require 'loom/login'
|
17
|
+
require 'loom/logout'
|
18
|
+
require 'loom/ping'
|
19
|
+
require 'loom/init'
|
20
|
+
require 'loom/use'
|
21
|
+
require 'loom/run'
|
22
|
+
require 'loom/sdk'
|
23
|
+
|
24
|
+
#create the loom storage directory
|
25
|
+
LOOM_DIR = File.expand_path "#{ENV['HOME']}/.loom"
|
26
|
+
if !File.directory?(LOOM_DIR)
|
27
|
+
FileUtils.mkdir_p LOOM_DIR
|
28
|
+
end
|
29
|
+
|
30
|
+
# Constants
|
31
|
+
TEMPLATES_DIR = File.expand_path File.join File.dirname(__FILE__), '..', 'lib', 'templates'
|
32
|
+
CONFIG_PATH = ".loomconfig"
|
33
|
+
GLOBAL_CONFIG_PATH = "#{LOOM_DIR}/.loomconfig"
|
34
|
+
TOKEN_PATH = "#{LOOM_DIR}/token"
|
35
|
+
TEMP_PATH = "#{LOOM_DIR}/temp"
|
36
|
+
OSX_APP_PATH = "LoomDemo.app"
|
37
|
+
|
38
|
+
if !File.exists? GLOBAL_CONFIG_PATH
|
39
|
+
global_config = Loom::Config.new
|
40
|
+
global_config.save! GLOBAL_CONFIG_PATH
|
41
|
+
end
|
42
|
+
|
43
|
+
program :version, File.new(File.join(File.dirname(__FILE__), "..", "VERSION")).read
|
44
|
+
program :description, 'Command line tools for working with the loom sdk'
|
45
|
+
default_command :help
|
data/lib/helper.rb
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'zip/zip'
|
3
|
+
require "net/http"
|
4
|
+
|
5
|
+
def get_token
|
6
|
+
|
7
|
+
if File.exists?(TOKEN_PATH)
|
8
|
+
return File.read(TOKEN_PATH)
|
9
|
+
else
|
10
|
+
say_error "Not Authenticated! Login using 'loom login'"
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup_env(command)
|
17
|
+
command.option '--env String', String, 'sets the authentication endpoint to a specific environment (for testing only).'
|
18
|
+
end
|
19
|
+
|
20
|
+
@host = "call setup_host"
|
21
|
+
def setup_host(options)
|
22
|
+
options.default :env => "prod"
|
23
|
+
|
24
|
+
if options.env == "prod"
|
25
|
+
@host = "theengine.co"
|
26
|
+
elsif options.env == "staging"
|
27
|
+
@host = "theengineco-staging.herokuapp.com"
|
28
|
+
elsif options.env == "local"
|
29
|
+
@host = "localhost:3000"
|
30
|
+
else
|
31
|
+
say "Environment #{options.env} is not supported"
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Ensures the directory is configured as a loom project
|
37
|
+
def ensure_configured!
|
38
|
+
if !File.exists? CONFIG_PATH
|
39
|
+
should_configure = choose("This directory has not been configured as a loom project. Configure it now?", :yes, :no)
|
40
|
+
|
41
|
+
if(should_configure == :yes)
|
42
|
+
configure_directory ""
|
43
|
+
else
|
44
|
+
say_error "Cannot complete action in an unconfigured loom project."
|
45
|
+
exit 1
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Ensures the SDK that is specified in the config is imported
|
52
|
+
# into the project
|
53
|
+
def ensure_sdk_imported!
|
54
|
+
|
55
|
+
# if the sdk artifacts are already here then we don't need to
|
56
|
+
# do anything
|
57
|
+
return if(File.exists?("LoomDemo.app") && File.directory?("bin"))
|
58
|
+
|
59
|
+
say "Pulling in sdk files..."
|
60
|
+
|
61
|
+
sdk_path = File.join(LOOM_DIR, "sdks", config["sdk_version"])
|
62
|
+
|
63
|
+
# TODO: Make this windows compatible
|
64
|
+
sdk_app_path = File.join sdk_path, "LoomDemo.app"
|
65
|
+
sdk_libs_path = File.join sdk_path, "libs"
|
66
|
+
sdk_assets_path = File.join sdk_path, "assets"
|
67
|
+
project_path = Dir.pwd
|
68
|
+
|
69
|
+
if !File.directory?("bin")
|
70
|
+
FileUtils.mkdir_p "bin"
|
71
|
+
end
|
72
|
+
|
73
|
+
#copy loomgame executable
|
74
|
+
|
75
|
+
#FileUtils.cp_r(sdk_app_path,"loomgame")
|
76
|
+
|
77
|
+
# Change permissions in the executable
|
78
|
+
bin_file = "#{sdk_app_path}/Contents/MacOS/LoomDemo"
|
79
|
+
# TODO Add check for bin_file if it exists
|
80
|
+
say_tab 1, "Adding permissions to LoomDemo at #{bin_file}"
|
81
|
+
FileUtils.chmod(0755, bin_file)
|
82
|
+
|
83
|
+
#copy sdk_libs_path
|
84
|
+
say_tab 1, "Copying core libraries from #{sdk_libs_path}"
|
85
|
+
|
86
|
+
FileUtils.mkdir_p "libs"
|
87
|
+
Dir.chdir(sdk_libs_path) do
|
88
|
+
Dir.glob('**.loom') do |lib|
|
89
|
+
say_tab 2, "Copy #{lib}"
|
90
|
+
FileUtils.cp(lib, File.join(project_path, "libs"))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
say_tab 1, "Copying assets to #{project_path}/assets"
|
95
|
+
FileUtils.cp_r("#{sdk_assets_path}/.", File.join(project_path, "assets"))
|
96
|
+
end
|
97
|
+
|
98
|
+
def say_tab(num_tabs,value)
|
99
|
+
|
100
|
+
result = ""
|
101
|
+
num_tabs.times do |t|
|
102
|
+
result += " "
|
103
|
+
end
|
104
|
+
|
105
|
+
say result + value
|
106
|
+
end
|
107
|
+
|
108
|
+
def configure_directory(dir)
|
109
|
+
say "Configuring Project..."
|
110
|
+
|
111
|
+
loom_config = {
|
112
|
+
:sdk_version => "0.0.1"
|
113
|
+
}
|
114
|
+
|
115
|
+
config_path = ""
|
116
|
+
|
117
|
+
if dir.length > 0
|
118
|
+
config_path = File.join dir, CONFIG_PATH
|
119
|
+
else
|
120
|
+
config_path = CONFIG_PATH
|
121
|
+
end
|
122
|
+
|
123
|
+
if File.exists?(config_path)
|
124
|
+
say_error "This project is already configured!"
|
125
|
+
exit 1
|
126
|
+
end
|
127
|
+
|
128
|
+
say_tab 1, "Writing file #{config_path}"
|
129
|
+
|
130
|
+
File.open(config_path , 'w') { |f|
|
131
|
+
f.write(JSON.pretty_generate(loom_config))
|
132
|
+
}
|
133
|
+
end
|
134
|
+
|
135
|
+
def config
|
136
|
+
ensure_configured!
|
137
|
+
JSON.parse(File.read(CONFIG_PATH))
|
138
|
+
end
|
139
|
+
|
140
|
+
def unzip_file (file, destination)
|
141
|
+
Zip::ZipFile.open(file) do |zip_file|
|
142
|
+
zip_file.each do |f|
|
143
|
+
f_path=File.join(destination, f.name)
|
144
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
145
|
+
zip_file.extract(f, f_path) unless File.exist?(f_path)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def search_for_remote_sdk(search)
|
151
|
+
|
152
|
+
if(search.nil? || search.empty?)
|
153
|
+
response = fetch("http://#{@host}/api/v1/sdks?auth_token=#{get_token}")
|
154
|
+
else
|
155
|
+
response = fetch("http://#{@host}/api/v1/sdk/#{search}?auth_token=#{get_token}")
|
156
|
+
end
|
157
|
+
|
158
|
+
response.body
|
159
|
+
end
|
160
|
+
|
161
|
+
def download_sdk(version)
|
162
|
+
response = fetch("http://#{@host}/api/v1/download/sdk/#{version}?auth_token=#{get_token}")
|
163
|
+
|
164
|
+
file_path = File.expand_path("#{TEMP_PATH}/#{version}.zip")
|
165
|
+
|
166
|
+
puts "Writing temporary file: #{file_path}"
|
167
|
+
|
168
|
+
FileUtils.mkdir_p TEMP_PATH
|
169
|
+
File.open(file_path, 'w') {|f| f.write(response.body) }
|
170
|
+
|
171
|
+
file_path
|
172
|
+
end
|
173
|
+
|
174
|
+
def fetch(uri_str, limit = 10)
|
175
|
+
# You should choose better exception.
|
176
|
+
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
|
177
|
+
|
178
|
+
response = Net::HTTP.get_response(URI.parse(uri_str))
|
179
|
+
case response
|
180
|
+
when Net::HTTPSuccess then response
|
181
|
+
when Net::HTTPRedirection then fetch(response['location'], limit - 1)
|
182
|
+
else
|
183
|
+
response.error!
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def list_installed_sdks()
|
188
|
+
say "Listing installed loom sdks..."
|
189
|
+
|
190
|
+
if !File.directory?(File.join(LOOM_DIR, "sdks")) || Dir[File.join(LOOM_DIR, "sdks", "*")].empty?
|
191
|
+
say_error "No SDKs installed"
|
192
|
+
exit 1
|
193
|
+
end
|
194
|
+
|
195
|
+
Dir.foreach(File.join(LOOM_DIR, "sdks")) do |sdk|
|
196
|
+
is_directory = File.directory?(File.join(LOOM_DIR, "sdks",sdk))
|
197
|
+
#is_current = sdk == config["sdk_version"]
|
198
|
+
#current_symbol = "*"
|
199
|
+
|
200
|
+
if is_directory && sdk != "." && sdk != ".."
|
201
|
+
# if is_current
|
202
|
+
# say_warning " #{current_symbol} #{sdk}"
|
203
|
+
# else
|
204
|
+
say_tab 1, "#{sdk}"
|
205
|
+
# end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
exit(0)
|
210
|
+
end
|
211
|
+
|
212
|
+
def sdk_installed?(version)
|
213
|
+
File.directory?(File.join(LOOM_DIR, "sdks", version))
|
214
|
+
end
|
215
|
+
|
216
|
+
def set_local_config(key, value)
|
217
|
+
ensure_configured!
|
218
|
+
|
219
|
+
loom_config = Loom::Config.load CONFIG_PATH
|
220
|
+
loom_config[key] = value
|
221
|
+
loom_config.save! CONFIG_PATH
|
222
|
+
end
|
223
|
+
|
224
|
+
def set_global_config(key, value)
|
225
|
+
loom_config = Loom::Config.load GLOBAL_CONFIG_PATH
|
226
|
+
loom_config[key] = value
|
227
|
+
loom_config.save! GLOBAL_CONFIG_PATH
|
228
|
+
end
|
data/lib/loom/config.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Loom
|
4
|
+
class Config < Hash
|
5
|
+
|
6
|
+
# load a new config option
|
7
|
+
def self.load(path)
|
8
|
+
config = Config.new
|
9
|
+
config.merge! JSON.parse(File.read(path))
|
10
|
+
end
|
11
|
+
|
12
|
+
def save!(path)
|
13
|
+
File.open(path , 'w') do |f|
|
14
|
+
f.write(JSON.pretty_generate(self))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
command :config do |c|
|
22
|
+
|
23
|
+
c.syntax = 'loom config [options]'
|
24
|
+
c.summary = 'add, edit and remove configuration options for loomcli'
|
25
|
+
c.description = 'add and edit configuration options for loomcli'
|
26
|
+
c.option '--global', 'sets the global configuration variable'
|
27
|
+
c.example 'set local variable', 'loom config foo bar'
|
28
|
+
c.example 'set global variable', 'loom config --global foo bar'
|
29
|
+
|
30
|
+
c.action do |args, options|
|
31
|
+
|
32
|
+
config_path = options.global ? GLOBAL_CONFIG_PATH : CONFIG_PATH
|
33
|
+
|
34
|
+
ensure_configured! unless options.global
|
35
|
+
|
36
|
+
loom_config = Loom::Config.load config_path
|
37
|
+
|
38
|
+
if !(args[0] && args[1])
|
39
|
+
say "Invalid number of arguments. Example: loom config foo bar"
|
40
|
+
exit 1
|
41
|
+
else
|
42
|
+
loom_config[args[0]] = args[1]
|
43
|
+
loom_config.save! config_path
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/lib/loom/init.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
command :init do |c|
|
2
|
+
|
3
|
+
c.syntax = 'loom init [options]'
|
4
|
+
c.summary = 'Configures the working directory as a loom project.'
|
5
|
+
c.description = 'Configuration for the loom toolbelt is done through a .loomconfig file. All projects that wish to use the loom commands must be configured with a .loomconfig file in the project root. calling "loom init" automatically configures the project.'
|
6
|
+
c.example 'initialize and configure loom project', 'loom init'
|
7
|
+
c.example 'initialize in a specific directory', 'loom init --dir /Path/To/My/Project'
|
8
|
+
c.option '--dir STRING', String, 'Specify a directory to configure'
|
9
|
+
|
10
|
+
c.action do |args, options|
|
11
|
+
|
12
|
+
options.default :dir => ""
|
13
|
+
|
14
|
+
configure_directory options.dir
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/lib/loom/login.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
command :login do |c|
|
2
|
+
|
3
|
+
c.syntax = 'loom login [options]'
|
4
|
+
c.summary = 'log in with your theengine.co credentials'
|
5
|
+
c.description = 'logging into theengine.co allows certain loom features to be unlocked, such as downloading the latest version of loom or installing a loom gem.'
|
6
|
+
c.example 'login to theengine.co', 'loom login'
|
7
|
+
|
8
|
+
setup_env c
|
9
|
+
|
10
|
+
c.action do |args, options|
|
11
|
+
|
12
|
+
setup_host options
|
13
|
+
|
14
|
+
say "Logging in to: #{@host}"
|
15
|
+
|
16
|
+
#ask for email and password
|
17
|
+
email = ask("Email: ")
|
18
|
+
user_password = password
|
19
|
+
|
20
|
+
# send along the credentials
|
21
|
+
endpoint = URI.parse("http://#{@host}/api/v1/session")
|
22
|
+
|
23
|
+
response = Net::HTTP.post_form(endpoint, {"email" => email, "password" => user_password})
|
24
|
+
|
25
|
+
if response.code == "201"
|
26
|
+
say_ok "Login successful!"
|
27
|
+
File.open(File.expand_path(TOKEN_PATH) , 'w') {|f| f.write(response.body) }
|
28
|
+
|
29
|
+
#save the token on disk
|
30
|
+
else
|
31
|
+
say_error "Login failed! #{response.body}"
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/loom/logout.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
command :logout do |c|
|
2
|
+
|
3
|
+
c.syntax = 'loom logout [options]'
|
4
|
+
c.summary = 'log out from theengine.co'
|
5
|
+
c.description = ''
|
6
|
+
c.example 'logout from theengine.co', 'loom logout'
|
7
|
+
|
8
|
+
c.action do |args, options|
|
9
|
+
|
10
|
+
if File.exists?(TOKEN_PATH)
|
11
|
+
File.delete(TOKEN_PATH)
|
12
|
+
end
|
13
|
+
say_ok "You are now logged out"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/loom/new.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
command :new do |c|
|
2
|
+
|
3
|
+
c.syntax = 'loom new [options]'
|
4
|
+
c.summary = 'Creates a new loom project in the specified directory'
|
5
|
+
c.description = 'loom new generates a bare bones project structure that can immediately compile by calling loom run, this acts as a great starting point for loom development'
|
6
|
+
c.example 'create a new project called MyProject', 'loom new MyProject'
|
7
|
+
|
8
|
+
c.action do |args, options|
|
9
|
+
|
10
|
+
dir = args[0] unless args.nil?
|
11
|
+
|
12
|
+
if dir.nil?
|
13
|
+
say_error "Unable to create a new loom project without a directory. Example: loom new MyGame"
|
14
|
+
exit 1
|
15
|
+
else
|
16
|
+
if !File.directory?(dir)
|
17
|
+
|
18
|
+
say "Initializing Project: #{dir}..."
|
19
|
+
say_tab 1, "Creating directory #{dir}/src"
|
20
|
+
FileUtils.mkdir_p "#{dir}/src"
|
21
|
+
say_tab 1, "Creating directory #{dir}/libs"
|
22
|
+
FileUtils.mkdir_p "#{dir}/libs"
|
23
|
+
say_tab 1, "Creating directory #{dir}/bin"
|
24
|
+
FileUtils.mkdir_p "#{dir}/bin"
|
25
|
+
|
26
|
+
say_tab 1, "Creating directory #{dir}/assets"
|
27
|
+
FileUtils.mkdir_p "#{dir}/assets"
|
28
|
+
|
29
|
+
say_tab 1, "Writing file #{dir}/src/Main.build"
|
30
|
+
main_build_file = File.new File.join TEMPLATES_DIR, "Main.build.erb"
|
31
|
+
File.open("#{dir}/src/Main.build" , 'w') {|f| f.write(main_build_file.read) }
|
32
|
+
|
33
|
+
say_tab 1, "Writing file #{dir}/src/Program.ls"
|
34
|
+
program_ls_file = File.new File.join TEMPLATES_DIR, "Program.ls.erb"
|
35
|
+
File.open("#{dir}/src/Program.ls" , 'w') {|f| f.write(program_ls_file.read) }
|
36
|
+
|
37
|
+
configure_directory dir
|
38
|
+
|
39
|
+
elsif
|
40
|
+
say_error "Directory #{dir} already exists!"
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/lib/loom/ping.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "uri"
|
3
|
+
|
4
|
+
command :ping do |c|
|
5
|
+
|
6
|
+
c.syntax = 'loom ping [options]'
|
7
|
+
c.summary = 'ping the server as an authenticated user'
|
8
|
+
c.description = 'ping the server to check if you have been authenticated'
|
9
|
+
c.option '--env String', String, 'sets the authentication endpoint to a specific environment (for testing only).'
|
10
|
+
c.example 'ping theengine.co', 'loom ping'
|
11
|
+
|
12
|
+
c.action do |args, options|
|
13
|
+
|
14
|
+
#default options
|
15
|
+
options.default :env => "prod"
|
16
|
+
|
17
|
+
if options.env == "prod"
|
18
|
+
host = "theengine.co"
|
19
|
+
elsif options.env == "staging"
|
20
|
+
host = "theengineco-staging.herokuapp.com"
|
21
|
+
elsif options.env == "local"
|
22
|
+
host = "localhost:3000"
|
23
|
+
else
|
24
|
+
say "Environment #{options.env} is not supported"
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
say "Pinging: #{host}"
|
29
|
+
|
30
|
+
# send along the credentials
|
31
|
+
endpoint = URI.parse("http://#{host}/api/v1/ping_authenticated?auth_token=#{get_token}")
|
32
|
+
response = Net::HTTP.get_response(endpoint)
|
33
|
+
|
34
|
+
if response.code == "200"
|
35
|
+
say "Ping successful!"
|
36
|
+
else
|
37
|
+
say "Ping failed! #{response.body}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/lib/loom/run.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
command :run do |c|
|
2
|
+
|
3
|
+
c.syntax = 'loom run [options]'
|
4
|
+
c.summary = 'run your loom app in the working directory'
|
5
|
+
c.description = ''
|
6
|
+
c.example 'run your loom app', 'loom run'
|
7
|
+
|
8
|
+
c.action do |args, options|
|
9
|
+
|
10
|
+
ensure_sdk_imported!
|
11
|
+
|
12
|
+
loom_config = Loom::Config.load CONFIG_PATH
|
13
|
+
sdk_version = loom_config["sdk_version"]
|
14
|
+
|
15
|
+
sdk_path = File.join(LOOM_DIR, "sdks", sdk_version)
|
16
|
+
|
17
|
+
# TODO: Shoud we hijack the stdio for this?
|
18
|
+
exec "#{sdk_path}/LoomDemo.app/Contents/MacOS/LoomDemo"
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/lib/loom/sdk.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
command :sdk do |c|
|
2
|
+
|
3
|
+
c.syntax = 'loom sdk [options]'
|
4
|
+
c.summary = 'Manage sdks installed on the system'
|
5
|
+
c.description = 'loom sdk manages the sdks on the system'
|
6
|
+
c.example 'display currently installed sdks', 'loom sdk list'
|
7
|
+
c.example 'sets the systems default sdk to 1.0.0', 'loom sdk default 1.0.0'
|
8
|
+
c.example 'installs the latest version of the sdk', 'loom sdk install latest'
|
9
|
+
c.example 'install the 1.0.0 version of the sdk', 'loom sdk install 1.0.0'
|
10
|
+
c.example 'uninstall the 1.0.0 version of the sdk', 'loom sdk uninstall 1.0.0'
|
11
|
+
c.option '--local path', String, 'Loads a local sdk with the path specified'
|
12
|
+
|
13
|
+
setup_env c
|
14
|
+
|
15
|
+
c.action do |args, options|
|
16
|
+
|
17
|
+
setup_host options
|
18
|
+
|
19
|
+
mode = args.shift
|
20
|
+
|
21
|
+
case mode
|
22
|
+
when "install"
|
23
|
+
install_sdk(args, options)
|
24
|
+
when "uninstall", "remove"
|
25
|
+
uninstall_sdk(args, options)
|
26
|
+
when "search"
|
27
|
+
search_for_sdk(args, options)
|
28
|
+
when "default"
|
29
|
+
set_default_sdk(args, options)
|
30
|
+
when "list", nil
|
31
|
+
list_installed_sdks
|
32
|
+
else
|
33
|
+
puts "don't know how to do #{args[0]}"
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_default_sdk(args, options)
|
41
|
+
|
42
|
+
sdk_version = args.shift unless args.nil?
|
43
|
+
|
44
|
+
if sdk_version.nil?
|
45
|
+
say "Invalid number of arguments."
|
46
|
+
exit 1
|
47
|
+
elsif !sdk_installed?(sdk_version)
|
48
|
+
say "Cannot set default SDK to '#{sdk_version}' it is not installed"
|
49
|
+
exit 1
|
50
|
+
end
|
51
|
+
|
52
|
+
set_global_config("default_sdk", sdk_version)
|
53
|
+
|
54
|
+
say "Default SDK set to #{sdk_version}"
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def search_for_sdk(args, options)
|
59
|
+
sdk_version = args.shift unless args.nil?
|
60
|
+
|
61
|
+
response = search_for_remote_sdk(sdk_version)
|
62
|
+
|
63
|
+
say "== Remote SDKs =="
|
64
|
+
say response
|
65
|
+
|
66
|
+
if response.include? "No sdk found"
|
67
|
+
exit 1
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def install_sdk(args, options)
|
73
|
+
sdk_version = args.shift unless args.nil?
|
74
|
+
sdk_path = File.join(LOOM_DIR, "sdks", sdk_version)
|
75
|
+
|
76
|
+
if sdk_version.nil?
|
77
|
+
say "Invalid number of arguments."
|
78
|
+
exit 1
|
79
|
+
end
|
80
|
+
|
81
|
+
# if the sdk doesn't already exists
|
82
|
+
if !File.directory?(sdk_path)
|
83
|
+
if options.local.nil?
|
84
|
+
say "Downloading remote loom SDK..."
|
85
|
+
temp_file = download_sdk(sdk_version)
|
86
|
+
say "Installing remote loom SDK..."
|
87
|
+
unzip_file(temp_file, sdk_path)
|
88
|
+
File.delete(temp_file)
|
89
|
+
say_tab 1, "SDK installed. You can type 'loom use #{sdk_version}' in the future to use this SDK."
|
90
|
+
else
|
91
|
+
say "Installing local loom SDK..."
|
92
|
+
unzip_file(options.local, sdk_path)
|
93
|
+
say_tab 1, "SDK installed. You can type 'loom use #{sdk_version}' in the future to use this SDK."
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def uninstall_sdk(args, options)
|
99
|
+
sdk_version = args.shift unless args.nil?
|
100
|
+
sdk_path = File.join(LOOM_DIR, "sdks", sdk_version)
|
101
|
+
|
102
|
+
if sdk_version.nil?
|
103
|
+
say "Invalid number of arguments."
|
104
|
+
exit 1
|
105
|
+
end
|
106
|
+
|
107
|
+
if File.directory?(sdk_path)
|
108
|
+
FileUtils.rm_rf sdk_path
|
109
|
+
say "Successfully uninstalled SDK: #{sdk_version}"
|
110
|
+
else
|
111
|
+
say "Cannot remove SDK: #{sdk_version}, it isn't installed"
|
112
|
+
end
|
113
|
+
end
|
data/lib/loom/use.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
command :use do |c|
|
2
|
+
|
3
|
+
c.syntax = 'loom use [options]'
|
4
|
+
c.summary = 'Chooses an sdk version to use for the project'
|
5
|
+
c.description = 'loom use configures the project to use the specified sdk'
|
6
|
+
c.example 'display currently installed sdks', 'loom use'
|
7
|
+
c.example 'use the 1.0.0 version of the sdk', 'loom use 1.0.0'
|
8
|
+
c.option '--local path', String, 'Loads a local sdk with the path specified'
|
9
|
+
|
10
|
+
setup_env c
|
11
|
+
|
12
|
+
c.action do |args, options|
|
13
|
+
ensure_configured!
|
14
|
+
|
15
|
+
setup_host options
|
16
|
+
|
17
|
+
# lookup the config
|
18
|
+
loom_config = Loom::Config.load CONFIG_PATH
|
19
|
+
|
20
|
+
#####################################################
|
21
|
+
# => List Available SDKs
|
22
|
+
#####################################################
|
23
|
+
if args.length == 0
|
24
|
+
say "Listing installed loom sdks..."
|
25
|
+
|
26
|
+
if !File.directory?(File.join(LOOM_DIR, "sdks")) || Dir[File.join(LOOM_DIR, "sdks", "*")].empty?
|
27
|
+
say_error "No SDKs installed"
|
28
|
+
exit 1
|
29
|
+
end
|
30
|
+
|
31
|
+
Dir.foreach(File.join(LOOM_DIR, "sdks")) do |sdk|
|
32
|
+
is_directory = File.directory?(File.join(LOOM_DIR, "sdks",sdk))
|
33
|
+
is_current = sdk == config["sdk_version"]
|
34
|
+
current_symbol = "*"
|
35
|
+
|
36
|
+
if is_directory && sdk != "." && sdk != ".."
|
37
|
+
if is_current
|
38
|
+
say_warning " #{current_symbol} #{sdk}"
|
39
|
+
else
|
40
|
+
say " #{sdk}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
#####################################################
|
48
|
+
# => Use specific sdk
|
49
|
+
#####################################################
|
50
|
+
sdk_version = args[0] unless args.nil?
|
51
|
+
sdk_path = File.join(LOOM_DIR, "sdks", sdk_version)
|
52
|
+
|
53
|
+
if sdk_version.nil?
|
54
|
+
say "Invalid number of arguments."
|
55
|
+
exit
|
56
|
+
end
|
57
|
+
|
58
|
+
# if the sdk doesn't already exists
|
59
|
+
if !File.directory?(sdk_path)
|
60
|
+
if options.local.nil?
|
61
|
+
# TODO: Download SDK from theengine.co
|
62
|
+
say "Downloading remote loom SDK..."
|
63
|
+
temp_file = download_sdk(sdk_version)
|
64
|
+
say "Installing remote loom SDK..."
|
65
|
+
unzip_file(temp_file, sdk_path)
|
66
|
+
File.delete(temp_file)
|
67
|
+
say_tab 1, "SDK installed. You can type 'loom use #{sdk_version}' in the future to use this SDK."
|
68
|
+
else
|
69
|
+
say "Installing local loom SDK..."
|
70
|
+
unzip_file(options.local, sdk_path)
|
71
|
+
say_tab 1, "SDK installed. You can type 'loom use #{sdk_version}' in the future to use this SDK."
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
if loom_config["sdk_version"] == sdk_version
|
77
|
+
say_ok "Already using loom version '#{sdk_version}'"
|
78
|
+
exit
|
79
|
+
end
|
80
|
+
|
81
|
+
# Write to .loomconfig
|
82
|
+
say "Configuring Project..."
|
83
|
+
loom_config["sdk_version"] = sdk_version
|
84
|
+
loom_config.save! CONFIG_PATH
|
85
|
+
|
86
|
+
# remove the bin folder to invalidate sdk import
|
87
|
+
FileUtils.rm_rf "bin" if File.directory?("bin")
|
88
|
+
|
89
|
+
ensure_sdk_imported!
|
90
|
+
|
91
|
+
say_ok "Now using loom version '#{sdk_version}'"
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
data/loom.gemspec
CHANGED
@@ -4,14 +4,15 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
7
|
+
s.name = %q{loom}
|
8
8
|
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["The Engine Co."]
|
12
|
-
s.date =
|
13
|
-
s.
|
14
|
-
s.
|
12
|
+
s.date = %q{2012-08-01}
|
13
|
+
s.default_executable = %q{loom}
|
14
|
+
s.description = %q{Command-line interface for the Loom Game Engine, brought to you by The Engine Co. (http://theengine.co)}
|
15
|
+
s.email = %q{support@theengine.co}
|
15
16
|
s.executables = ["loom"]
|
16
17
|
s.extra_rdoc_files = [
|
17
18
|
"LICENSE.txt",
|
@@ -26,38 +27,60 @@ Gem::Specification.new do |s|
|
|
26
27
|
"Rakefile",
|
27
28
|
"VERSION",
|
28
29
|
"bin/loom",
|
29
|
-
"lib/
|
30
|
-
"loom.
|
31
|
-
"
|
32
|
-
"
|
30
|
+
"lib/helper.rb",
|
31
|
+
"lib/loom/config.rb",
|
32
|
+
"lib/loom/init.rb",
|
33
|
+
"lib/loom/login.rb",
|
34
|
+
"lib/loom/logout.rb",
|
35
|
+
"lib/loom/new.rb",
|
36
|
+
"lib/loom/ping.rb",
|
37
|
+
"lib/loom/run.rb",
|
38
|
+
"lib/loom/use.rb",
|
39
|
+
"lib/loom/version.rb",
|
40
|
+
"lib/templates/Main.build.erb",
|
41
|
+
"lib/templates/Program.ls.erb",
|
42
|
+
"loom.gemspec"
|
33
43
|
]
|
34
|
-
s.homepage =
|
44
|
+
s.homepage = %q{http://www.theengine.co}
|
35
45
|
s.require_paths = ["lib"]
|
36
|
-
s.rubygems_version =
|
37
|
-
s.summary =
|
46
|
+
s.rubygems_version = %q{1.3.6}
|
47
|
+
s.summary = %q{Loom Game Engine Command Line}
|
38
48
|
|
39
49
|
if s.respond_to? :specification_version then
|
50
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
40
51
|
s.specification_version = 3
|
41
52
|
|
42
|
-
if Gem::Version.new(Gem::
|
53
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<commander>, [">= 0"])
|
55
|
+
s.add_runtime_dependency(%q<rubyzip>, [">= 0"])
|
43
56
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
44
57
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
45
58
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
46
59
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
47
60
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
61
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
62
|
+
s.add_development_dependency(%q<aruba>, [">= 0"])
|
48
63
|
else
|
64
|
+
s.add_dependency(%q<commander>, [">= 0"])
|
65
|
+
s.add_dependency(%q<rubyzip>, [">= 0"])
|
49
66
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
50
67
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
51
68
|
s.add_dependency(%q<bundler>, [">= 0"])
|
52
69
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
53
70
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
71
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
72
|
+
s.add_dependency(%q<aruba>, [">= 0"])
|
54
73
|
end
|
55
74
|
else
|
75
|
+
s.add_dependency(%q<commander>, [">= 0"])
|
76
|
+
s.add_dependency(%q<rubyzip>, [">= 0"])
|
56
77
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
57
78
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
58
79
|
s.add_dependency(%q<bundler>, [">= 0"])
|
59
80
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
60
81
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
82
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
83
|
+
s.add_dependency(%q<aruba>, [">= 0"])
|
61
84
|
end
|
62
85
|
end
|
63
86
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.43
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: commander
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rubyzip
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
14
46
|
- !ruby/object:Gem::Dependency
|
15
47
|
name: shoulda
|
16
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +123,38 @@ dependencies:
|
|
91
123
|
- - ! '>='
|
92
124
|
- !ruby/object:Gem::Version
|
93
125
|
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: cucumber
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: aruba
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
94
158
|
description: Command-line interface for the Loom Game Engine, brought to you by The
|
95
159
|
Engine Co. (http://theengine.co)
|
96
160
|
email: support@theengine.co
|
@@ -109,10 +173,19 @@ files:
|
|
109
173
|
- Rakefile
|
110
174
|
- VERSION
|
111
175
|
- bin/loom
|
112
|
-
- lib/
|
176
|
+
- lib/helper.rb
|
177
|
+
- lib/loom/config.rb
|
178
|
+
- lib/loom/init.rb
|
179
|
+
- lib/loom/login.rb
|
180
|
+
- lib/loom/logout.rb
|
181
|
+
- lib/loom/new.rb
|
182
|
+
- lib/loom/ping.rb
|
183
|
+
- lib/loom/run.rb
|
184
|
+
- lib/loom/sdk.rb
|
185
|
+
- lib/loom/use.rb
|
186
|
+
- lib/templates/Main.build.erb
|
187
|
+
- lib/templates/Program.ls.erb
|
113
188
|
- loom.gemspec
|
114
|
-
- test/helper.rb
|
115
|
-
- test/test_loom.rb
|
116
189
|
homepage: http://www.theengine.co
|
117
190
|
licenses: []
|
118
191
|
post_install_message:
|
@@ -127,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
200
|
version: '0'
|
128
201
|
segments:
|
129
202
|
- 0
|
130
|
-
hash:
|
203
|
+
hash: 4584131822068820033
|
131
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
205
|
none: false
|
133
206
|
requirements:
|
data/lib/loom.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'fileutils'
|
3
|
-
require 'optparse'
|
4
|
-
|
5
|
-
class Loom
|
6
|
-
@options = {}
|
7
|
-
|
8
|
-
def self.generate_new_loom(dir)
|
9
|
-
if dir.nil?
|
10
|
-
puts "Unable to generate new loom project, dir is nil"
|
11
|
-
else
|
12
|
-
if @options[:verbose] then puts "Making directory #{dir}" end
|
13
|
-
|
14
|
-
create_directory dir
|
15
|
-
|
16
|
-
#TODO These templates either need to be bundled with the gem,
|
17
|
-
#or downloadedfrom the server.
|
18
|
-
#FileUtils.cp_r "/Users/natebeck/Desktop/LoomScriptDev/.", dir
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.process()
|
23
|
-
|
24
|
-
OptionParser.new do |opts|
|
25
|
-
opts.banner = "Usage: example.rb [options]"
|
26
|
-
|
27
|
-
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
28
|
-
@options[:verbose] = v
|
29
|
-
end
|
30
|
-
end.parse!
|
31
|
-
|
32
|
-
if @options[:verbose] then puts "I AM VERBOSE!" end
|
33
|
-
|
34
|
-
#p options
|
35
|
-
#p ARGV
|
36
|
-
|
37
|
-
action = ARGV[0]
|
38
|
-
|
39
|
-
case action
|
40
|
-
when "new"
|
41
|
-
generate_new_loom ARGV[1]
|
42
|
-
when "init", "s"
|
43
|
-
puts "Do it here!"
|
44
|
-
else
|
45
|
-
puts "Whatcha trying to do?"
|
46
|
-
# TODO Run Help
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def self.create_directory(path)
|
53
|
-
if !File.directory?(path)
|
54
|
-
FileUtils.mkdir_p path
|
55
|
-
puts "Created directory: #{path}"
|
56
|
-
else
|
57
|
-
puts "Skipped directory: #{path}" unless(path == Dir.pwd)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
data/test/helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'shoulda'
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
-
require 'loom'
|
16
|
-
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
end
|