short_message 0.1.0 → 1.0.0

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +18 -10
  4. data/Rakefile +18 -8
  5. data/app/controllers/short_message/application_controller.rb +1 -0
  6. data/app/controllers/short_message/messages_controller.rb +20 -0
  7. data/app/mailers/application_mailer.rb +3 -0
  8. data/app/mailers/short_message/mailer.rb +5 -15
  9. data/app/models/short_message/message.rb +27 -61
  10. data/config/routes.rb +5 -1
  11. data/db/migrate/20130308133457_create_short_message_messages.rb +1 -1
  12. data/lib/generators/short_message/templates/config/initializers/short_message.rb +10 -10
  13. data/lib/generators/short_message/templates/config/locales/short_message.de.yml +5 -11
  14. data/lib/generators/short_message/templates/config/locales/short_message.en.yml +5 -11
  15. data/lib/short_message/config.rb +3 -4
  16. data/lib/short_message/engine.rb +3 -4
  17. data/lib/short_message/version.rb +1 -1
  18. data/test/dummy/README.rdoc +28 -0
  19. data/{spec → test}/dummy/Rakefile +1 -2
  20. data/{spec → test}/dummy/app/assets/javascripts/application.js +4 -6
  21. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  22. data/test/dummy/app/controllers/application_controller.rb +5 -0
  23. data/{spec → test}/dummy/app/helpers/application_helper.rb +0 -0
  24. data/{spec → test}/dummy/app/views/layouts/application.html.erb +1 -2
  25. data/test/dummy/bin/bundle +3 -0
  26. data/test/dummy/bin/rails +4 -0
  27. data/test/dummy/bin/rake +4 -0
  28. data/test/dummy/bin/setup +29 -0
  29. data/test/dummy/config/application.rb +26 -0
  30. data/test/dummy/config/boot.rb +5 -0
  31. data/test/dummy/config/database.yml +54 -0
  32. data/test/dummy/config/environment.rb +5 -0
  33. data/test/dummy/config/environments/development.rb +41 -0
  34. data/test/dummy/config/environments/production.rb +79 -0
  35. data/test/dummy/config/environments/test.rb +42 -0
  36. data/test/dummy/config/initializers/assets.rb +11 -0
  37. data/{spec → test}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  38. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  39. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  40. data/{spec → test}/dummy/config/initializers/inflections.rb +6 -5
  41. data/{spec → test}/dummy/config/initializers/mime_types.rb +0 -1
  42. data/test/dummy/config/initializers/session_store.rb +3 -0
  43. data/{spec → test}/dummy/config/initializers/wrap_parameters.rb +6 -6
  44. data/test/dummy/config/locales/en.yml +23 -0
  45. data/{spec → test}/dummy/config/routes.rb +0 -0
  46. data/test/dummy/config/secrets.yml +22 -0
  47. data/test/dummy/config.ru +4 -0
  48. data/{spec/dummy/public/favicon.ico → test/dummy/log/development.log} +0 -0
  49. data/test/dummy/public/404.html +67 -0
  50. data/test/dummy/public/422.html +67 -0
  51. data/test/dummy/public/500.html +66 -0
  52. data/test/dummy/public/favicon.ico +0 -0
  53. data/test/integration/navigation_test.rb +8 -0
  54. data/test/short_message_test.rb +7 -0
  55. data/test/test_helper.rb +21 -0
  56. metadata +87 -164
  57. data/spec/config_helper.rb +0 -15
  58. data/spec/dummy/README.rdoc +0 -261
  59. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  60. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  61. data/spec/dummy/config/application.rb +0 -65
  62. data/spec/dummy/config/boot.rb +0 -10
  63. data/spec/dummy/config/database.example.yml +0 -42
  64. data/spec/dummy/config/environment.rb +0 -5
  65. data/spec/dummy/config/environments/development.rb +0 -37
  66. data/spec/dummy/config/environments/production.rb +0 -67
  67. data/spec/dummy/config/environments/test.rb +0 -37
  68. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  69. data/spec/dummy/config/initializers/session_store.rb +0 -8
  70. data/spec/dummy/config/locales/en.yml +0 -5
  71. data/spec/dummy/config/locales/short_message.de.yml +0 -14
  72. data/spec/dummy/config/locales/short_message.en.yml +0 -14
  73. data/spec/dummy/config.ru +0 -4
  74. data/spec/dummy/public/404.html +0 -26
  75. data/spec/dummy/public/422.html +0 -26
  76. data/spec/dummy/public/500.html +0 -25
  77. data/spec/dummy/script/rails +0 -6
  78. data/spec/factories/short_message_messages.rb +0 -17
  79. data/spec/mailers/short_message/mailer_spec.rb +0 -64
  80. data/spec/models/short_message/config_spec.rb +0 -17
  81. data/spec/models/short_message/message_spec.rb +0 -52
  82. data/spec/spec_helper.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c279adb74034281791d363ed71482435e27abc7
