ferris_bueller 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 851cf963e02b7fb8b97ff936c02ccc157103dbdc
4
+ data.tar.gz: d48f31dbee5016c1911b2c33d92de564094850f4
5
+ SHA512:
6
+ metadata.gz: c0bf0497e7272b7d9cc1c92cd94c4503a6497879d8fa0496d52394f7fe8957657c54273270da0f48d1f9376d668447a2dddf09d1bdda95de5bda8b587e8fc4c4
7
+ data.tar.gz: 5700e15dc9b4ee25ab8b16758e615b8a6df324cb86019d5c53840bae643849a98bc57219ffef774dc0c3337c57bb8da6448ee6a694fecfe8cee81dd98de64061
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ *.gem
15
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ferris_bueller.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Goldstar
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.
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # FerrisBueller
2
+
3
+ FerrisBueller is a gem for creating events.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ferris_bueller'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ferris_bueller
20
+
21
+ ## Usage
22
+
23
+ Creating an event:
24
+
25
+ ```
26
+ client = FerrisBueller::Client.new(url: 'your-event-service.com', token: '1337807')
27
+
28
+ client.create_event(
29
+ title: 'Jonan on Ice',
30
+ venue: {
31
+ name: 'Rose Garden',
32
+ locality: 'Portland',
33
+ region: 'Oregon'
34
+ },
35
+ shows: [
36
+ { date: '2015-03-01 19:00:00 -0700',
37
+ date_description: 'First Sunday of March',
38
+ time_description: "Seven o'clock at night" },
39
+ { date: '2015-03-08 19:00:00 -0700',
40
+ date_description: 'Second Sunday of March',
41
+ time_description: "Seven o'clock at night" },
42
+ { date: '2015-03-15 19:00:00 -0700',
43
+ date_description: 'Third Sunday of March',
44
+ time_description: "Seven o'clock at night" },
45
+ { date: '2015-03-22 19:00:00 -0700',
46
+ date_description: 'Third Sunday of March',
47
+ time_description: "Seven o'clock at night" },
48
+ { date: '2015-03-29 19:00:00 -0700',
49
+ date_description: 'Third Sunday of March',
50
+ time_description: "Seven o'clock at night" },
51
+ ],
52
+ source: "unique_name_for_your_event_source",
53
+ source_listing: {
54
+ title: 'Jonan on Ice',
55
+ where: 'The Rose Garden in Portland Oregon',
56
+ when: 'Every Sunday night in March at 7'
57
+ }
58
+ )
59
+ ```
60
+
61
+ The source_listing attribute is used to prevent insertion of duplicates and to maintain a
62
+ canonical record of imported events. It should include all of the data you
63
+ extracted from your source that consistently identifies this event.
64
+
65
+ Do not include timestamps or other data from your source that is likely to change
66
+ for the same event.
67
+
68
+ If two events have identical source listings only the first one will be inserted.
69
+
70
+ ### Response
71
+
72
+ FerrisBueller::Event.create will return a hash with the id of the event whether or not
73
+ it was created by your call. It will also return a boolean value to indicate
74
+ whether or not the data you submitted created that event.
75
+
76
+ ```
77
+ FerrisBueller::Event.create(...)
78
+ #=> { id: 7, created: false }
79
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ferris_bueller/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ferris_bueller"
8
+ spec.version = FerrisBueller::VERSION
9
+ spec.authors = ["Jonan Scheffler"]
10
+ spec.email = ["jonanscheffler@gmail.com"]
11
+ spec.summary = %q{Events gem}
12
+ spec.description = %q{A gem for creating events}
13
+ spec.homepage = "https://github.com/1337807"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "faraday", "~> 0.9.1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0'
26
+ spec.add_development_dependency "pry", "~> 0.10.1"
27
+ end
@@ -0,0 +1,36 @@
1
+ require 'faraday'
2
+
3
+ module FerrisBueller
4
+ class Client
5
+ attr_reader :connection
6
+
7
+ def initialize(options = {})
8
+ @url = from_options(:url, options)
9
+ @token = from_options(:token, options)
10
+
11
+ @connection = Faraday.new(url: @url)
12
+ @connection.token_auth(@token)
13
+ end
14
+
15
+ def from_options(key, options)
16
+ if value = options[key]
17
+ value
18
+ else
19
+ raise ArgumentError.new "#{key.inspect} is required."
20
+ end
21
+ end
22
+
23
+ def create_event(event_attributes)
24
+ validate_event_attributes(event_attributes)
25
+ self.connection.post '/events', event_attributes
26
+ end
27
+
28
+ def validate_event_attributes(event_attributes)
29
+ raise ArgumentError.new ":event is required." unless event_attributes[:event]
30
+
31
+ [:title, :venue, :shows, :source_listing, :source].each do |key|
32
+ raise ArgumentError.new ":event => #{key.inspect} is required." unless event_attributes[:event][key]
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module FerrisBueller
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "ferris_bueller/version"
2
+ require "ferris_bueller/client"
3
+
4
+ module FerrisBueller
5
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe FerrisBueller::Client do
4
+ it "must be created with a URL" do
5
+ expect { FerrisBueller::Client.new }.to raise_error ArgumentError, ":url is required."
6
+ end
7
+
8
+ it "must be created with an authentication token" do
9
+ expect { FerrisBueller::Client.new(url: '') }.to raise_error ArgumentError, ":token is required."
10
+ end
11
+
12
+ it "sets the authorization header on the connection with the provided token" do
13
+ client = FerrisBueller::Client.new(url: '', token: '1337807')
14
+ expect(client.connection.headers['Authorization']).to eql("Token token=\"1337807\"")
15
+ end
16
+
17
+ context "#create_event" do
18
+ let(:client) { client = FerrisBueller::Client.new(url: 'fake_url', token: '1337807') }
19
+
20
+ it "POSTs the event data to the events endpoint" do
21
+ expect(client.connection).to receive(:post).with('/events', anything)
22
+
23
+ client.create_event(event_data)
24
+ end
25
+
26
+ it "POSTs the provided event data" do
27
+ expect(client.connection).to receive(:post).with(anything, event_data)
28
+
29
+ client.create_event(event_data)
30
+ end
31
+
32
+ it "raises an error when the event is missing from the event data" do
33
+ event = event_data
34
+
35
+ event.delete(:event)
36
+ allow(client.connection).to receive(:post)
37
+ expect { client.create_event(event) }.to raise_error ArgumentError, ":event is required."
38
+ end
39
+
40
+ it "raises an error if any of the event attributes are missing" do
41
+ allow(client.connection).to receive(:post)
42
+
43
+ event_data[:event].keys.each do |key|
44
+ key_event_data = event_data
45
+ key_event_data[:event].delete key
46
+
47
+ expect { client.create_event(key_event_data) }.to raise_error ArgumentError, ":event => #{key.inspect} is required."
48
+ end
49
+ end
50
+ end
51
+
52
+ def event_data
53
+ {
54
+ event: {
55
+ title: "bueller_test_title",
56
+ venue: {
57
+ name: "bueller_test_venue_name",
58
+ locality: "bueller_test_locality",
59
+ region: "bueller_test_region"
60
+ },
61
+ shows: [
62
+ {
63
+ date: Time.now.to_s,
64
+ date_description: "bueller_test_show_date_description",
65
+ time_description: "bueller_test_show_date_description"
66
+ }
67
+ ],
68
+ source_listing: {
69
+ title: "bueller_test_source_listing_title"
70
+ },
71
+ source: "csv_upload"
72
+ }
73
+ }
74
+ end
75
+ end
@@ -0,0 +1,94 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+
20
+ require 'ferris_bueller'
21
+
22
+ RSpec.configure do |config|
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # The settings below are suggested to provide a good initial experience
47
+ # with RSpec, but feel free to customize to your heart's content.
48
+ =begin
49
+ # These two settings work together to allow you to limit a spec run
50
+ # to individual examples or groups you care about by tagging them with
51
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
52
+ # get run.
53
+ config.filter_run :focus
54
+ config.run_all_when_everything_filtered = true
55
+
56
+ # Limits the available syntax to the non-monkey patched syntax that is
57
+ # recommended. For more details, see:
58
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
59
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
60
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
61
+ config.disable_monkey_patching!
62
+
63
+ # This setting enables warnings. It's recommended, but in some cases may
64
+ # be too noisy due to issues in dependencies.
65
+ config.warnings = true
66
+
67
+ # Many RSpec users commonly either run the entire suite or an individual
68
+ # file, and it's useful to allow more verbose output when running an
69
+ # individual spec file.
70
+ if config.files_to_run.one?
71
+ # Use the documentation formatter for detailed output,
72
+ # unless a formatter has already been configured
73
+ # (e.g. via a command-line flag).
74
+ config.default_formatter = 'doc'
75
+ end
76
+
77
+ # Print the 10 slowest examples and example groups at the
78
+ # end of the spec run, to help surface which specs are running
79
+ # particularly slow.
80
+ config.profile_examples = 10
81
+
82
+ # Run specs in random order to surface order dependencies. If you find an
83
+ # order dependency and want to debug it, you can fix the order by providing
84
+ # the seed, which is printed after each run.
85
+ # --seed 1234
86
+ config.order = :random
87
+
88
+ # Seed global randomization in this process using the `--seed` CLI option.
89
+ # Setting this allows you to use `--seed` to deterministically reproduce
90
+ # test failures related to randomization by passing the same `--seed` value
91
+ # as the one that triggered the failure.
92
+ Kernel.srand config.seed
93
+ =end
94
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ferris_bueller
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonan Scheffler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 3.2.0
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '3.2'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 3.2.0
75
+ - !ruby/object:Gem::Dependency
76
+ name: pry
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 0.10.1
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 0.10.1
89
+ description: A gem for creating events
90
+ email:
91
+ - jonanscheffler@gmail.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - ferris_bueller.gemspec
102
+ - lib/ferris_bueller.rb
103
+ - lib/ferris_bueller/client.rb
104
+ - lib/ferris_bueller/version.rb
105
+ - spec/ferris_bueller/client_spec.rb
106
+ - spec/spec_helper.rb
107
+ homepage: https://github.com/1337807
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.4.5
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Events gem
131
+ test_files:
132
+ - spec/ferris_bueller/client_spec.rb
133
+ - spec/spec_helper.rb
134
+ has_rdoc: