diff --git a/.gitignore b/.gitignore deleted file mode 100644 index d880d8c..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -vendor -.bundle diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..83e16f8 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 5859406..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.2.3 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5a4e2c1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: node_js -node_js: - - 5.10.1 -addons: - postgresql: "9.4" -before_install: - - rvm install 2.2.3 -install: - # run whatever you have to do here. I have a Makefile that lets you install - # all Node.js-related or Ruby-related dependencies as one step. - - make npm - - make bundler -before_script: - # My Rails app lives in a subdirectory. I want to make sure that - # my database is ready before I start running RSpec tests - - psql -c 'create database test_db;' -U postgres - # I use separate database.yml config for Travis CI - - cp webapp/config/database.travis.yml webapp/config/database.yml -script: - # `test` target executes `bundle exec rspec spec` and `npm run test` - # in all appropriate subdirectories - - make test -shareeditflag diff --git a/Gemfile b/Gemfile index 31ce048..1bc8134 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,16 @@ -source :rubygems +# frozen_string_literal: true +source "https://rubygems.org" -gem 'rack-contrib' -gem 'shotgun', group: :development +gem "redcarpet" +gem "haml" +gem "rack" +gem "rack-contrib" + +group :development do + gem "shotgun" + gem "awesome_print" +end + +group :development, :test do + gem "rspec" +end diff --git a/Gemfile.lock b/Gemfile.lock index 182dd45..1d39433 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,18 +1,42 @@ GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: + awesome_print (1.7.0) + diff-lcs (1.3) + haml (4.0.7) + tilt rack (2.0.1) rack-contrib (1.2.0) rack (>= 0.9.1) + redcarpet (3.4.0) + rspec (3.5.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) shotgun (0.9.2) rack (>= 1.0) + tilt (2.0.6) PLATFORMS ruby DEPENDENCIES + awesome_print + haml + rack rack-contrib + redcarpet + rspec shotgun BUNDLED WITH - 1.13.7 + 1.14.3 diff --git a/NOTES b/NOTES deleted file mode 100644 index 2327b42..0000000 --- a/NOTES +++ /dev/null @@ -1,10 +0,0 @@ -The Ruby Racer -http://stackoverflow.com/questions/14829275/therubyracer-or-nodejs-which-should-i-use - -Heroku Build Packs (i.e. Node + Ruby) - -https://medium.com/@rdsubhas/ruby-in-production-lessons-learned-36d7ab726d99#.cjpomdpyn - -https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app - -https://www.codementor.io/inanc/tutorials/how-to-run-python-and-ruby-on-heroku-with-multiple-buildpacks-kgy6g3b1e?utm_term=heroku-multi-buildpacks&utm_content=buffer60758&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer diff --git a/README.md b/README.md index 9d5c48e..d77ddde 100644 --- a/README.md +++ b/README.md @@ -1,78 +1,39 @@ # devpunks -### DSL (Domain Specific Language) for ([config.ru](https://github.com/NYCrb/devpunks/blob/master/config.ru)) -Inspired by Express.js _(http://expressjs.com/)_ routing. +> devpunk starts with just a rack app and a dream -#### static! -Expose static files _(defaults to ./public)_ -```ruby -static! -```` +Right now, this codebase only exists to serve the website for devpunks dot com. -#### four_oh_four! -Fallback error page for missing route definitions. -```ruby -four_oh_four! # /not-found => 404 & renders ./public/404.html -```` +But five minutes from now, it could be anything! -#### route -Define handler for route URI -```ruby -route ('/foo') { 'devPunks' } -```` +# Contributing -#### params -Access to _(GET, POST, PUT, & PATCH)_ request parameters -```ruby -route ('/echo?value=Hello') { "#{params[:value]} World!" } -```` +The site copy and configuration are stored in YAML files under `data/`. -#### status -Get or set the response code. -```ruby -status 201 #=> Responds with 201 CREATED -```` +devpunk uses `EasyData` to massage info from these files for use in templates. -#### json -Responds with a JSON body -```ruby -json(foo: 'bar', baz: 'bat') #=> "{\"foo\":\"bar\", \"baz\":\"bat\"}" -```` +See `homepage.rb` and `events.rb` for examples of endpoints. -#### run! -Run the Application -```ruby -run! -```` +See `config.ru` for how to add and route to endpoints. -### Install -```bash -$ bundle -``` - -### Running Server -#### Development +# Running +## Development ```bash $ bundle exec shotgun ``` -#### Production +## Production ```bash $ rackup ``` -### Dependencies - - [Rack](https://rack.github.io) - -#### Development - - [Shotgun](https://github.com/rtomayko/shotgun#shotgun) - -### Skeleton Framework: or...Why Rack? -Web Servers vs. App Servers -http://www.justinweiss.com/articles/a-web-server-vs-an-app-server/ +# Dependencies +- [Rack](https://rack.github.io) -Rails vs. Sinatra -https://blog.engineyard.com/2014/rails-vs-sinatra +## Development +- [Shotgun](https://github.com/rtomayko/shotgun#shotgun) -How Does Rack Work? -https://blog.engineyard.com/2015/understanding-rack-apps-and-middleware +# Skeleton Framework: or...Why Rack? +- [Web Servers vs. App Servers](http://www.justinweiss.com/articles/a-web-server-vs-an-app-server/) +- [Rails vs. Sinatra](https://blog.engineyard.com/2014/rails-vs-sinatra) +- [How Does Rack Work?](https://blog.engineyard.com/2015/understanding-rack-apps-and-middleware) diff --git a/action.rb b/action.rb deleted file mode 100644 index fc29281..0000000 --- a/action.rb +++ /dev/null @@ -1,38 +0,0 @@ -class Action - attr_reader :headers, :body, :request - - def initialize(&block) - @block = block - @headers = {'Content-Type' => 'application/json'} - end - - def call(env) - @request = Rack::Request.new(env) - - evaluate_body - - [status, headers, [body]] - end - - private - - def status(code=200) - @status ||= code - end - - def params - request.params - .tap { |r| r.symbolize_keys! } - end - - def json(payload) - JSON.dump(payload.to_h) - end - - def evaluate_body - # "Some 🎩 magik🎩 stuff is happening" - Jan - # http://web.stanford.edu/~ouster/cgi-bin/cs142-winter15/classEval.php - - @body = instance_eval &@block - end -end diff --git a/application.rb b/application.rb deleted file mode 100644 index 00a538e..0000000 --- a/application.rb +++ /dev/null @@ -1 +0,0 @@ -Application = Rack::Builder.new diff --git a/config.ru b/config.ru index fb1fdc8..f3b2805 100644 --- a/config.ru +++ b/config.ru @@ -1,15 +1,24 @@ -%w[hash] - .each { |extension| require_relative "./extensions/#{extension}" } +require "rack" +require "rack/contrib" -%w[events] - .each { |store| require_relative "./stores/#{store}" } +require "./homepage" +require "./events" -require_relative './helpers' +use Rack::ShowExceptions -static! +use Rack::TryStatic, + root: "public", + urls: %w[/] -four_oh_four! +map "/events" do + run DevPunks::Events.new +end -route ('/events') { json Events } - -run! +run lambda { |env| + case env["PATH_INFO"] + when "/" + DevPunks::HomePage.new + else + Rack::NotFound.new("public/404.html") + end.call env +} diff --git a/data/index.yaml b/data/index.yaml new file mode 100644 index 0000000..27faac9 --- /dev/null +++ b/data/index.yaml @@ -0,0 +1,40 @@ +title: devpunks \m/ +blurb: The first technology show from junior to super senior developer in 15 minutes. + +mission: > + Devpunks include a diverse array of ideologies, fashions and forms of + expression, including visual art, literature, and film. Devpunk are largely + characterized by **anti-establishment** views and the promotion of + **individual freedom**. The devpunk is centered on a loud, aggressive genre + of developers. It is usually played by small teams consisting of a junior, + one or two seniors, and a hiring manager. + +politics: > + devpunk politics cover the entire political spectrum. devpunk-related + ideologies are mostly concerned with individual freedom and + anti-establishment views. Common devpunk viewpoints include + anti-authoritarianism, a DIY ethic, non-conformity, direct action and not + selling out. + +community: > + devpunks can come from any and all walks of life and economic classes. + Compared to some alternative cultures, devpunk is much closer to being gender + equalist in terms of its ideology. + + One part of devpunk is creating explicitly outward identities of mentality. + Everything that was normally supposed to be hidden was brought to the front, + both literally and figuratively. + +media: > + Devpunks often follow a DIY policy of filming the footage first, without + permission, and also posting it without permission, but will generally take + down material if asked. Founder Joly MacFie argues that this serves an + important archival purpose. + + Devpunk Communities use collaborative podcasts & vocasts to support + multiple contributors podcasting through generally simplified processes, and + without having to host their own individual feeds. A community podcast can + also allow members of the community (related to the podcast topic) to + contribute to the podcast in many different ways. This method was first used + for a series of podcasts hosted by the Regional Educational Technology Center + at Fordham University in 2005. diff --git a/data/site.yaml b/data/site.yaml new file mode 100644 index 0000000..9b1d0db --- /dev/null +++ b/data/site.yaml @@ -0,0 +1,33 @@ +links: + twitter: + icon: 🐦 + url: http://twitter.com/devpunks + title: Twitter + github: + icon: πŸ’Ύ + url: http://github.com/nycrb/devpunks + title: GitHub + youtube: + icon: 🎬 + url: https://www.youtube.com/channel/UCdbw8GpAB4pjVacUTtGUemQ + title: YouTube + email: + icon: πŸ“¨ + url: mailto:help@devpunks.com + title: E-Mail + +sponsors: + pivotal: + title: Pivotal Labs + url: http://pivotal.io + +posts: + decaf: + title: Rails Decaf *(sans CoffeeScript & Sprockets)* + url: http://blog.arkency.com/2015/03/gulp-modern-approach-to-asset-pipeline-for-rails-developers/ + +tools: + termjs: + title: term.js + url: https://github.com/chjj/term.js + blurb: A terminal written in JavaScript diff --git a/easy_data.rb b/easy_data.rb new file mode 100644 index 0000000..57a1d76 --- /dev/null +++ b/easy_data.rb @@ -0,0 +1,72 @@ +require "yaml" +require "ostruct" + +require "./markdown" + +# EasyData +# +# EasyData["site", "index"] +# => data/site.yaml +# => data/index.yaml +# +# EasyData reads each YAML file provided and merges them all into a single hash +# +# The hash can then be passed into Haml::Engine#render() and used as locals in +# templates. EasyData makes some changes so the data is easier to work with: + +# DOT ATTRIBUTES +# +# For simple informational hashes, EasyData wraps the hash in an OpenStruct, +# which allows us to do things like link.url (as opposed to link["url"], which +# let's face it, is just way more annoying) + +# MARKDOWN +# +# For all strings, EasyData runs the string through a Markdown HTML renderer so +# we can easily include formatting anywhere in the site data. + +module DevPunks + module EasyData + TRANSFORMS = [ + # PHASE 1 - Transforms that change the enumerability of objects + [String, -> obj { obj.include?("\n") ? obj.split("\n") : obj }], + + # PHASE 2 - Recursion into enumerable objects + [Hash , -> obj { obj.map { |k, v| [k, transform(v)] }.to_h } ], + [Array , -> obj { obj.map { |v| transform(v) } } ], + + # PHASE 3 - Transforms that improve the format/usability of objects + [Hash , -> obj { hash_to_data_object(obj) } ], + [String, -> obj { DevPunks::Markdown.render_inline(obj) } ] + ] + + def self.[] *files + files.reduce({}) do |hash, file| + hash.merge transformed_data_from(File.join("data", file + ".yaml")) + end + end + + def self.transformed_data_from file + YAML.load_file(file).reduce({}) do |hash, (key, value)| + hash.merge key => transform(value) + end + end + + def self.transform object + TRANSFORMS.reduce(object) do |obj, (type, transform)| + obj.is_a?(type) ? transform.call(obj) : obj + end + end + + def self.hash_to_data_object hash + if hash.all? { |_, v| v.is_a?(Hash) || v.is_a?(OpenStruct) } + # If this hash's values are all Hashes or OpenStructs, then it must be + # a nested hash for organizing data objects, and it should be left as a + # Hash so it can be enumerated by loops in the view + hash + else + OpenStruct.new hash + end + end + end +end diff --git a/events.rb b/events.rb new file mode 100644 index 0000000..bd6ee4a --- /dev/null +++ b/events.rb @@ -0,0 +1,37 @@ +require "json" +require "date" +require "open-uri" + +module DevPunks + class Events + API_URL = "https://api.meetup.com/NYC-rb/events?status=past" + + def call env + [200, { "Content-Type" => "application/json" }, [body]] + end + + def body + JSON.dump to_h + end + + def to_h + data.map do |hash| + { + "Name": hash["name"], + "Date": date_format(hash["time"]), + "Attendee Limit": hash["rsvp_limit"], + "Attended": hash["yes_rsvp_count"], + "Link": hash["link"] + } + end + end + + def data + @data ||= JSON.parse open(API_URL).read + end + + def date_format time + Time.at(time / 1_000).strftime "%Y-%m-%d" + end + end +end diff --git a/extensions/hash.rb b/extensions/hash.rb deleted file mode 100644 index f86cf23..0000000 --- a/extensions/hash.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Hash - def symbolize_keys! - keys - .each {|key| self[key.to_sym] = delete(key) } - end -end diff --git a/helpers.rb b/helpers.rb deleted file mode 100644 index 65bc4f2..0000000 --- a/helpers.rb +++ /dev/null @@ -1,33 +0,0 @@ -require './action' -require './application' -require 'rack/contrib/not_found' -require 'rack/contrib/try_static' - -def four_oh_four!( path = './public/404.html' ) - Application.run Rack::NotFound.new(path) -end - -def static!( path='public' ) - options = { - gzip: true, - root: path, - urls: ['/'], - index: 'index.html', - - try: ['.html'] - } - - Application.map options[:urls].first do - use Rack::TryStatic, options - end -end - -def route(pattern, &block) - Application.map pattern do - run Action.new &block - end -end - -def run! - run Application -end diff --git a/homepage.rb b/homepage.rb new file mode 100644 index 0000000..bd49097 --- /dev/null +++ b/homepage.rb @@ -0,0 +1,19 @@ +require "haml" + +require "./easy_data" + +module DevPunks + class HomePage + def call env + [200, { "Content-Type" => "text/html" }, [body]] + end + + def body + template.render self, EasyData["site", "index"] + end + + def template + Haml::Engine.new File.read("index.haml") + end + end +end diff --git a/index.haml b/index.haml new file mode 100644 index 0000000..3d3f7b5 --- /dev/null +++ b/index.haml @@ -0,0 +1,61 @@ +!!!html +%html{lang: "en"} + %head + %title= title + %link{rel: "stylesheet", href: "style.css"} + + %body + %h1= title + %blockquote= blurb + + %main + %img{src: "quote.png", alt: "devpunks"} + + %section#mission + - mission.each do |m| + %p= m + + %section#politics + %h1 Politics + - politics.each do |p| + %p= p + + %section#community + %h1 Community + - community.each do |c| + %p= c + + %section#media + %h1 devpunk vodcast + - media.each do |m| + %p= m + + %section#sponsors + %h1 Sponsors + %dl + - sponsors.each do |key, s| + %dt + %a{title: s.title, href: s.url}= s.title + %dd + %p Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + + %q fight the technocracy! + %cite https://www.wikiwand.com/en/technocracy + + %aside + %h1 Off the Beaten Post + %ul + = list_of posts do |key, p| + %a{href: p.url}= p.title + + %h1 Tools + %ul + = list_of tools do |key, t| + %a{href: t.url}= t.title + + %footer + %nav + %h1 βš“ devpunk Links + %ul + = list_of links do |key, l| + %a{href: l.url, title: l.title}= l.title diff --git a/markdown.rb b/markdown.rb new file mode 100644 index 0000000..bcfd8cf --- /dev/null +++ b/markdown.rb @@ -0,0 +1,20 @@ +require "redcarpet" + +module DevPunks + module Markdown + Engine = Redcarpet::Markdown.new(Redcarpet::Render::HTML) + + def self.render str + Engine.render(str) + end + + def self.render_inline str + # By default, the Markdown HTML renderer wraps everything in

