wedding 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wedding.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jai Pandya
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,86 @@
1
+ # Wedding
2
+
3
+ > How would be a weddding without a gem?
4
+
5
+ <img src='http://i.imgur.com/Ap02gKh.png' alt='screenshot' width='600' />
6
+
7
+ ## Overview
8
+
9
+ A fun experiment to invite my geeky friends
10
+ via this ruby gem.
11
+
12
+ ## Installation
13
+
14
+ Command line install
15
+
16
+ $ gem install wedding
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ gem 'wedding'
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ ## Usage
27
+
28
+ ### Command Line
29
+
30
+ List of all available commands
31
+
32
+ wedding
33
+
34
+ Print a personalized wedding invitation
35
+
36
+ wedding invitation
37
+
38
+ Glory words for the groom
39
+
40
+ wedding groom
41
+
42
+ Glory words for the bride
43
+
44
+ wedding bride
45
+
46
+ RSVP for the event
47
+
48
+ wedding rsvp
49
+
50
+ Map location of the venue
51
+
52
+ wedding location
53
+
54
+ ### Public API
55
+
56
+ New wedding
57
+
58
+ # By default it would take config options from
59
+ # lib/wedding/default_config.rb, which can be overridden
60
+ # by passing your own hash
61
+
62
+ wedding = Wedding.new
63
+
64
+ Returns invitation card string
65
+
66
+ wedding.invitation
67
+
68
+ Wedding venue coordinates
69
+
70
+ wedding.location
71
+
72
+ Returns google maps URL of the venue
73
+
74
+ wedding.map_location
75
+
76
+ Access the groom 'object'
77
+
78
+ wedding.groom
79
+
80
+ Access the bride 'object'
81
+
82
+ wedding.bride
83
+
84
+ RSVP information about the event
85
+
86
+ wedding.rsvp
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'wedding'
4
+ require 'wedding/cli'
5
+ Wedding::CLI.start
@@ -0,0 +1,38 @@
1
+ require 'launchy'
2
+ require 'thor'
3
+ require 'wedding/default_config'
4
+
5
+ # Lets bring the bride, groom here and
6
+ # ring the bells to start the ceremony
7
+ require 'wedding/bride'
8
+ require 'wedding/groom'
9
+ require 'wedding/ceremony'
10
+
11
+ module Wedding
12
+
13
+ class << self
14
+
15
+ # Sets the default options used when calling Wedding#new.
16
+ attr_writer :default_config
17
+
18
+ # There is a weddig, there is a ceremony. Time for celebrations.
19
+ attr_accessor :ceremony
20
+
21
+
22
+ # Returns new Ceremony object that can be used to query details
23
+ # about the wedding
24
+ # @param [Hash] config A hash of config values for wedding. Check
25
+ # default_config.rb
26
+ def new(config = nil)
27
+ config = config ? default_config.merge(config) : default_config.dup
28
+ Ceremony.new(config)
29
+ end
30
+
31
+ # Getter method for default_config for the wedding.
32
+ def default_config
33
+ DefaultConfig.options
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,27 @@
1
+ module Wedding
2
+ # No wedding without a bride
3
+ class Bride
4
+ # Get her ready for all the jazz and buzz
5
+ def initialize(config)
6
+ self.name = config[:bride_name]
7
+ self.about = config[:bride_about]
8
+ self.occupation = config[:bride_occupation]
9
+ self.email = config[:bride_email]
10
+ end
11
+
12
+ # Overriding for pretty printing
13
+ def to_s
14
+ bride_gungaan = %Q[
15
+ ========= Bride ==========
16
+
17
+ The bride's name is #{self.name}
18
+ She is a #{self.about}
19
+ She works as #{self.occupation}
20
+ If you want to contact her, her email ID
21
+ is #{self.email}
22
+
23
+ ]
24
+ end
25
+ attr_accessor :name, :about, :occupation, :email
26
+ end
27
+ end
@@ -0,0 +1,118 @@
1
+ require 'cgi'
2
+ require 'artii'
3
+ require 'date'
4
+ require 'rainbow'
5
+
6
+ module Wedding
7
+ # The magic happens here
8
+ # Sing, dance, eat and enjoy
9
+ class Ceremony
10
+
11
+ # Time to set the things in the right direction
12
+ # Groom, bride, location, date and event schedule.
13
+ # @param [Hash] config configuration object for the constructor
14
+ def initialize(config)
15
+ @groom = Wedding::Groom.new(config)
16
+ @bride = Wedding::Bride.new(config)
17
+ @location = config[:location]
18
+ @date = Date.parse(config[:date])
19
+ @event_schedule = config[:event_schedule]
20
+
21
+ @artii = Artii::Base.new :font => 'slant'
22
+ end
23
+
24
+ # We need to access what we have set earlier
25
+ attr_reader :groom, :bride, :location, :event_schedule, :date
26
+
27
+ # Venue coordinates
28
+ def coordinates
29
+ @location
30
+ end
31
+
32
+ # Lets have a more readable format of coordinates method
33
+ # with a URL to google maps
34
+ def location
35
+ "https://maps.google.com/?q=" + CGI.escape(coordinates)
36
+ end
37
+
38
+ # Number of days left
39
+ def days_left
40
+ (date - Date.today)
41
+ end
42
+
43
+ # Event schedule
44
+ def events
45
+ @event_schedule.join("\n")
46
+ end
47
+
48
+ # Forms a pretty invitation card for the wedding
49
+ def invitation
50
+ invitation = %Q[
51
+ #{print_ganesha.color(:green)}
52
+ ========= Wedding invitation ==========
53
+
54
+ #{@artii.asciify(groom.name).color(:blue)}
55
+ with
56
+ #{@artii.asciify(bride.name).color(:blue)}
57
+
58
+
59
+ Hi #{`whoami`.strip.capitalize}
60
+
61
+ We are getting married on #{date.strftime("%d %B %y")}. It will
62
+ be a great pleausre for us to have your presence
63
+ in the wedding ceremony.
64
+
65
+ Event schedule:
66
+
67
+ #{events}
68
+
69
+ Pack your bags! Only #{days_left.to_s.color(:red)} days left.
70
+ ]
71
+
72
+ rescue StandardError => e
73
+
74
+ invitation = %Q[
75
+ ========= Wedding invitation ==========
76
+
77
+ Looks like something went wrong here, did you you fake
78
+ the invitation?
79
+
80
+ ]
81
+
82
+ end
83
+
84
+ # In Hindu mythology it is a custom to start
85
+ # anything new worshipping lord Ganesha
86
+ # http://en.wikipedia.org/wiki/Ganesha
87
+ def print_ganesha
88
+ ganesh = %Q[
89
+ _.!._
90
+ /O*@*O\\
91
+ <\\@(_)@/>
92
+ ,;, .--;` `;--. ,
93
+ O@O_ / |d b| \\ _hnn
94
+ | `/ \\ | | / \\` |
95
+ &&&& :##;\\ /;##; &&&&
96
+ | \\ / `##/| |##' \\ / |
97
+ \\ %%%%`</| |#'`%%%% /
98
+ '._|_ \\ | |' / _|_.'
99
+ _/ / \\ \\ \\ \\
100
+ / (\\( '. '-._&&&&
101
+ ( ()##, o'--.._`\\-)
102
+ '-():`##########'()()()
103
+ /:::::/()`Y`()\\:::::\\
104
+ \\::::( () | () )::::/
105
+ `"""`\\().'.()/'"""`
106
+ ]
107
+ end
108
+
109
+ # RSVP for the event
110
+ def rsvp
111
+ invitation = %Q[
112
+ You can RSVP to the event by sending an email to
113
+ #{groom.name.color(:blue)} (#{groom.email.color(:green)})
114
+ or #{bride.name.color(:blue)} (#{bride.email.color(:green)})
115
+ ]
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,44 @@
1
+ require 'wedding'
2
+ require 'launchy'
3
+ module Wedding
4
+
5
+ # We have a new wedding taking place here
6
+ self.ceremony = self.ceremony || self.new
7
+
8
+ # Command line interface for the wedding
9
+ class CLI < Thor
10
+ desc 'invitation', 'Your invitation card is inside this envelope'
11
+ def invitation
12
+ puts Wedding.ceremony.invitation
13
+ end
14
+
15
+ desc 'location', 'Google maps link to the wedding venue'
16
+ def location
17
+ puts map_location = Wedding.ceremony.location
18
+ answer = yes?('Do you want to open this link in browser? (yes/no)')
19
+ if (answer)
20
+ begin
21
+ Launchy.open(map_location)
22
+ rescue StandardError => e
23
+ puts "Sorry, you are probably not using a graphical terminal"
24
+ end
25
+ end
26
+ end
27
+
28
+ desc 'rsvp', 'RSVP for the event'
29
+ def rsvp
30
+ puts Wedding.ceremony.rsvp
31
+ end
32
+
33
+ desc 'groom', 'Glory words about the groom'
34
+ def groom
35
+ puts Wedding.ceremony.groom
36
+ end
37
+
38
+ desc 'bride', 'Glory words about the bride'
39
+ def bride
40
+ puts Wedding.ceremony.bride
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,23 @@
1
+ module Wedding
2
+ module DefaultConfig
3
+ def self.options
4
+ {
5
+ :groom_name => "Jai",
6
+ :groom_about => "Programmer, Traveller, Photographer, Biker, SlideShare Engineer",
7
+ :groom_occupation => "Hacker at SlideShare",
8
+ :groom_email => "jaipandya@gmail.com",
9
+ :bride_name => "Prerita",
10
+ :bride_about => "Banker, Traveller, Dancer, Painter, Dreamer",
11
+ :bride_occupation => "Asst. Manager at Bank of Baroda",
12
+ :bride_email => "preritayadav@gmail.com",
13
+ :location => "+26° 52' 57.3024\", +75° 48' 24.75\"",
14
+ :event_schedule => [
15
+ " 7:00 pm Barat starts from Home",
16
+ " 8:00 pm Barat reaches venue",
17
+ "12:00 pm Phere"
18
+ ],
19
+ :date => "2013-11-29"
20
+ }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ module Wedding
2
+ # No wedding without a groom
3
+ class Groom
4
+ # Get him ready for all pomp and show
5
+ def initialize(config)
6
+ self.name = config[:groom_name]
7
+ self.about = config[:groom_about]
8
+ self.occupation = config[:groom_occupation]
9
+ self.email = config[:groom_email]
10
+ end
11
+
12
+ # Overriding for pretty printing
13
+ def to_s
14
+ groom_gungaan = %Q[
15
+ ========= Groom ==========
16
+
17
+ The groom's name is #{self.name}
18
+ He is a #{self.about}
19
+ He works as a #{self.occupation}
20
+ If you want to contact him, his email ID
21
+ is #{self.email}
22
+
23
+ ]
24
+ end
25
+ attr_accessor :name, :about, :occupation, :email
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ module Wedding
2
+ class << self
3
+ def post_install_message
4
+ footer = <<'EOS'
5
+
6
+ ==== Release notes for wedding gem ====
7
+
8
+ Now that you have installed this gem, you earn our immence respect.
9
+ You are the star guest of our wedding, you will receive our special
10
+ attention.
11
+ Go ahead and type `wedding` (wihtout backticks) on the command
12
+ prompt to see the list of commands available with it. Print your
13
+ personal invitation, and fire your browser to see the location of
14
+ the event. We love you!
15
+
16
+ Prerita and Jai
17
+
18
+ =======================================
19
+
20
+ EOS
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ module Wedding
2
+ # No major releases scheduled after this one
3
+ VERSION = "0.0.1" unless const_defined?(:VERSION)
4
+ end
Binary file
@@ -0,0 +1,39 @@
1
+ require 'wedding'
2
+
3
+ describe "Wedding#default_config" do
4
+ it "returns default config options" do
5
+ Wedding.default_config.should eql({
6
+ :groom_name => "Jai",
7
+ :groom_about => "Programmer, Traveller, Photographer, Biker, SlideShare Engineer",
8
+ :groom_occupation => "Hacker at SlideShare",
9
+ :groom_email => "jaipandya@gmail.com",
10
+ :bride_name => "Prerita",
11
+ :bride_about => "Banker, Traveller, Dancer, Painter, Dreamer",
12
+ :bride_occupation => "Asst. Manager at Bank of Baroda",
13
+ :bride_email => "preritayadav@gmail.com",
14
+ :location => "26° 53.415', 75° 48.466'",
15
+ :event_schedule => [
16
+ "7:00 pm Barats starts from Home",
17
+ "8:00 pm Barat reaches venue",
18
+ "12:00 pm Fere"
19
+ ],
20
+ :date => "29 November 2013"
21
+ })
22
+ end
23
+ end
24
+
25
+ describe "Wedding::Ceremony" do
26
+
27
+ it "correctly initializes all the instance variables" do
28
+ end
29
+
30
+ it "launches the browser for map location" do
31
+ end
32
+
33
+ it "prints an awesome invitation message" do
34
+ end
35
+
36
+ it 'RSVPs for the event' do
37
+ end
38
+
39
+ end
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wedding/version'
5
+ require 'wedding/post_install_message'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "wedding"
9
+ spec.version = Wedding::VERSION
10
+ spec.authors = ["Jai Pandya"]
11
+ spec.email = ["jaipandya@gmail.com"]
12
+ spec.description = <<-EOS
13
+ What could be better than a gem for a wedding. A fun experiment that generates
14
+ an invite for my wedding. The gem is generic in nature that accepts a configuration
15
+ object to work on.
16
+ EOS
17
+ spec.summary = %q{I created this gem for inviting friends to my wedding.}
18
+ spec.homepage = "http://github.com/jaipandya/wedding"
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files`.split($/)
22
+ spec.executables = ['wedding']
23
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.3"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "rspec", "~> 2.6"
29
+
30
+ spec.post_install_message = Wedding.post_install_message
31
+
32
+ spec.add_runtime_dependency 'launchy', '2.3.0'
33
+ spec.add_runtime_dependency 'require_all', '~> 1.3.2'
34
+ spec.add_runtime_dependency 'thor', '~> 0.18'
35
+ spec.add_runtime_dependency 'artii', '~> 2.0.3'
36
+ spec.add_runtime_dependency 'rainbow', '~> 1.1.4'
37
+
38
+ end
metadata ADDED
@@ -0,0 +1,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wedding
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Jai Pandya
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2013-11-19 00:00:00 +05:30
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: bundler
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 3
30
+ version: "1.3"
31
+ type: :development
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
42
+ version: "0"
43
+ type: :development
44
+ version_requirements: *id002
45
+ - !ruby/object:Gem::Dependency
46
+ name: rspec
47
+ prerelease: false
48
+ requirement: &id003 !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ~>
51
+ - !ruby/object:Gem::Version
52
+ segments:
53
+ - 2
54
+ - 6
55
+ version: "2.6"
56
+ type: :development
57
+ version_requirements: *id003
58
+ - !ruby/object:Gem::Dependency
59
+ name: launchy
60
+ prerelease: false
61
+ requirement: &id004 !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - "="
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 2
67
+ - 3
68
+ - 0
69
+ version: 2.3.0
70
+ type: :runtime
71
+ version_requirements: *id004
72
+ - !ruby/object:Gem::Dependency
73
+ name: require_all
74
+ prerelease: false
75
+ requirement: &id005 !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ segments:
80
+ - 1
81
+ - 3
82
+ - 2
83
+ version: 1.3.2
84
+ type: :runtime
85
+ version_requirements: *id005
86
+ - !ruby/object:Gem::Dependency
87
+ name: thor
88
+ prerelease: false
89
+ requirement: &id006 !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ segments:
94
+ - 0
95
+ - 18
96
+ version: "0.18"
97
+ type: :runtime
98
+ version_requirements: *id006
99
+ - !ruby/object:Gem::Dependency
100
+ name: artii
101
+ prerelease: false
102
+ requirement: &id007 !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ~>
105
+ - !ruby/object:Gem::Version
106
+ segments:
107
+ - 2
108
+ - 0
109
+ - 3
110
+ version: 2.0.3
111
+ type: :runtime
112
+ version_requirements: *id007
113
+ - !ruby/object:Gem::Dependency
114
+ name: rainbow
115
+ prerelease: false
116
+ requirement: &id008 !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ~>
119
+ - !ruby/object:Gem::Version
120
+ segments:
121
+ - 1
122
+ - 1
123
+ - 4
124
+ version: 1.1.4
125
+ type: :runtime
126
+ version_requirements: *id008
127
+ description: |
128
+ What could be better than a gem for a wedding. A fun experiment that generates
129
+ an invite for my wedding. The gem is generic in nature that accepts a configuration
130
+ object to work on.
131
+
132
+ email:
133
+ - jaipandya@gmail.com
134
+ executables:
135
+ - wedding
136
+ extensions: []
137
+
138
+ extra_rdoc_files: []
139
+
140
+ files:
141
+ - .gitignore
142
+ - Gemfile
143
+ - LICENSE.txt
144
+ - README.md
145
+ - Rakefile
146
+ - bin/wedding
147
+ - lib/wedding.rb
148
+ - lib/wedding/bride.rb
149
+ - lib/wedding/ceremony.rb
150
+ - lib/wedding/cli.rb
151
+ - lib/wedding/default_config.rb
152
+ - lib/wedding/groom.rb
153
+ - lib/wedding/post_install_message.rb
154
+ - lib/wedding/version.rb
155
+ - screenshot.png
156
+ - spec/wedding_spec.rb
157
+ - wedding.gemspec
158
+ has_rdoc: true
159
+ homepage: http://github.com/jaipandya/wedding
160
+ licenses:
161
+ - MIT
162
+ post_install_message: |+
163
+
164
+ ==== Release notes for wedding gem ====
165
+
166
+ Now that you have installed this gem, you earn our immence respect.
167
+ You are the star guest of our wedding, you will receive our special
168
+ attention.
169
+ Go ahead and type `wedding` (wihtout backticks) on the command
170
+ prompt to see the list of commands available with it. Print your
171
+ personal invitation, and fire your browser to see the location of
172
+ the event. We love you!
173
+
174
+ Prerita and Jai
175
+
176
+ =======================================
177
+
178
+ rdoc_options: []
179
+
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ segments:
187
+ - 0
188
+ version: "0"
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ segments:
194
+ - 0
195
+ version: "0"
196
+ requirements: []
197
+
198
+ rubyforge_project:
199
+ rubygems_version: 1.3.6
200
+ signing_key:
201
+ specification_version: 3
202
+ summary: I created this gem for inviting friends to my wedding.
203
+ test_files:
204
+ - spec/wedding_spec.rb