Skip to content

Commit 9a802c1

Browse files
committed
Add initializer generator
1 parent 69f755a commit 9a802c1

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,33 @@ And then execute:
2121

2222
## Usage
2323

24-
Firstly, add `sms_ru.rb` to initializers. Here you can set api_id.
24+
After you add 'sms_ru' to your Gemfile, you need to run the
25+
generator:
26+
27+
```console
28+
rails generate sms_ru:install
29+
```
30+
31+
The generator will install an initializer to
32+
`config/initializers/sms_ru.rb`. Here you can set app_id
2533

2634
``` ruby
2735
SmsRu.setup do |config|
2836
config.api_id = Rails.application.secrets.sms_ru_key
29-
### you can setup default settings for every sms.ru API query you want
37+
end
38+
```
39+
40+
Also you can setup default settings for every sms.ru API query
41+
42+
``` ruby
43+
SmsRu.setup do |config|
44+
...
3045
config.queries.sms.send.from = 'fasteria.ru'
3146
end
3247
```
3348

49+
Example:
50+
3451
``` ruby
3552
SmsRu.sms.send(api_id: 'abcdef', to: '79112223344', text: 'Sample message') # => '100\n000-00000'
3653
SmsRu.my.balance # => '100\n87.79'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module SmsRu
2+
module Generators
3+
class InstallGenerator < Rails::Generators::Base
4+
source_root File.expand_path("../templates", __FILE__)
5+
6+
def copy_initializer
7+
template 'sms_ru.rb', 'config/initializers/sms_ru.rb'
8+
end
9+
end
10+
end
11+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SmsRu.setup do |config|
2+
config.api_id = Rails.application.secrets.sms_ru_key
3+
end

0 commit comments

Comments
 (0)