tags. + # It also appends a \n to the end of every rendered output string. Since + # many of the things we're Markdowning are meant to be inline, the

+ # tags and \n are stripped out here, leaving the decision to the + # template(s). + self.render(str).strip[3...-4] + end + end +end diff --git a/public/.DS_Store b/public/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/public/.DS_Store and /dev/null differ diff --git a/public/120 - iPhone.png b/public/120 - iPhone.png deleted file mode 100644 index 282bb5d..0000000 Binary files a/public/120 - iPhone.png and /dev/null differ diff --git a/public/background.png b/public/background.png deleted file mode 100644 index 7d661ee..0000000 Binary files a/public/background.png and /dev/null differ diff --git a/public/index.html b/public/index.html deleted file mode 100644 index a3de566..0000000 --- a/public/index.html +++ /dev/null @@ -1,123 +0,0 @@ -devpunks \m/ - - - -

devpunks \m/

- - -

The first technology show from junior to super senior developer in 15 minutes.

- - -
- devpunks - -
-

Devpunks include a diverse array of ideologies, fashions and forms of expression, including visual art, literature, and film. Devpunk are largely characterized by anti-establishment views and the promotion of individual freedom. The devpunk is centered on a loud, aggressive genre of developers. It is usually played by small teams consisting of a junior, one or two seniors, and a hiring manager. -

