hulaki 0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23ae4598e465d968a7d6b347336b2f64480d9203
4
- data.tar.gz: bd861ed5e5495fa44acb6e7686e6a86268710f63
3
+ metadata.gz: 223e8463666e7cd5c69f339d512680d597e6f858
4
+ data.tar.gz: 9d816a3224a76434bcd38c55919f72f2c5156842
5
5
  SHA512:
6
- metadata.gz: 7ef0fd5d590ee83caf83f5de5c4ea22d832648e6d8bf08c8497b7175670ac4a94386e5cc06b44b463d2a7a1612a9f3e4b2cf2d346dd3f641827495e7cf0bf2f9
7
- data.tar.gz: 10ab76ee6143e4372b181d1b8684cc335e0e6e17e9639063c27aebdcb1482ff3556730c8811be1f28b057fa939bd68a6b1eea0c02014e2b60c17565ae126ebf1
6
+ metadata.gz: 5837855f6497d7122e460ebb9ed7a8ca13a8197d4ea771ab49a08c26bdfac7ad2d938d79495e1daf23670e4fff271de30518ff34c485ae757684e127033fca9a
7
+ data.tar.gz: 84e1f9ced65e653e8b6e5528fc3648f8fdc039488945e2bffdb18b00f4d796840fb652a29cb1067d91031b80b36ff9ac4c42f9db0933fe7bbc45fa275ad1a83e
data/Gemfile.lock CHANGED
@@ -1,17 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hulaki (0.1)
5
- amatch
6
- smarter_csv
4
+ hulaki (1.1)
5
+ amatch (~> 0.3.1)
6
+ clipboard (= 1.1.0)
7
+ mail (~> 2.6.3)
8
+ nexmo (~> 4.6.0)
9
+ smarter_csv (= 1.1.0)
10
+ terminal-table (= 1.8.0)
7
11
  twilio-ruby (~> 4.11.1)
8
12
 
9
13
  GEM
10
14
  remote: https://rubygems.org/
11
15
  specs:
12
- amatch (0.3.0)
16
+ amatch (0.3.1)
13
17
  tins (~> 1.0)
14
- builder (3.2.2)
18
+ builder (3.2.3)
19
+ clipboard (1.1.0)
15
20
  coderay (1.1.1)
16
21
  diff-lcs (1.2.5)
17
22
  jwt (1.5.6)
@@ -20,6 +25,8 @@ GEM
20
25
  method_source (0.8.2)
21
26
  mime-types (2.99)
22
27
  multi_json (1.12.1)
28
+ nexmo (4.6.0)
29
+ jwt
23
30
  pry (0.10.3)
24
31
  coderay (~> 1.1.0)
25
32
  method_source (~> 0.8.1)
@@ -40,11 +47,14 @@ GEM
40
47
  rspec-support (3.5.0)
41
48
  slop (3.6.0)
42
49
  smarter_csv (1.1.0)
43
- tins (1.12.0)
50
+ terminal-table (1.8.0)
51
+ unicode-display_width (~> 1.1, >= 1.1.1)
52
+ tins (1.14.0)
44
53
  twilio-ruby (4.11.1)
45
54
  builder (>= 2.1.2)
46
55
  jwt (~> 1.0)
47
56
  multi_json (>= 1.3.0)
57
+ unicode-display_width (1.2.1)
48
58
 
49
59
  PLATFORMS
50
60
  ruby
@@ -58,4 +68,4 @@ DEPENDENCIES
58
68
  rspec
59
69
 
60
70
  BUNDLED WITH
