Class: Jank::Config
- Inherits:
-
Object
- Object
- Jank::Config
- Defined in:
- lib/config.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#go ⇒ Object
readonly
Returns the value of attribute go.
-
#gopaths ⇒ Object
readonly
Returns the value of attribute gopaths.
-
#home ⇒ Object
readonly
Returns the value of attribute home.
-
#janked ⇒ Object
readonly
Returns the value of attribute janked.
-
#janked_gopath ⇒ Object
readonly
Returns the value of attribute janked_gopath.
-
#janked_gopaths ⇒ Object
readonly
Returns the value of attribute janked_gopaths.
-
#janked_local_path ⇒ Object
readonly
Returns the value of attribute janked_local_path.
-
#janked_packge ⇒ Object
readonly
Returns the value of attribute janked_packge.
-
#local_gopath ⇒ Object
readonly
Returns the value of attribute local_gopath.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#pwd ⇒ Object
readonly
Returns the value of attribute pwd.
-
#rsync ⇒ Object
readonly
Returns the value of attribute rsync.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
7 8 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/config.rb', line 7 def initialize # Ignore or include ENV gopath @include_env_gopath = nil # Path to go @go = ENV['JANK_GO'] || `which go`.chomp # Path to rsync @rsync = ENV['JANK_RSYNC'] || `which rsync`.chomp if @go.empty? STDERR.write "go not found" exit(1) end if @rsync.empty? STDERR.write "rsync not found" exit(1) end # Working directory if ENV.has_key? 'TM_DIRECTORY' @pwd = ENV['TM_DIRECTORY'] else @pwd = Dir.pwd end # Home directory @home = Dir.home # Current Go package @package = nil # Janked Go package (might be higher in the filesystem than the current package) @janked_package = nil # Path to root of go package in gopath @janked_gopath = nil # Path to root of go package in local project @janked_local_path = nil # true if this package is to be janked into a gopath @janked = false # ENV supplied gopaths @gopaths = ENV['GOPATH'] || ENV['JANK_GOPATH'] || ENV['TM_GOPATH'] if @gopaths == nil @gopaths = Array.new else @gopaths = @gopaths.split(/:/).select {|p| p != ''} end # Array of janked_gopaths @janked_gopaths = Array.new # The gopath that contains the working directory, null if janked @local_gopath = nil read_config_files @env = ENV if @include_env_gopath == false @env['GOPATH'] = @janked_gopaths.uniq.join(':') else @env['GOPATH'] = (@janked_gopaths + @gopaths).uniq.join(':') end end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
5 6 7 |
# File 'lib/config.rb', line 5 def env @env end |
#go ⇒ Object (readonly)
Returns the value of attribute go.
5 6 7 |
# File 'lib/config.rb', line 5 def go @go end |
#gopaths ⇒ Object (readonly)
Returns the value of attribute gopaths.
5 6 7 |
# File 'lib/config.rb', line 5 def gopaths @gopaths end |
#home ⇒ Object (readonly)
Returns the value of attribute home.
5 6 7 |
# File 'lib/config.rb', line 5 def home @home end |
#janked ⇒ Object (readonly)
Returns the value of attribute janked.
5 6 7 |
# File 'lib/config.rb', line 5 def janked @janked end |
#janked_gopath ⇒ Object (readonly)
Returns the value of attribute janked_gopath.
5 6 7 |
# File 'lib/config.rb', line 5 def janked_gopath @janked_gopath end |
#janked_gopaths ⇒ Object (readonly)
Returns the value of attribute janked_gopaths.
5 6 7 |
# File 'lib/config.rb', line 5 def janked_gopaths @janked_gopaths end |
#janked_local_path ⇒ Object (readonly)
Returns the value of attribute janked_local_path.
5 6 7 |
# File 'lib/config.rb', line 5 def janked_local_path @janked_local_path end |
#janked_packge ⇒ Object (readonly)
Returns the value of attribute janked_packge.
5 6 7 |
# File 'lib/config.rb', line 5 def janked_packge @janked_packge end |
#local_gopath ⇒ Object (readonly)
Returns the value of attribute local_gopath.
5 6 7 |
# File 'lib/config.rb', line 5 def local_gopath @local_gopath end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
5 6 7 |
# File 'lib/config.rb', line 5 def package @package end |
#pwd ⇒ Object (readonly)
Returns the value of attribute pwd.
5 6 7 |
# File 'lib/config.rb', line 5 def pwd @pwd end |
#rsync ⇒ Object (readonly)
Returns the value of attribute rsync.
5 6 7 |
# File 'lib/config.rb', line 5 def rsync @rsync end |