mega_lottery 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/bin/mega_lottery +6 -0
- data/lib/generators/mega_lottery/install/install_generator.rb +16 -0
- data/lib/generators/mega_lottery/install/templates/mega_lottery.rb +3 -0
- data/lib/mega_lottery.rb +21 -0
- data/lib/mega_lottery/configuration.rb +9 -0
- data/lib/mega_lottery/drawing.rb +1 -1
- data/lib/mega_lottery/helper.rb +7 -0
- data/lib/mega_lottery/railtie.rb +17 -0
- data/lib/mega_lottery/tasks/mega_lottery.rake +6 -0
- data/lib/mega_lottery/version.rb +1 -1
- data/spec/mega_lottery/configuration_spec.rb +20 -0
- data/spec/mega_lottery/helper_spec.rb +17 -0
- data/spec/mega_lottery_spec.rb +38 -0
- metadata +17 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d704ba0c00762a43a8446dacca2872f9b6011ad3
|
|
4
|
+
data.tar.gz: 0dcf9894de1f820a4510bcf966d1d95ce8e04ba7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 755310a75b9368b18c92ce94e2ef955e7e0353ef48591594d4bf3206298e8ff5a80d79ec917600e31e5f41a0adbf63d3f259f12321623f6bc8e9f332a2a57fe9
|
|
7
|
+
data.tar.gz: 07cda17a70914d9196e79099212379f7dc567211081eff926816335b400e4350a0fd9ed65bc15e33d02650f9aa3a7dbc8a1b35d19b9c5fad1f8bcadfd915cc24
|
data/Rakefile
CHANGED
data/bin/mega_lottery
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module MegaLottery
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
5
|
+
|
|
6
|
+
desc <<DESC
|
|
7
|
+
Description:
|
|
8
|
+
Copy MegaLottery configuration to an initializer.
|
|
9
|
+
DESC
|
|
10
|
+
|
|
11
|
+
def create_configuration
|
|
12
|
+
template "mega_lottery.rb", "config/initializers/mega_lottery.rb"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/mega_lottery.rb
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
require "mega_lottery/version"
|
|
2
|
+
require "mega_lottery/configuration"
|
|
2
3
|
require "mega_lottery/drawing"
|
|
3
4
|
|
|
5
|
+
require "mega_lottery/railtie" if defined?(Rails)
|
|
6
|
+
|
|
7
|
+
# this makes it so that pry only gets required if it's present,
|
|
8
|
+
# ie, when it's been added as a development_dependency
|
|
4
9
|
begin
|
|
5
10
|
require "pry"
|
|
6
11
|
rescue LoadError
|
|
@@ -8,4 +13,20 @@ end
|
|
|
8
13
|
|
|
9
14
|
module MegaLottery
|
|
10
15
|
# binding.pry
|
|
16
|
+
|
|
17
|
+
class << self
|
|
18
|
+
attr_writer :configuration
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.configuration
|
|
22
|
+
@configuration ||= Configuration.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.reset
|
|
26
|
+
@configuration = Configuration.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.configure
|
|
30
|
+
yield(configuration)
|
|
31
|
+
end
|
|
11
32
|
end
|
data/lib/mega_lottery/drawing.rb
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'rails'
|
|
2
|
+
require 'mega_lottery/helper'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
module MegaLottery
|
|
6
|
+
class Railtie < Rails::Railtie
|
|
7
|
+
initializer "mega_lottery.action_view" do
|
|
8
|
+
ActiveSupport.on_load(:action_view) do
|
|
9
|
+
include MegaLottery::Helper
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
rake_tasks do
|
|
14
|
+
load "mega_lottery/tasks/mega_lottery.rake"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
data/lib/mega_lottery/version.rb
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module MegaLottery
|
|
4
|
+
describe Configuration do
|
|
5
|
+
describe "#drawing_count" do
|
|
6
|
+
it "default value is 5" do
|
|
7
|
+
# Configuration.new.drawing_count = 6
|
|
8
|
+
expect(Configuration.new.drawing_count).to eq(5)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "#drawing_count=" do
|
|
13
|
+
it "can set value" do
|
|
14
|
+
config = Configuration.new
|
|
15
|
+
config.drawing_count = 7
|
|
16
|
+
expect(config.drawing_count).to eq(7)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "mega_lottery/helper"
|
|
3
|
+
|
|
4
|
+
class FakeView
|
|
5
|
+
include MegaLottery::Helper
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe FakeView do
|
|
9
|
+
describe "#mega_lottery_drawing" do
|
|
10
|
+
it "delegates to MegaLottery::Drawing#draw" do
|
|
11
|
+
drawing = double("drawing")
|
|
12
|
+
MegaLottery::Drawing.stub(:new).and_return(drawing)
|
|
13
|
+
expect(drawing).to receive(:draw)
|
|
14
|
+
FakeView.new.mega_lottery_drawing
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe MegaLottery do
|
|
4
|
+
describe "#configure" do
|
|
5
|
+
before do
|
|
6
|
+
MegaLottery.configure do |config|
|
|
7
|
+
config.drawing_count = 10
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "returns an array with 10 elements" do
|
|
12
|
+
draw = MegaLottery::Drawing.new.draw
|
|
13
|
+
|
|
14
|
+
expect(draw).to be_a(Array)
|
|
15
|
+
expect(draw.size).to eq(10)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
after do
|
|
19
|
+
MegaLottery.reset
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe ".reset" do
|
|
24
|
+
before :each do
|
|
25
|
+
MegaLottery.configure do |config|
|
|
26
|
+
config.drawing_count = 10
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "resets the configuration" do
|
|
31
|
+
MegaLottery.reset
|
|
32
|
+
|
|
33
|
+
config = MegaLottery.configuration
|
|
34
|
+
|
|
35
|
+
expect(config.drawing_count).to eq(5)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mega_lottery
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Derick Hitchcock
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-01-
|
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -69,7 +69,8 @@ dependencies:
|
|
|
69
69
|
description: Sample gem that i'm writing while reading 'Build a Ruby Gem'
|
|
70
70
|
email:
|
|
71
71
|
- hitchcock.derick@gmail.com
|
|
72
|
-
executables:
|
|
72
|
+
executables:
|
|
73
|
+
- mega_lottery
|
|
73
74
|
extensions: []
|
|
74
75
|
extra_rdoc_files: []
|
|
75
76
|
files:
|
|
@@ -79,11 +80,21 @@ files:
|
|
|
79
80
|
- LICENSE.txt
|
|
80
81
|
- README.md
|
|
81
82
|
- Rakefile
|
|
83
|
+
- bin/mega_lottery
|
|
84
|
+
- lib/generators/mega_lottery/install/install_generator.rb
|
|
85
|
+
- lib/generators/mega_lottery/install/templates/mega_lottery.rb
|
|
82
86
|
- lib/mega_lottery.rb
|
|
87
|
+
- lib/mega_lottery/configuration.rb
|
|
83
88
|
- lib/mega_lottery/drawing.rb
|
|
89
|
+
- lib/mega_lottery/helper.rb
|
|
90
|
+
- lib/mega_lottery/railtie.rb
|
|
91
|
+
- lib/mega_lottery/tasks/mega_lottery.rake
|
|
84
92
|
- lib/mega_lottery/version.rb
|
|
85
93
|
- mega_lottery.gemspec
|
|
94
|
+
- spec/mega_lottery/configuration_spec.rb
|
|
86
95
|
- spec/mega_lottery/drawing_spec.rb
|
|
96
|
+
- spec/mega_lottery/helper_spec.rb
|
|
97
|
+
- spec/mega_lottery_spec.rb
|
|
87
98
|
- spec/spec_helper.rb
|
|
88
99
|
homepage: http://thiswebsiteistaken.com
|
|
89
100
|
licenses:
|
|
@@ -110,5 +121,8 @@ signing_key:
|
|
|
110
121
|
specification_version: 4
|
|
111
122
|
summary: Sample gem
|
|
112
123
|
test_files:
|
|
124
|
+
- spec/mega_lottery/configuration_spec.rb
|
|
113
125
|
- spec/mega_lottery/drawing_spec.rb
|
|
126
|
+
- spec/mega_lottery/helper_spec.rb
|
|
127
|
+
- spec/mega_lottery_spec.rb
|
|
114
128
|
- spec/spec_helper.rb
|