comufyrails 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,10 +13,6 @@ require 'comufyrails'
13
13
  # also print to the log. This is often useful for debugging, but in practise you should provide these with a block.
14
14
  module Comufyrails
15
15
  module Connection
16
-
17
- class IllegalKeyTypeError < StandardError; end
18
- class IllegalValueTypeError < StandardError; end
19
-
20
16
  class << self
21
17
 
22
18
  # Shortened method name for storing a user, or users in your Application.
@@ -78,18 +74,18 @@ module Comufyrails
78
74
  message = JSON.parse(http.response)
79
75
  case message["cd"]
80
76
  when 388 then
81
- p "388 - Success! - data = #{data} - message = #{message}."
77
+ Comufyrails.logger.debug("388 - Success! - data = #{data} - message = #{message}.")
82
78
  when 475 then
83
- p "475 - Invalid parameter provided. - data = #{data} - message = #{message}."
79
+ Comufyrails.logger.debug("475 - Invalid parameter provided. - data = #{data} - message = #{message}.")
84
80
  when 617 then
85
- p "617 - Some of the tags passed are not registered. - data = #{data} - message = #{message}."
81
+ Comufyrails.logger.debug("617 - Some of the tags passed are not registered. - data = #{data} - message = #{message}.")
86
82
  when 632 then
87
- p "632 - _ERROR_FACEBOOK_PAGE_NOT_FOUND - data = #{data} - message = #{message}."
83
+ Comufyrails.logger.debug("632 - _ERROR_FACEBOOK_PAGE_NOT_FOUND - data = #{data} - message = #{message}.")
88
84
  else
89
- p "UNKNOWN RESPONSE - data = #{data} - message = #{message}."
85
+ Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
90
86
  end
91
87
  else
92
- p "Server responded with #{http.response_header}."
88
+ Comufyrails.logger.warn("Server responded with #{http.response_header}.")
93
89
  end
94
90
  end
95
91
  end
@@ -164,30 +160,30 @@ module Comufyrails
164
160
  message = JSON.parse(http.response)
165
161
  case message["cd"]
166
162
  when 383 then
167
- p "383 - Success! - data = #{data} - message = #{message}."
163
+ Comufyrails.logger.debug("383 - Success! - data = #{data} - message = #{message}.")
168
164
  when 416 then
169
- p "416 - _ERROR_MSG_SEND_FAILED - data = #{data} - message = #{message}."
165
+ Comufyrails.logger.debug("416 - _ERROR_MSG_SEND_FAILED - data = #{data} - message = #{message}.")
170
166
  when 475 then
171
- p "475 - Invalid parameters provided - data = #{data} - message = #{message}."
167
+ Comufyrails.logger.debug("475 - Invalid parameters provided - data = #{data} - message = #{message}.")
172
168
  when 551 then
173
- p "551 _ERROR_TAG_VALUE_NOT_FOUND - data = #{data} - message = #{message}."
169
+ Comufyrails.logger.debug("551 _ERROR_TAG_VALUE_NOT_FOUND - data = #{data} - message = #{message}.")
174
170
  when 603 then
175
- p "603 - _ERROR_DOMAIN_APPLICATION_NAME_NOT_FOUND - data = #{data} - message = #{message}."
171
+ Comufyrails.logger.debug("603 - _ERROR_DOMAIN_APPLICATION_NAME_NOT_FOUND - data = #{data} - message = #{message}.")
176
172
  when 607 then
177
- p "607 - _ERROR_UNAUTHORISED_ACTION - data = #{data} - message = #{message}."
173
+ Comufyrails.logger.debug("607 - _ERROR_UNAUTHORISED_ACTION - data = #{data} - message = #{message}.")
178
174
  when 617 then
179
- p "617 - _ERROR_DOMAIN_APPLICATION_TAG_NOT_FOUND - data = #{data} - message = #{message}."
175
+ Comufyrails.logger.debug("617 - _ERROR_DOMAIN_APPLICATION_TAG_NOT_FOUND - data = #{data} - message = #{message}.")
180
176
  when 648 then