4
- data.tar.gz: 3fdecf7b086165361a255c65448bf0bee39d7814
3
+ metadata.gz: d987538fe6cd5c550bbf3612cae44a45fb4a08e7
4
+ data.tar.gz: 1335ad39e09979ccaae3097cb02f7f48620d6489
5
5
  SHA512:
6
- metadata.gz: a28908e48e31fcc3c04681a60a9ef042a475964866f99317478de60bb73070fe5b4f93696dcc2e499b5cf57f05b1abf8074f977f6e82b240cf1b3066e3f38ae7
7
- data.tar.gz: 5857e907d60d7d9a213c80ffa1088e8c08c59f49a5cd8e66e35f743506e70b501295e1752128029e240b135b707155fd21e0fea52bbe5302cf741dc4556dfbcb
6
+ metadata.gz: 6f5d5d95c78f15da9a21db1cc6f07e26d872d426421829840fe289704c6500f8a3fa8df7be917f92b35d3b090711b4edebf26486d106e3a8ae2f3ca4e857aad4
7
+ data.tar.gz: de7b38d19b85bf706d3010233aa5efccd63ba392e81406996382f909d824b0e079092f5fdd812173bd47e14aaa4a0f0dc04a0fce16f6cc6125c18cbfe26eab1c
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2013 YOURNAME
1
+ Copyright 2016 Andi Saurer
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # ShortMessage #
1
+ # ShortMessage
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/short_message.png)](http://badge.fury.io/rb/short_message)
4
4
 
5
- ## Installation ##
5
+ ## Installation
6
6
 
7
7
  Add it to your Gemfile:
8
8
 
@@ -22,30 +22,38 @@ Run the generator:
22
22
  rails generate short_message:install
23
23
  ```
24
24
 
25
- And rake the migrations:
25
+ And run the migrations:
26
+
26
27
  ```console
27
28
  rake db:migrate
28
29
  ```
29
- ## Usage ##
30
+
31
+ ## Usage
30
32
 
31
33
  Create a message and deliver it:
34
+
32
35
  ```ruby
33
- @sms = ShortMessage::Message.new(:sender => "0041791234567", :recipient => "0041799876543", :text => "Hello World!")
36
+ @sms = ShortMessage::Message.new(sender: "0041791234567", recipient: "0041799876543", text: "Hello World!")
34
37
  @sms.deliver
35
38
  ```
36
- ## Customization ##
37
- ### Status Codes ##
39
+
40
+ ## Customization
41
+
42
+ ### Status Codes
43
+
38
44
  If you need to customize the status response codes simply edit the internationalization files in config/locales
39
45
 
40
- ### Params ###
41
- To override the params string add this to an initializer file (or put it into config/initializers/short_message.rb)
46
+ ### Params
47
+
48
+ To override the params string add the code below into `config/initializers/short_message.rb`:
49
+
42
50
  ```ruby
43
51
  ShortMessage::Message.module_eval do
44
52
  private
45
53
  def build_deliver_params_string
46
54
  # your code here
47
55
  end
48
-
56
+
49
57
  def build_recharge_params_string amount
50
58
  # your code here
51
59
  end
data/Rakefile CHANGED
@@ -1,16 +1,10 @@
1
- #!/usr/bin/env rake
2
1
  begin
3
2
  require 'bundler/setup'
4
3
  rescue LoadError
5
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
5
  end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
6
+
7
+ require 'rdoc/task'
14
8
 
15
9
  RDoc::Task.new(:rdoc) do |rdoc|
16
10
  rdoc.rdoc_dir = 'rdoc'
@@ -20,8 +14,24 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
14
  rdoc.rdoc_files.include('lib/**/*.rb')
21
15
  end
22
16
 
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
23
22
 
24
23
 
25
24
 
26
25
  Bundler::GemHelper.install_tasks
27
26
 
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -1,4 +1,5 @@
1
1
  module ShortMessage
2
2
  class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
3
4
  end
4
5
  end
@@ -0,0 +1,20 @@
1
+ require_dependency "short_message/application_controller"
2
+
3
+ module ShortMessage
4
+ class MessagesController < ApplicationController
5
+ def status
6
+ unless params[:id].blank? or params[:status].blank?
7
+ if message = ShortMessage::Message.find_by(message_key: params[:id])
8
+ message.status_code = params[:status]
9
+ message.save!
10
+
11
+ render plain: "Message #{params[:id]} has now status #{params[:status]}"
12
+ else
13
+ render plain: "Message #{params[:id]} not found!", status: 404
14
+ end
15
+ else
16
+ render plain: "Message ID or status not provided!", status: 400
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: ShortMessage.config.default_mail_sender
3
+ end
@@ -1,21 +1,11 @@
1
1
  module ShortMessage
2
- class Mailer < ActionMailer::Base
3
- default from: ShortMessage.config.default_mail_sender
4
-
5
- def recharge_notification amount
6
- mail to: ShortMessage.config.reload_notification_email, :subject => "SMS credit recharged", :body => "Your SMS Account has automatically been recharged with #{amount} sms."
7
- end
8
-
9
- def voucher_notification amount
10
- mail :to => ShortMessage.config.voucher_notification_email, :subject => "SMS credit recharged, please create a voucher", :body => "Please add a voucher:\r\nCustomer: #{ShortMessage.config.user_id}\r\nAmount: #{amount} sms\r\n\r\nThank you!"
11
- end
12
-
13
- def recharge_failed_notification amount, message
14
- mail :to => ShortMessage.config.reload_notification_email, :subject => "SMS credit recharge failed", :body =>"SMS account could not be recharged with #{amount} sms. Error: #{body}"
2
+ class Mailer < ApplicationMailer
3
+ def error_notification message, response
4
+ mail to: ShortMessage.config.admin_notification_email, subject: "Error delivering SMS to #{message.recipient}", body: "SMS from #{message.sender} to #{message.recipient} could not be sent!\r\n\r\nResponse: #{response.to_yaml}"
15
5
  end
16
6
 
17
- def error_notification message, response
18
- mail :to => ShortMessage.config.reload_notification_email, :subject => "Error delivering SMS to #{message.recipient}", :body =>"SMS from #{message.sender} to #{message.recipient} could not be sent!\r\n\r\nResponse: #{response.to_yaml}"
7
+ def payment_required_notification
8
+ mail to: ShortMessage.config.reload_notification_email, subject: "SMS Gateway requires payment", body: "Your SMS Gateway API #{ShortMessage.config.gateway_server} requires payment!"
19
9
  end
20
10
  end
21
11
  end
@@ -1,13 +1,5 @@
1
- require "net/http"
2
-
3
1
  module ShortMessage
4
2
  class Message < ActiveRecord::Base
5
- attr_accessible :message_key, :recipient, :sender, :status_code, :text
6
-
7
- def status_text
8
- I18n.t("short_message.status.code_#{self.status_code}")
9
- end
10
-
11
3
  def deliver
12
4
  self.sender = ShortMessage.config.default_sms_sender if self.sender.blank?
13
5
 
@@ -17,78 +9,52 @@ module ShortMessage
17
9
  http.use_ssl = true
18
10
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
19
11
  end
20
- response, data = http.post(ShortMessage.config.send_file_path, build_deliver_params_string)
21
12
 
22
- if response.code == "200"
23
- # returns something like 0:200: OK (<mobilenumber>:<msgid>)
24
- result_set = response.body.gsub("(","").gsub(")","").split(":")
25
- self.status_code = result_set[0].to_i
26
- self.message_key = result_set[3] unless result_set[3].blank?
13
+ response, data = http.post(ShortMessage.config.send_file_path, build_deliver_params_string)
27
14
 
28
- if self.status_code == 3 and ShortMessage.config.default_reload_amount > 0
29
- if self.recharge
30
- self.deliver
31
- else
32
- self.status_code = 99
33
- return false
34
- end
15
+ if response.code == "200" or response.code == "402"
16
+ if response.code == "402" and not ShortMessage.config.reload_notification_email.blank?
17
+ ShortMessage::Mailer.payment_required_notification(self, response).deliver_now
35
18
  end
36
19
 
37
- self.save
38
- true
20
+ result_set = response.body.gsub("(","").gsub(")","").split(" ")
21
+ self.message_key = result_set[2] unless result_set[2].blank?
22
+
23
+ return self.save
39
24
  else
40
- Mailer.error_notification(self, response).deliver unless ShortMessage.config.admin_notification_email.blank?
41
- false
25
+ ShortMessage::Mailer.error_notification(self, response).deliver_now unless ShortMessage.config.admin_notification_email.blank?
42
26
  end
27
+ else
28
+ return false
43
29
  end
44
30
  end
45
31
 
46
- def recharge amount = ShortMessage.config.default_reload_amount
47
- unless ShortMessage.config.account_functions_path.blank?
48
- http = Net::HTTP.new(ShortMessage.config.gateway_server)
49
- response, body = http.post(ShortMessage.config.account_functions_path, build_recharge_params_string(amount))
50
-
51
- if response.code == "200"
52
- # returns something like 0:Successful
53
- result_set = response.body.split(":")
32
+ def recharge
33
+ raise "NOT YET IMPLEMENTED"
34
+ end
54
35
 
55
- if result_set[0].to_i == 0
56
- logger.info "SMS account successfully charged with #{amount} sms."
57
- Mailer.recharge_notification(amount).deliver unless ShortMessage.config.reload_notification_email.blank?
58
- Mailer.voucher_notification(amount).deliver unless ShortMessage.config.voucher_notification_email.blank?
59
- true
60
- else
61
- logger.warn "SMS account could not be recharged with #{amount} sms. Error: #{body}"
62
- Mailer.recharge_failed_notification(amount, body).deliver unless ShortMessage.config.reload_notification_email.blank?
63
- false
64
- end
65
- else
66
- "#{response.code} #{response.message}"
67
- end
68
- end
36
+ def status_text
37
+ I18n.t("short_message.status.code_#{self.status_code}")
69
38
  end
70
39
 
71
40
  private
72
41
  def build_deliver_params_string
73
42
  params = []
74
- params << "UserID=#{ShortMessage.config.user_id}"
75
- params << "CCUID=#{ShortMessage.config.ccu_id}"
76
- params << "ID=#{ShortMessage.config.id_string}"
77
- params << "sender=#{CGI.escape(self.sender)}"
78
- params << "receipient=#{CGI.escape(self.recipient)}"
79
- params << "message=#{CGI.escape(self.text)}"
80
- params << "utf-8=1"
43
+ params << "user=#{ShortMessage.config.user}"
44
+ params << "pass=#{ShortMessage.config.password}"
45
+ params << "from=#{CGI.escape(self.sender)}"
46
+ params << "to=#{CGI.escape(self.recipient)}"
47
+ params << "text=#{CGI.escape(self.text)}"
81
48
  params.join("&")
82
49
  end
83
50
 
84
51
  def build_recharge_params_string amount
85
- params = []
86
- params << "UserIDFS=#{ShortMessage.config.user_id}"
87
- params << "CCUID=#{ShortMessage.config.ccu_id}"
88
- params << "pay=1"
89
- params << "amount=#{amount}"
90
- params << "idstring=#{ShortMessage.config.id_string}"
91
- params.join("&")
52
+ raise "NOT YET IMPLEMENTED"
53
+ # params = []
54
+ # params << "user=#{ShortMessage.config.user}"
55
+ # params << "password=#{ShortMessage.config.password}"
56
+ # params << "amount=#{amount}"
57
+ # params.join("&")
92
58
  end
93
59
  end
94
60
  end
data/config/routes.rb CHANGED
@@ -1,2 +1,6 @@
1
- ShortMessage::Engine.routes.draw do
1
+ Rails.application.routes.draw do
2
+ namespace :short_message do
3
+ get 'messages/status' => "messages#status"
4
+ post 'messages/status' => "messages#status"
5
+ end
2
6
  end
@@ -7,7 +7,7 @@ class CreateShortMessageMessages < ActiveRecord::Migration
7
7
  t.integer :status_code
8
8
  t.text :text
9
9
 
10
- t.timestamps
10
+ t.timestamps null: false
11
11
  end
12
12
  end
13
13
  end
@@ -1,21 +1,21 @@
1
1
  ShortMessage.configure do |config|
2
- config.gateway_server = "www1.q-x.ch"
2
+ # Configuration example www.gtx-messaging.com
3
+ config.gateway_server = "http.gtx-messaging.net"
3
4
  config.gateway_port = 443
4
5
 
5
- config.send_file_path = "/app/sms/gw1/cust/send.php"
6
- config.account_functions_path = "/app/sms/gw1/cust/accfunc.php"
6
+ config.send_file_path = "/smsc.php"
7
+ # config.account_functions_path = ""
7
8
 
8
9
  # enter your details received from provider here
9
- config.user_id = ""
10
- config.ccu_id = ""
11
- config.id_string = ""
10
+ config.user = ""
11
+ config.password = ""
12
12
 
13
- config.default_reload_amount = 1000
13
+ # config.default_reload_amount = 1000
14
14
 
15
15
  config.default_mail_sender = "webmaster@your-domain.com"
16
- config.reload_notification_email = "webmaster@your-domain.com"
17
- config.admin_notification_email = "webmaster@your-domain.com" # set to blank to deactivate error mailing
18
- config.voucher_notification_email = "give-me-money@your-domain.com" # set nil to disable voucher mailing
16
+ config.reload_notification_email = "webmaster@your-domain.com" # send a message if payment is required
17
+ config.admin_notification_email = "webmaster@your-domain.com" # set nil to deactivate error mailing
18
+ # config.voucher_notification_email = "give-me-money@your-domain.com" # set nil to disable voucher mailing
19
19
 
20
20
  # set a default sms sender (used if no sender is present)
21
21
  # config.default_sms_sender = ""
@@ -1,14 +1,8 @@
1
1
  de:
2
2
  short_message:
3
3
  status:
4
- code_1: "Empfänger abwesend"
5
- code_3: "anerkannt"
6
- code_5: "anruf blockiert"
7
- code_6: "MSC Fehler"
8
- code_7: "zugestellt"
9
- code_18: "abgewiesen"
10
- code_20: "nicht verfügbar während Roaming"
11
- code_21: "unerwarteter Wert"
12
- code_22: "unbekannter Abonnent"
13
- code_99: "Aufladen fehlgeschlagen"
14
- code_999: "unkategorisierter Status"
4
+ code_1: "An Telefon zugestellt"
5
+ code_2: "Nicht an Telefon zugestellt"
6
+ code_4: "Bei SMSC in Warteschlange"
7
+ code_8: "Zugestellt an SMSC"
8
+ code_16: "Nicht zugestellt an SMSC"
@@ -1,14 +1,8 @@
1
1
  en:
2
2
  short_message:
3
3
  status:
4
- code_1: "absent subscriber"
5
- code_3: "accepted"
6
- code_5: "call barred"
7
- code_6: "controlling MSC failure"
8
- code_7: "delivered"
9
- code_18: "rejected by gateway"
10
- code_20: "unavailable while roaming to"
11
- code_21: "unexpected data value"
12
- code_22: "unknown subscriber"
13
- code_99: "recharge failed"
14
- code_999: "uncategorized status"
4
+ code_1: "Delivered to phone"
5
+ code_2: "Not delivered to phone"
6
+ code_4: "Queued on SMSC"
7
+ code_8: "Delivered to SMSC"
8
+ code_16: "Not delivered to SMSC"
@@ -16,9 +16,8 @@ module ShortMessage
16
16
  config_accessor :send_file_path
17
17
  config_accessor :account_functions_path
18
18
 
19
- config_accessor :user_id
20
- config_accessor :ccu_id
21
- config_accessor :id_string
19
+ config_accessor :user
20
+ config_accessor :password
22
21
 
23
22
  config_accessor :default_sms_sender
24
23
  config_accessor :default_reload_amount
@@ -31,7 +30,7 @@ module ShortMessage
31
30
  config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name
32
31
  end
33
32
 
34
- # define param_name writer (copied from AS::Configurable)
33
+ # define param_name writer
35
34
  writer, line = 'def param_name=(value); config.param_name = value; end', __LINE__
36
35
  singleton_class.class_eval writer, __FILE__, line
37
36
  class_eval writer, __FILE__, line
@@ -1,14 +1,13 @@
1
1
  module ShortMessage
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace ShortMessage
4
-
4
+
5
5
  initializer "short_message.migrate_database" do |app|
6
6
  Rails.application.config.paths['db/migrate'] << paths["db/migrate"].expanded.join
7
7
  end
8
-
8
+
9
9
  config.generators do |g|
10
- g.test_framework :rspec, :fixture => false
11
- g.fixture_replacement :factory_girl, :dir => 'spec/factories'
10
+ g.test_framework false
12
11
  g.assets false
13
12
  g.helper false
14
13
  end
@@ -1,3 +1,3 @@
1
1
  module ShortMessage
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -1,7 +1,6 @@
1
- #!/usr/bin/env rake
2
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
3
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
3
 
5
4
  require File.expand_path('../config/application', __FILE__)
6
5
 
7
- Dummy::Application.load_tasks
6
+ Rails.application.load_tasks
@@ -2,14 +2,12 @@
2
2
  // listed below.
3
3
  //
4
4
  // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
6
  //
7
7
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
8
+ // compiled file.
9
9
  //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
12
  //
13
- //= require jquery
14
- //= require jquery_ujs
15
13
  //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -2,8 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", :media => "all" %>
6
- <%= javascript_include_tag "application" %>
5
+ <%= stylesheet_link_tag 'application', media: 'all' %>
7
6
  <%= csrf_meta_tags %>
8
7
  </head>
9
8
  <body>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "short_message"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+
22
+ # Do not swallow errors in after_commit/after_rollback callbacks.
23
+ config.active_record.raise_in_transactional_callbacks = true
24
+ end
25
+ end
26
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)