@@ -5,19 +5,31 @@ const core = require('@actions/core')
55const exec = require ( '@actions/exec' )
66const common = require ( './common' )
77
8+ const inputDefaults = {
9+ 'ruby-version' : 'default' ,
10+ 'bundler' : 'default' ,
11+ 'working-directory' : '.' ,
12+ }
13+
814export async function run ( ) {
915 try {
10- await main ( )
16+ const options = { }
17+ for ( const key in inputDefaults ) {
18+ options [ key ] = core . getInput ( key )
19+ }
20+ await setupRuby ( options )
1121 } catch ( error ) {
1222 core . setFailed ( error . message )
1323 }
1424}
1525
16- async function main ( ) {
17- process . chdir ( core . getInput ( 'working-directory' ) )
26+ export async function setupRuby ( options ) {
27+ const inputs = { ...inputDefaults , ...options }
28+
29+ process . chdir ( inputs [ 'working-directory' ] )
1830
1931 const platform = common . getVirtualEnvironmentName ( )
20- const [ engine , parsedVersion ] = parseRubyEngineAndVersion ( core . getInput ( 'ruby-version' ) )
32+ const [ engine , parsedVersion ] = parseRubyEngineAndVersion ( inputs [ 'ruby-version' ] )
2133
2234 let installer
2335 if ( platform === 'windows-latest' && engine !== 'jruby' ) {
@@ -35,9 +47,9 @@ async function main() {
3547
3648 setupPath ( newPathEntries )
3749
38- if ( core . getInput ( 'bundler' ) !== 'none' ) {
50+ if ( inputs [ 'bundler' ] !== 'none' ) {
3951 await common . measure ( 'Installing Bundler' , async ( ) =>
40- installBundler ( platform , rubyPrefix , engine , version ) )
52+ installBundler ( inputs [ 'bundler' ] , platform , rubyPrefix , engine , version ) )
4153 }
4254
4355 core . setOutput ( 'ruby-prefix' , rubyPrefix )
@@ -142,8 +154,8 @@ function readBundledWithFromGemfileLock() {
142154 return null
143155}
144156
145- async function installBundler ( platform , rubyPrefix , engine , rubyVersion ) {
146- var bundlerVersion = core . getInput ( 'bundler' )
157+ async function installBundler ( bundlerVersionInput , platform , rubyPrefix , engine , rubyVersion ) {
158+ var bundlerVersion = bundlerVersionInput
147159
148160 if ( bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock' ) {
149161 bundlerVersion = readBundledWithFromGemfileLock ( )
0 commit comments