181
- p "648 - _ERROR_FACEBOOK_APPLICATION_USER_NOT_FOUND - data = #{data} - message = #{message}."
177
+ Comufyrails.logger.debug("648 - _ERROR_FACEBOOK_APPLICATION_USER_NOT_FOUND - data = #{data} - message = #{message}.")
182
178
  when 673 then
183
- p "673 - Invalid time exception - data = #{data} - message = #{message}."
179
+ Comufyrails.logger.debug("673 - Invalid time exception - data = #{data} - message = #{message}.")
184
180
  when 679 then
185
- p "679 - _ERROR_MALFORMED_TARGETING_EXPRESSION - data = #{data} - message = #{message}."
181
+ Comufyrails.logger.debug("679 - _ERROR_MALFORMED_TARGETING_EXPRESSION - data = #{data} - message = #{message}.")
186
182
  else
187
- p "UNKNOWN RESPONSE - data = #{data} - message = #{message}."
183
+ Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
188
184
  end
189
185
  else
190
- p "Server responded with #{http.response_header}."
186
+ Comufyrails.logger.warn("Server responded with #{http.response_header}.")
191
187
  end
192
188
  end
193
189
  end
@@ -211,13 +207,13 @@ module Comufyrails
211
207
  else
212
208
  case message["cd"]
213
209
  when 219 then
214
- p "219 - Success! - data = #{data} - message = #{message}."
210
+ Comufyrails.logger.debug("219 - Success! - data = #{data} - message = #{message}.")
215
211
  else
216
- p "UNKNOWN RESPONSE - data = #{data} - message = #{message}."
212
+ Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
217
213
  end
218
214
  end
219
215
  else
220
- p "Server responded with #{http.response_header}."
216
+ Comufyrails.logger.warn("Server responded with #{http.response_header}.")
221
217
  end
222
218
  end
223
219
  end
@@ -225,10 +221,11 @@ module Comufyrails
225
221
  def user(facebook_id)
226
222
  filter = "FACEBOOK.ID=\"#{facebook_id}\""
227
223
  self.users(filter) do |users, total, to, from|
228
- user = users.first
229
- account = user.delete("account")
230
- tags = user.delete("tagValues")
231
- yield account, tags, [users, total, to, from]
224
+ user = users.delete_at(0)
225
+ account = user ? user.delete("account") : { }
226
+ tags = user ? user.delete("tagValues") : { }
227
+ other = { users: users, total: total, to: to, from: from }.with_indifferent_access
228
+ yield account, tags, other
232
229
  end
233
230
  end
234
231
 
@@ -250,25 +247,30 @@ module Comufyrails
250
247
  http = EventMachine::HttpRequest.new(Comufyrails.config.url).post(
251
248
  :body => { request: data.to_json }, :initheader => { 'Content-Type' => 'application/json' })
252
249
  if http.response_header.status == 200
253
- message = JSON.parse(http.response)
250
+ message = JSON.parse(http.response).with_indifferent_access
251
+ blocks = message.clone.delete("timeBlocks")
252
+ total = blocks.first ? blocks.first.delete("total") : 0
253
+ to = blocks.first ? blocks.first.delete("to") : 0
254
+ from = blocks.first ? blocks.first.delete("from") : 0
255
+ users = blocks.first && total > 0 ? blocks.first.delete("data") : [ ]
256
+
254
257
  if block_given?
255
- total = message["timeBlocks"][0]["total"]
256
- users = message["timeBlocks"][0]["data"]
257
- to = message["timeBlocks"][0]["to"]
258
- from = message["timeBlocks"][0]["from"]
259
258
  yield users, total, to, from
260
259
  else
261
260
  case message["cd"]
262
261
  when 382 then
263
- p "382 - Success! - data = #{data} - message = #{message}."
262
+ Comufyrails.logger.debug("382 - Success! - data = #{data} - message = #{message}.")
263
+ Comufyrails.logger.info("#{total} user(s) were found matching your filter.\n #{users}")
264
264
  when 692 then