61
- 1.13.1
71
+ 1.15.0
data/README.md CHANGED
@@ -4,7 +4,8 @@
4
4
  [![Issue Count](https://codeclimate.com/github/shivabhusal/hulaki/badges/issue_count.svg)](https://codeclimate.com/github/shivabhusal/hulaki)
5
5
  [ ![Codeship Status for shivabhusal/hulaki](https://codeship.com/projects/49470f10-ba22-0133-af95-025ac38368ea/status?branch=master)](https://codeship.com/projects/135625)
6
6
 
7
- #### Hulaki is a CLI tool to search contact details from your CSV file.
7
+ #### Hulaki is a CLI tool to search contact details from your CSV file and sending easy SMS and Emails with single command.
8
+ ![Hulaki Logo](images/hulaki.png)
8
9
 
9
10
  Hulaki makes communication easier by providing ability to search through the contact list. The CLI tool also allows sending direct SMS and/or email to desired person in contact list
10
11
 
@@ -18,40 +19,94 @@ Install this in your system using command.
18
19
  - Make sure to install this in your default ruby-version gemset. Other wise you may not be able to use the command from anywhere in your terminal emulator.
19
20
  - Or install in every ruby-version gemset; to make the command `$ hulaki` accessible from anywhere.
20
21
 
21
- ## Usage
22
- Use the following command for help
23
- ```bash
24
- $ hulaki -h
25
- $ hulaki --help
26
- ```
27
- ### Search phone number or other contact detail
22
+
23
+ ## Usage:
24
+ ### Search
28
25
  ```bash
29
26
  $ hulaki -s search-string
30
27
  # Example: Hulaki features fuzzy search
31
- # $ hulaki -s smithjohn
32
- # $ hulaki -s johsmith
33
- # $ hulaki -s smijohnth
34
- ```
28
+ # $ hulaki -s smithjohn
29
+ # $ hulaki -s johsmith
30
+ # $ hulaki -s smijohnth
35
31
 
36
- ### Sending SMS
37
- > First search for contact number, copy it
32
+ ```
33
+ **Example Output**
34
+ ```
35
+ $ hulaki -s 'jhn'
36
+ +-----+--------------------------------+------------+------------+--------------------+
37
+ | Hulaki 1.0 |
38
+ +-----+--------------------------------+------------+------------+--------------------+
39
+ | S.N | Name | Phone 1 | Phone 2 | Email |
40
+ +-----+--------------------------------+------------+------------+--------------------+
41
+ | 1 | John Bhusal | 984xxx8271 | | hisemail@gmail.com |
42
+ | 2 | Joe Dhakal | 984xxx8627 | 980xxx1820 | |
43
+ | 3 | Jhalak Parajuli | 985xxx3695 | | |
44
+ | 4 | Jonathan Dai Subedi | 984xxx4397 | | |
45
+ +-----+--------------------------------+------------+------------+--------------------+
38
46
 
39
47
  ```
48
+ ### SMS
49
+ ```bash
40
50
  $ hulaki -t +977xxxxxxxxxx -m "Message to be sent"
51
+
52
+ # You can even select a specific SMS Gateway
53
+ $ hulaki -t +977xxxxxxxxxx -m "Message to be sent" -g nexmo
54
+ $ hulaki -t +61xxxxxxxxxx -m "Message to be sent" -g twilio
55
+ $ hulaki -t +1xxxxxxxxxx -m "Message to be sent" -g sparrow
56
+
57
+ # You can even broadcast SMSes selecting a specific SMS Gateway
58
+ # However, keep in mind that multiple SMS request will go to the server
59
+ $ hulaki -t +977xxxxxxxxxx,+9779832xxxxxx -m "Message to be sent" -g nexmo
60
+
61
+ # You can also change the name that appears on recipient's Phone using `-f` switch. This only works with Nexmo
62
+ $ hulaki -t +977xxxxxxxxxx,+9779832xxxxxx -m "Message to be sent" -g nexmo -f "Hero Dai!"
63
+
64
+ ```
65
+
66
+ ### EMail
67
+ ```bash
68
+ $ hulaki -t someone@example.com -S "Subject of the email" -m "Message to be sent"
69
+ $ hulaki -t someone@example.com --subject "Subject of the email" -m "Message to be sent"
70
+
71
+ # You can even broadcast emails, i.e. mutiple recipients
72
+ # However, keep in mind that multiple SMTP request will go to the server. No `CC`, `BCC` will be used
73
+ $ hulaki -t someone@example.com,nextperson@email.com --subject "Subject of the email" -m "Message to be sent"
74
+
75
+ # You can also change your sender id using `-f` switch
76
+ $ hulaki -t someone@example.com -S "Subject of the email" -m "Message to be sent" -f "My Name<anonymous@example.com>"
77
+ ```
78
+
79
+ ### Email Templates/Layouts
80
+ You are allowed to have an Email template in HTML format at `~/hulaki/template.html.erb` which will be copied when you use `-i` switch. If you have `use_template` setting set to `true` then only you will be able to use the template. Templates are like `Layouts` in Rails.
81
+ ```bash
82
+ $ hulaki -t someone@example.com -S "Subject of the email" -m "Message to be sent"
83
+ ```
84
+
85
+ ### Specific options:
86
+ ```bash
87
+ -t, --to x,y,z list of recipient, can be
88
+ -m, --message [Message] Message to be sent to recipient
89
+ -S, --subject [Subject] Subject to email
90
+ -g, --gateway [Gateway Name] Name of the gateway, `nexmo`, `twilio`, `sparrow` are currently supported
91
+ -f, --from [Sender] name <email> | PhoneNumber; this will take precedence over `from` in `config.yml`.
92
+ -s, --search [name/contact] Search keyword
93
+ -h, --help Help / Examples
94
+ -l, --list list all the options available
95
+ -i, --install Creates ~/hulaki/config.yml, `template.html.erb`. Will ask you if have to replace them
41
96
  ```
42
97
 
43
98
  ## Configuration
44
- - `Hulaki` requires the file `~/hulaki/contact.csv` to be present.
99
+ - `Hulaki` requires the file `~/hulaki/contact.csv` to be present.
45
100
  - The file must be a valid `CSV` file.
46
- - When you install the gem, a sample config file is copied to `~/hulaki/config.yml`
47
- - You need to update your `Twilio` creds
48
- - `Hulaki` only supports `Twilio` at the moment.
101
+ - When you install the gem, a sample config and template filea are copied to `~/hulaki/`
102
+ - You need to update the template per requirement.
103
+ - You need to update your SMS gateway(eg. `Twilio`, `nexmo`) creds
104
+ - `Hulaki` only supports `Twilio` and `nexmo` at the moment.
49
105
  - Also, update the SMTP settings accordingly
50
106
 
51
107
  ---
52
108
 
53
109
  ## Development
54
-
55
110
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
56
111
 
57
112
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
@@ -64,4 +119,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/shivab
64
119
  ## License
65
120
 
66
121
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
67
-
data/hulaki.gemspec CHANGED
@@ -4,13 +4,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'hulaki/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'hulaki'
8
- spec.version = Hulaki::VERSION
9
- spec.authors = ['Shiva Bhusal', 'Shishir Sapkota', 'Neha Suwal', 'Prativa Devkota']
10
- spec.email = ['hotline.shiva@gmail.com']
7
+ spec.name = 'hulaki'
8
+ spec.version = Hulaki::VERSION
9
+ spec.authors = ['Shiva Bhusal']
10
+ spec.email = ['hotline.shiva@gmail.com']
11
11
 
12
- spec.summary = %q{Hulaki is basically a CLI tool to search contact details \
13
- exported already in CSV format.}
12
+ spec.summary = %q{Hulaki is basically a CLI tool to search contact details \
13
+ exported already in CSV format, send SMS and Emails in a single command.}
14
14
 
15
15
  spec.description = %Q{We developers don't have time to grab mobile phones, \
16
16
  slide the screen, press pin numbers, open contact list \
@@ -20,18 +20,25 @@ Gem::Specification.new do |spec|
20
20
  search the contact details and send message if we like.}
21
21
 
22
22
  spec.homepage = 'https://github.com/shivabhusal/hulaki'
23
- spec.license = 'MIT'
23
+ spec.license = 'MIT'
24
24
 
25
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
- spec.bindir = 'exe'
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
- spec.require_paths = ['lib']
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
29
 
30
- spec.add_development_dependency 'bundler', '~> 1.10'
31
- spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'bundler', '~> 1.10'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
32
  spec.add_development_dependency 'pry'
33
33
  spec.add_development_dependency 'rspec'
34
- spec.add_runtime_dependency 'amatch'
35
- spec.add_runtime_dependency 'twilio-ruby', '~> 4.11.1'
36
- spec.add_runtime_dependency 'smarter_csv'
34
+
35
+ spec.add_runtime_dependency 'amatch', '~> 0.3.1'
36
+ spec.add_runtime_dependency 'twilio-ruby', '~> 4.11.1'
37
+ spec.add_runtime_dependency 'nexmo', '~> 4.6.0'
38
+ spec.add_runtime_dependency 'mail', '~> 2.6.3'
39
+ spec.add_runtime_dependency 'smarter_csv', '1.1.0'
40
+ spec.add_runtime_dependency 'terminal-table', '1.8.0'
41
+ spec.add_runtime_dependency 'clipboard', '1.1.0'
42
+
43
+ spec.post_install_message = 'Please run `$ hulaki -i` to install Configuration files so that you can modify later'
37
44
  end
data/images/hulaki.png ADDED
Binary file
data/lib/hulaki.rb CHANGED
@@ -1,78 +1,10 @@
1
- require 'hulaki/version'
2
- require 'hulaki/string_modifier'
3
- require 'amatch'
4
- require 'hulaki/search_engine'
5
- require 'hulaki/version'
6
- require 'hulaki/contact_parser'
7
- require 'smarter_csv'
8
- require 'twilio-ruby'
9
- require 'pry'
10
- require 'hulaki/option_parser'
11
- require 'hulaki/sms_handler/sms_handler'
12
- require 'hulaki/sms_handler/sms_validator'
13
- require 'hulaki/sms_handler/gateway_adapters/twilio'
14
- require 'hulaki/sms_handler/gateway_adapters/sparrow'
15
- require 'hulaki/config/config'
16
- require 'hulaki/exceptions'
17
- require 'hulaki/email_validator'
18
- require 'hulaki/mailer'
19
- require 'hulaki/logger'
20
- require 'mail'
21
-
22
- class Hulaki::Core
23
- def initialize(config)
24
- @config = config
25
- end
26
-
27
- def perform
28
- puts '~' * 100
29
- puts 'Welcome to Hulaki : Your best companion! to make your day great.'
30
- puts '~' * 100
31
-
32
- @config.to.each do |recipient|
33
- if is_phone?(recipient)
34
- handle_sms(recipient)
35
- elsif is_email?(recipient)
36
- handle_email(recipient)
37
- end
38
- end
39
-
40
- puts '~' * 100
41
- puts @config.message
42
- puts '~' * 100
43
-
44
- end
45
-
46
- private
47
-
48
- def is_phone?(number)
49
- Hulaki::SmsValidator.is_phone_number?(number)
50
- end
51
-
52
- def is_email?(email)
53
- Hulaki::EmailValidator.is_email?(email)
54
- end
1
+ require 'hulaki/version.rb'
2
+ begin
3
+ require 'pry'
4
+ rescue LoadError
5
+ # No matter if its production
6
+ end
55
7
 
56
- def handle_email(recipient)
57
- puts "Sending email to #{recipient}"
58
- email_handler = Hulaki::Mailer.new(
59
- {
60
- to: recipient,
61
- body: @config.message,
62
- sub: @config.subject,
63
- })
64
- puts "Email sent to #{recipient}."
65
- end
66
8
 
67
- def handle_sms(recipient)
68
- puts "Sending SMS to #{recipient}"
69
- sms_handler = Hulaki::SmsHandler.new(
70
- {
71
- to: recipient,
72
- message: @config.message
73
- })
74
- if sms_handler.send
75
- puts "SMS sent successfully to #{recipient}"
76
- end
77
- end
78
- end
9
+ path = File.expand_path('../hulaki/', __FILE__)
10
+ Dir["#{path}/**/*.rb"].each{ |f| require f }
@@ -1,35 +1,35 @@
1
+ require 'smarter_csv'
1
2
  require 'yaml'
2
3
  require 'erb'
4
+
3
5
  class Hulaki::Config
4
- ConfigPath = '~/hulaki/config.yml'
5
- SampleConfigPath = 'lib/hulaki/config/config_sample.yml'
6
- @@config_file_path = ConfigPath
7
- attr_accessor :file_path
6
+ ConfigPath = '~/hulaki/config.yml'
7
+ SampleConfigPath = File.expand_path('../sample.config.yml', __FILE__)
8
+ SampleContactPath = File.expand_path('../sample.contact.csv', __FILE__)
9
+ SampleTemplatePath = File.expand_path('../sample.template.html.erb', __FILE__)
8
10
 
9
- def initialize(params = {})
10
- @file_path = File.expand_path(params.fetch(:path, @@config_file_path))
11
- end
11
+ @@config_file_path = File.expand_path(ConfigPath)
12
12
 
13
- def parse
14
- read_file
15
- end
13
+ class << self
14
+ def [](key)
15
+ config[key]
16
+ end
16
17
 
17
- private
18
+ def config_file_path=(config_file_path)
19
+ @@config_file_path = File.expand_path(config_file_path)
20
+ end
18
21
 
19
- def read_file
20
- read_file = File.open(@file_path).read
21
- YAML.load(ERB.new(read_file).result)
22
- rescue Errno::ENOENT => e
23
- raise Hulaki::InvalidFilePath, 'Invalid file.'
24
- end
22
+ private
25
23
 
26
- class << self
27
- def config_file_path=(config_file_path)
28
- @@config_file_path = config_file_path
24
+ def config
25
+ @@config ||= parse
29
26
  end
30
27
 
31
- def config_file_path
32
- @@config_file_path
28
+ def parse
29
+ read_file = File.open(@@config_file_path ).read
30
+ YAML.load(ERB.new(read_file).result)
31
+ rescue Errno::ENOENT => e
32
+ raise Hulaki::InvalidFilePath, 'Invalid file.'
33
33
  end
34
34
  end
35
35
  end
@@ -0,0 +1,34 @@
1
+ sms:
2
+ # The later config will override the former one
3
+ # To have multiple config and switch between them, comment the not used one
4
+ twilio:
5
+ default: true
6
+ API_KEY: ACf43b1e6876as8d7a6sd27515ea49e418
7
+ API_SECRET: 75768435c30daeef519439kjhkjahsdk
8
+ ACCOUNT_PHONE_NUMBER: +150447566666
9
+
10
+ nexmo:
11
+ API_KEY: ACf43b1e6167987123jhkhkhkjjj49e418
12
+ API_SECRET: 75768435c30daeef519439c123123123f
13
+ ACCOUNT_PHONE_NUMBER: +154444451701
14
+
15
+ sparrow:
16
+ API_KEY: ACf43b1e6167987123jhkhkhkjjj49e418
17
+ API_SECRET: 75768435c30daeef519439c123123123f
18
+ ACCOUNT_PHONE_NUMBER: +154444451701
19
+ from: Your Name
20
+
21
+ email:
22
+ delivery_method: smtp
23
+ address: smtp.gmail.com
24
+ port: 587
25
+ domain: gmail.com
26
+ user_name: youremail@gmail.com
27
+ password: p@ssword123
28
+ authentication: plain
29
+ from: your_name <your_email@example.com>
30
+ # This feature will let you use a template stored in `~/hulaki/template.`
31
+ use_template: true
32
+
33
+ search:
34
+ no_of_results: 10
@@ -0,0 +1,4 @@
1
+ Name,First Name,Last Name,Phone 1 - Type,Phone 1 - Value,Phone 2 - Type,Phone 2 - Value,Address 1 - Type,Address 1 - Formatted
2
+ Shiva Bhusal,Shiva,Bhusal,Mobile,9843488889,Home,034567238,Home,Kathmandu-Dhobikhola
3
+ Shiva Gaire,Shiva,Gaire,Mobile,9843488889,Home,034567238,Home,Kathmandu-Dhobikhola
4
+ Yubraj Acharya,Yubraj,Acharya,Mobile,9843488867,Home,034563338,Home,Kathmandu-Dhobikhola
@@ -0,0 +1,10 @@
1
+ <h1>Your heading might go here!</h1>
2
+ <section>
3
+ You body will be inserted here, if you wish to use, modify this file accordingly.
4
+ <%= @email_body %>
5
+ </section>
6
+ <p>
7
+ regards,<br>
8
+ Your Name
9
+ </p>
10
+ <footer>This will be your footer</footer>