- -
-
Politics
- -

devpunk politics cover the entire political spectrum. devpunk-related ideologies are mostly concerned with individual freedom and anti-establishment views. Common devpunk viewpoints include anti-authoritarianism, a DIY ethic, non-conformity, direct action and not selling out. -

- -
-
Community
- -

devpunks can come from any and all walks of life and economic classes. Compared to some alternative cultures, devpunk is much closer to being gender equalist in terms of its ideology. - -

One part of devpunk is creating explicitly outward identities of mentality. Everything that was normally supposed to be hidden was brought to the front, both literally and figuratively. -

- -
-
Devpunk Vodcast
- -

Devpunks often follow a DIY policy of filming the footage first, without permission, and also posting it without permission, but will generally take down material if asked. Founder Joly MacFie argues that this serves an important archival purpose. - -

Devpunk Communities use collaborative podcasts & vocasts to support multiple contributors podcasting through generally simplified processes, and without having to host their own individual feeds. A community podcast can also allow members of the community (related to the podcast topic) to contribute to the podcast in many different ways. This method was first used for a series of podcasts hosted by the Regional Educational Technology Center at Fordham University in 2005. - -

-
-
πŸ’» devpunks: β€œThis is the Show Title”
- -
-
- @devpunks - First Guest -
- - - First Guest - -
- - - @JessiTron - -
- -
- - -
30:00 minute viewing time
-
- -

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. - -