265
- p "692 - Invalid filter/filter not found - data = #{data} - message = #{message}."
265
+ Comufyrails.logger.debug("692 - Invalid filter/filter not found - data = #{data} - message = #{message}.")
266
+ Comufyrails.logger.info("Invalid filter/filter not found.\n #{users}")
266
267
  else
267
- p "UNKNOWN RESPONSE - data = #{data} - message = #{message}."
268
+ Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
269
+ Comufyrails.logger.info("Unknown response from server.\n #{users}")
268
270
  end
269
271
  end
270
272
  else
271
- p "Server responded with #{http.response_header}."
273
+ Comufyrails.logger.warn("Server responded with #{http.response_header}, rather than the expected 200.")
272
274
  end
273
275
  end
274
276
  end
@@ -1,16 +1,17 @@
1
1
  require 'rails'
2
2
  require 'comufyrails'
3
3
 
4
+ # :nodoc:
4
5
  class Comufyrails::Railtie < Rails::Railtie
5
6
 
6
- # this allows users to manage settings just like they manage rails settings
7
- config.comufy_rails = ActiveSupport::OrderedOptions.new # enable namespaced configuration in Rails environment
7
+ # enable namespaced configuration in Rails environment
8
+ config.comufy_rails = ActiveSupport::OrderedOptions.new
8
9
 
9
- # initialize our logger
10
10
  initializer 'Rails logger' do
11
11
  Comufyrails.logger = Rails.logger
12
12
  end
13
13
 
14
+ # configure the key settings that Comufyrails requires to functions
14
15
  initializer "comufyrails.configure" do |app|
15
16
  Comufyrails.configure do |c|
16
17
  c.app_name = app.config.comufy_rails[:app_name] || ENV.fetch('COMUFY_APP_NAME', ::Rails.application.class.to_s.split("::").first)
@@ -1,4 +1,4 @@
1
1
  module Comufyrails
2
2
  # Current version of this gem.
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.8"
4
4
  end
data/lib/comufyrails.rb CHANGED
@@ -6,6 +6,7 @@ require "comufyrails/constants"
6
6
  require "comufyrails/connection"
7
7
  require 'comufyrails/railtie' if defined?(Rails)
8
8
 
9
+ # :nodoc:
9
10
  module Comufyrails
10
11
 
11
12
  # Contains the list of constant variables that will be used throughout this gem.
@@ -21,7 +22,6 @@ module Comufyrails
21
22
  end
22
23
 
23
24
  class << self
24
- # Comufyrails logger (usually uses the Rails.logger)
25
25
  attr_accessor :logger
26
26
 
27
27
  # define as a Config object unless defined
@@ -11,24 +11,20 @@ namespace :comufy do
11
11
  args.with_defaults(type: 'STRING')
12
12
 
13
13
  if Comufyrails.config.app_name.blank?