- -
-
-
-
- -
-
Sponsors
- -
-
- Pivotal Labs -
-
-

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. -

-
-
-
- -fight the technocracy! -https://www.wikiwand.com/en/technocracy - - - - diff --git a/public/login.html b/public/login.html deleted file mode 100644 index e9c11d3..0000000 --- a/public/login.html +++ /dev/null @@ -1,5 +0,0 @@ -

This is the login page

- - diff --git a/public/wallpaper.png b/public/wallpaper.png deleted file mode 100644 index 8496291..0000000 Binary files a/public/wallpaper.png and /dev/null differ diff --git a/spec/easy_data_spec.rb b/spec/easy_data_spec.rb new file mode 100644 index 0000000..e6b7f39 --- /dev/null +++ b/spec/easy_data_spec.rb @@ -0,0 +1,58 @@ +require "./easy_data" + +# Terminology +# +# data hash: +# a hash with at least one non-hash value +# +# data object: +# has attributes that can be accessed using dot notation + +RSpec.describe "easy data" do + let(:caesar) do + { + name: "Caesar", + age: 40 + } + end + + def handle obj + DevPunks::EasyData.transform obj + end + + it "turns data hashes into data objects" do + expect(handle caesar).to have_attributes caesar + end + + it "leaves nested hashes as hashes" do + expect(handle(person: caesar)).to be_a Hash + end + + it "parses markdown in string attributes" do + expect( + handle caesar.merge( + description: "inventor of *salad*" + ) + ).to have_attributes description: "inventor of salad" + end + + it "parses markdown in arrays of strings" do + expect(handle ["*foo*", "bar"]).to eq ["foo", "bar"] + end + + it "splits multi para heredoc-style text (> in yaml) into arrays" do + expect( + handle caesar.merge( + history: "betrayed by his brother Cobb\ndied of high cholesterol" + ) + ).to have_attributes history: ["betrayed by his brother Cobb", "died of high cholesterol"] + end + + it "splits single para heredoc-style text (> in yaml) into arrays" do + expect( + handle caesar.merge( + history: "betrayed by his brother Cobb\n" + ) + ).to have_attributes history: ["betrayed by his brother Cobb"] + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..47b39ce --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,103 @@ +# This file was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end diff --git a/stores/events.rb b/stores/events.rb deleted file mode 100644 index 7a48d2c..0000000 --- a/stores/events.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'json' -require 'date' -require 'open-uri' - -class Events - def self.to_h - data.map do |hash| - { - "Name": "#{hash['name']}", - "Date": "#{date_format(hash['time'])}", - "Attendee Limit": "#{hash['rsvp_limit']}", - "Attended": "#{hash['yes_rsvp_count']}", - "Link": "#{hash['link']}" - } - end - end - - def self.data - uri = 'https://api.meetup.com/NYC-rb/events?status=past' - - @data ||= JSON.parse(open(uri).read) - end - - def self.date_format(time) - Time.at(( time / 1_000 )).strftime '%Y-%m-%d' - end -end