14
- p "
15
- Cannot find the application name, is it currently set to nil or an empty string? Please check
16
- config.comufy_rails.app_name in your environment initializer or the environment variable
17
- COMUFY_APP_NAME are valid strings. And remember you need to register your application with Comufy first with
18
- the comufy:app rake command."
14
+ Comufyrails.logger.info("Cannot find the application name, is it currently set to nil or an empty string? Please check
15
+ config.comufy_rails.app_name in your environment initializer or the environment variable
16
+ COMUFY_APP_NAME are valid strings. And remember you need to register your application with Comufy
17
+ first with the comufy:app rake command.")
19
18
  elsif Comufyrails.config.url.blank?
20
- p "
21
- Cannot find the base api url, is it currently set to nil or an empty string?\n
22
- Please check config.comufy_rails.url in your environment initializer or the environment variable
23
- COMUFY_URL are valid strings."
19
+ Comufyrails.logger.info("Cannot find the base api url, is it currently set to nil or an empty string?\n
20
+ Please check config.comufy_rails.url in your environment initializer or the environment variable
21
+ COMUFY_URL are valid strings.")
24
22
  elsif Comufyrails.config.access_token.blank?
25
- p "
26
- Cannot find the access token, is it currently set to nil or an empty string?\n
27
- Please check config.comufy_rails.access_token in your environment initializer or the environment variable
28
- COMUFY_TOKEN are valid strings."
23
+ Comufyrails.logger.info("Cannot find the access token, is it currently set to nil or an empty string?\n
24
+ Please check config.comufy_rails.access_token in your environment initializer or the environment
25
+ variable COMUFY_TOKEN are valid strings.")
29
26
  elsif not Comufyrails::LEGAL_TYPES.include?(args.type)
30
- p "
31
- The type must be #{Comufyrails::LEGAL_TYPES.to_sentence(two_words_connector: ' or ', last_word_connector: ', or ')}"
27
+ Comufyrails.logger.info("The type must be #{Comufyrails::LEGAL_TYPES.to_sentence(last_word_connector: ', or ')}")
32
28
  else
33
29
  data = {
34
30
  cd: 86,
@@ -51,20 +47,21 @@ The type must be #{Comufyrails::LEGAL_TYPES.to_sentence(two_words_connector: ' o
51
47
  message = JSON.parse(response.read_body)
52
48
  case message["cd"]
53
49
  when 386 then
54
- p "386 - Success! - data = #{data} - message = #{message}."
50
+ Comufyrails.logger.debug("386 - Success! - data = #{data} - message = #{message}.")
55
51
  when 475 then
56
- p "475 - Invalid parameters provided - data = #{data} - message = #{message}."
52
+ Comufyrails.logger.debug("475 - Invalid parameters provided - data = #{data} - message = #{message}.")
57
53
  when 603 then
58
- p "603 - _ERROR_DOMAIN_APPLICATION_NAME_NOT_FOUND - data = #{data} - message = #{message}."
54
+ Comufyrails.logger.debug("603 - _ERROR_DOMAIN_APPLICATION_NAME_NOT_FOUND - data = #{data} - message = #{message}.")
59
55
  when 607 then
60
- p "607 - _ERROR_UNAUTHORISED_ACTION - data = #{data} - message = #{message}."
56
+ Comufyrails.logger.debug("607 - _ERROR_UNAUTHORISED_ACTION - data = #{data} - message = #{message}.")
61
57
  when 618 then
62
- p "618 - _ERROR_DOMAIN_APPLICATION_TAG_ALREADY_REGISTERED - data = #{data} - message = #{message}."
58
+ Comufyrails.logger.debug("618 - _ERROR_DOMAIN_APPLICATION_TAG_ALREADY_REGISTERED - data = #{data} - message = #{message}.")
63
59
  else
64
- p "UNKNOWN RESPONSE - data = #{data} - message = #{message}."
60
+ Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
65
61
  end
66
62
  else
67
- p "Authentication failed when sending #{data}. Please get in touch with Comufy if you cannot resolve this."
63
+ Comufyrails.logger.debug("Rake task comufy:tag failed when sending #{data}.")
64
+ Comufyrails.logger.warn("Authentication failed. Please get in touch with Comufy if you cannot resolve this.")
68
65
  end
69
66
  end
70
67
  end
@@ -74,21 +71,18 @@ The type must be #{Comufyrails::LEGAL_TYPES.to_sentence(two_words_connector: ' o
74
71
  raise ArgumentError, "Must specify a name for the tag." unless args.name
75
72
 
76
73
  if Comufyrails.config.app_name.blank?
77
- puts "
78
- Cannot find the application name, is it currently set to nil or an empty string? Please check
79
- config.comufy_rails.app_name in your environment initializer or the environment variable
80
- COMUFY_APP_NAME are valid strings. And remember you need to register your application with Comufy first with
81
- the comufy:app rake command."
74
+ Comufyrails.logger.info("Cannot find the application name, is it currently set to nil or an empty string? Please check
75
+ config.comufy_rails.app_name in your environment initializer or the environment variable
76
+ COMUFY_APP_NAME are valid strings. And remember you need to register your application with Comufy
77
+ first with the comufy:app rake command.")
82
78
  elsif Comufyrails.config.url.blank?
83
- p "
84
- Cannot find the base api url, is it currently set to nil or an empty string?
85
- Please check config.comufy_rails.url in your environment initializer or the environment variable
86
- COMUFY_URL are valid strings."
79
+ Comufyrails.logger.info("Cannot find the base api url, is it currently set to nil or an empty string?\n
80
+ Please check config.comufy_rails.url in your environment initializer or the environment variable
81
+ COMUFY_URL are valid strings.")
87
82
  elsif Comufyrails.config.access_token.blank?
88
- p "
89
- Cannot find the access token, is it currently set to nil or an empty string?
90
- Please check config.comufy_rails.access_token in your environment initializer or the environment variable
91
- COMUFY_TOKEN are valid strings."
83
+ Comufyrails.logger.info("Cannot find the access token, is it currently set to nil or an empty string?\n
84
+ Please check config.comufy_rails.access_token in your environment initializer or the environment
85
+ variable COMUFY_TOKEN are valid strings.")
92
86
  else
93
87
  data = {
94
88
  cd: 85,
@@ -108,20 +102,21 @@ COMUFY_TOKEN are valid strings."
108
102
  message = JSON.parse(response.read_body)
109
103
  case message['cd']
110
104
  when 385 then
111
- p "385 - Success! - data = #{data} - message = #{message}."
105
+ Comufyrails.logger.debug("385 - Success! - data = #{data} - message = #{message}.")
112
106
  when 475 then
113
- p "475 - Invalid parameters provided - data = #{data} - message = #{message}."
107
+ Comufyrails.logger.debug("475 - Invalid parameters provided - data = #{data} - message = #{message}.")
114
108
  when 603 then
115
- p "603 - _ERROR_DOMAIN_APPLICATION_NAME_NOT_FOUND - data = #{data} - message = #{message}."
109
+ Comufyrails.logger.debug("603 - _ERROR_DOMAIN_APPLICATION_NAME_NOT_FOUND - data = #{data} - message = #{message}.")
116
110
  when 607 then
117
- p "607 - _ERROR_UNAUTHORISED_ACTION - data = #{data} - message = #{message}."
111
+ Comufyrails.logger.debug("607 - _ERROR_UNAUTHORISED_ACTION - data = #{data} - message = #{message}.")
118
112
  when 617 then
119
- p "617 - _ERROR_DOMAIN_APPLICATION_TAG_NOT_FOUND - data = #{data} - message = #{message}."
113
+ Comufyrails.logger.debug("617 - _ERROR_DOMAIN_APPLICATION_TAG_NOT_FOUND - data = #{data} - message = #{message}.")
120
114
  else
121
- p "UNKNOWN RESPONSE - data = #{data} - message = #{message}."
115
+ Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
122
116
  end
123
117
  else
124
- p "Authentication failed when sending #{data}. Please get in touch with Comufy if you cannot resolve this."
118
+ Comufyrails.logger.debug("Rake task comufy:tag failed when sending #{data}.")
119
+ Comufyrails.logger.warn("Authentication failed. Please get in touch with Comufy if you cannot resolve this.")
125
120
  end
126
121
  end
127
122
  end
@@ -134,15 +129,13 @@ COMUFY_TOKEN are valid strings."
134
129
  raise ArgumentError, "Must specify a description for the application." unless args.description
135
130
 
136
131
  if Comufyrails.config.url.blank?
137
- p "
138
- Cannot find the base api url, is it currently set to nil or an empty string?\n
139
- Please check config.comufy_rails.url in your environment initializer or the environment variable
140
- COMUFY_URL are valid strings."
132
+ Comufyrails.logger.info("Cannot find the base api url, is it currently set to nil or an empty string?
133
+ Please check config.comufy_rails.url in your environment initializer or the environment variable
134
+ COMUFY_URL are valid strings.")
141
135
  elsif Comufyrails.config.access_token.blank?
142
- p "
143
- Cannot find the access token, is it currently set to nil or an empty string?\n
144
- Please check config.comufy_rails.access_token in your environment initializer or the environment variable
145
- COMUFY_TOKEN are valid strings."
136
+ Comufyrails.logger.info("Cannot find the access token, is it currently set to nil or an empty string?
137
+ Please check config.comufy_rails.access_token in your environment initializer or the environment
138
+ variable COMUFY_TOKEN are valid strings.")
146
139
  else
147
140
  data = {
148
141
  cd: 106,
@@ -164,18 +157,19 @@ COMUFY_TOKEN are valid strings."
164
157
  message = JSON.parse(response.read_body)
165
158
  case message['cd']
166
159
  when 205 then
167
- p "205 - Success! - data = #{data} - message = #{message}."
160
+ Comufyrails.logger.debug("205 - Success! - data = #{data} - message = #{message}.")
168
161
  when 602 then
169
- p "602 - _ERROR_DOMAIN_APPLICATION_NAME_ALREADY_REGISTERED - data = #{data} - message = #{message}."
162
+ Comufyrails.logger.debug("602 - _ERROR_DOMAIN_APPLICATION_NAME_ALREADY_REGISTERED - data = #{data} - message = #{message}.")
170
163
  when 619 then
171
- p "619 - _ERROR_DOMAIN_APPLICATION_ALREADY_REGISTERED_UNDER_DIFFERENT_NAME - data = #{data} - message = #{message}."
164
+ Comufyrails.logger.debug("619 - _ERROR_DOMAIN_APPLICATION_ALREADY_REGISTERED_UNDER_DIFFERENT_NAME - data = #{data} - message = #{message}.")
172
165
  when 645 then
173
- p "645 - _ERROR_FACEBOOK_AUTHORISATION_FAILURE - data = #{data} - message = #{message}."
166
+ Comufyrails.logger.debug("645 - _ERROR_FACEBOOK_AUTHORISATION_FAILURE - data = #{data} - message = #{message}.")
174
167
  else
175
- p "UNKNOWN RESPONSE - data = #{data} - message = #{message}."
168
+ Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
176
169
  end
177
170
  else
178
- p "Authentication failed when sending #{data}. Please get in touch with Comufy if you cannot resolve this."
171
+ Comufyrails.logger.debug("Rake task comufy:tag failed when sending #{data}.")
172
+ Comufyrails.logger.warn("Authentication failed. Please get in touch with Comufy if you cannot resolve this.")
179
173
  end
180
174
  end
181
175
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comufyrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-11 00:00:00.000000000 Z
12
+ date: 2013-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -99,7 +99,6 @@ extensions: []
99
99
  extra_rdoc_files: []
100
100
  files:
101
101
  - .gitignore
102
- - .rvmrc
103
102
  - Gemfile
104
103
  - LICENSE.txt
105
104
  - README.md
@@ -135,5 +134,5 @@ rubyforge_project:
135
134
  rubygems_version: 1.8.24
136
135
  signing_key:
137
136
  specification_version: 3
138
- summary: comufyrails-0.1.6
137
+ summary: comufyrails-0.1.8
139
138
  test_files: []
data/.rvmrc DELETED
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
- # Only full ruby name is supported here, for short names use:
8
- # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3-p327@comufyrails"
10
-
11
- # Uncomment the following lines if you want to verify rvm version per project
12
- # rvmrc_rvm_version="1.17.3 (master)" # 1.10.1 seams as a safe start
13
- # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
- # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
- # return 1
16
- # }
17
-
18
- # First we attempt to load the desired environment directly from the environment
19
- # file. This is very fast and efficient compared to running through the entire
20
- # CLI and selector. If you want feedback on which environment was used then
21
- # insert the word 'use' after --create as this triggers verbose mode.
22
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
- then
25
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
- [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
- \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
- else
29
- # If the environment file has not yet been created, use the RVM CLI to select.
30
- rvm --create "$environment_id" || {
31
- echo "Failed to create RVM environment '${environment_id}'."
32
- return 1
33
- }
34
- fi
35
-
36
- # If you use bundler, this might be useful to you:
37
- # if [[ -s Gemfile ]] && {
38
- # ! builtin command -v bundle >/dev/null ||
39
- # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
- # }
41
- # then
42
- # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
- # gem install bundler
44
- # fi
45
- # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
- # then
47
- # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
- # fi