forked from starburstgem/starburst
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 27ee468
Showing
67 changed files
with
1,052 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.bundle/ | ||
log/*.log | ||
pkg/ | ||
test/dummy/db/*.sqlite3 | ||
test/dummy/db/*.sqlite3-journal | ||
test/dummy/log/*.log | ||
test/dummy/tmp/ | ||
test/dummy/.sass-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
source "https://rubygems.org" | ||
|
||
# Declare your gem's dependencies in starburst.gemspec. | ||
# Bundler will treat runtime dependencies like base dependencies, and | ||
# development dependencies will be added by default to the :development group. | ||
gemspec | ||
|
||
# Declare any dependencies that are still in development here instead of in | ||
# your gemspec. These might include edge Rails or gems from your path or | ||
# Git. Remember to move these dependencies to your gemspec before releasing | ||
# your gem to rubygems.org. | ||
|
||
# To use debugger | ||
# gem 'debugger' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
starburst (0.0.1) | ||
rails (~> 4.1.4) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actionmailer (4.1.6) | ||
actionpack (= 4.1.6) | ||
actionview (= 4.1.6) | ||
mail (~> 2.5, >= 2.5.4) | ||
actionpack (4.1.6) | ||
actionview (= 4.1.6) | ||
activesupport (= 4.1.6) | ||
rack (~> 1.5.2) | ||
rack-test (~> 0.6.2) | ||
actionview (4.1.6) | ||
activesupport (= 4.1.6) | ||
builder (~> 3.1) | ||
erubis (~> 2.7.0) | ||
activemodel (4.1.6) | ||
activesupport (= 4.1.6) | ||
builder (~> 3.1) | ||
activerecord (4.1.6) | ||
activemodel (= 4.1.6) | ||
activesupport (= 4.1.6) | ||
arel (~> 5.0.0) | ||
activesupport (4.1.6) | ||
i18n (~> 0.6, >= 0.6.9) | ||
json (~> 1.7, >= 1.7.7) | ||
minitest (~> 5.1) | ||
thread_safe (~> 0.1) | ||
tzinfo (~> 1.1) | ||
arel (5.0.1.20140414130214) | ||
builder (3.2.2) | ||
erubis (2.7.0) | ||
hike (1.2.3) | ||
i18n (0.6.11) | ||
json (1.8.1) | ||
mail (2.6.1) | ||
mime-types (>= 1.16, < 3) | ||
mime-types (2.3) | ||
minitest (5.4.2) | ||
multi_json (1.10.1) | ||
rack (1.5.2) | ||
rack-test (0.6.2) | ||
rack (>= 1.0) | ||
rails (4.1.6) | ||
actionmailer (= 4.1.6) | ||
actionpack (= 4.1.6) | ||
actionview (= 4.1.6) | ||
activemodel (= 4.1.6) | ||
activerecord (= 4.1.6) | ||
activesupport (= 4.1.6) | ||
bundler (>= 1.3.0, < 2.0) | ||
railties (= 4.1.6) | ||
sprockets-rails (~> 2.0) | ||
railties (4.1.6) | ||
actionpack (= 4.1.6) | ||
activesupport (= 4.1.6) | ||
rake (>= 0.8.7) | ||
thor (>= 0.18.1, < 2.0) | ||
rake (10.3.2) | ||
sprockets (2.12.2) | ||
hike (~> 1.2) | ||
multi_json (~> 1.0) | ||
rack (~> 1.0) | ||
tilt (~> 1.1, != 1.3.0) | ||
sprockets-rails (2.1.4) | ||
actionpack (>= 3.0) | ||
activesupport (>= 3.0) | ||
sprockets (~> 2.8) | ||
sqlite3 (1.3.9) | ||
thor (0.19.1) | ||
thread_safe (0.3.4) | ||
tilt (1.4.1) | ||
tzinfo (1.2.2) | ||
thread_safe (~> 0.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
sqlite3 | ||
starburst! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright 2014 YOURNAME | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
= Starburst | ||
|
||
This project rocks and uses MIT-LICENSE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
begin | ||
require 'bundler/setup' | ||
rescue LoadError | ||
puts 'You must `gem install bundler` and `bundle install` to run rake tasks' | ||
end | ||
|
||
require 'rdoc/task' | ||
|
||
RDoc::Task.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'Starburst' | ||
rdoc.options << '--line-numbers' | ||
rdoc.rdoc_files.include('README.rdoc') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end | ||
|
||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) | ||
load 'rails/tasks/engine.rake' | ||
|
||
|
||
|
||
Bundler::GemHelper.install_tasks | ||
|
||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.libs << 'test' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = false | ||
end | ||
|
||
|
||
task default: :test |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// This is a manifest file that'll be compiled into application.js, which will include all the files | ||
// listed below. | ||
// | ||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, | ||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. | ||
// | ||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | ||
// compiled file. | ||
// | ||
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details | ||
// about supported directives. | ||
// | ||
//= require_tree . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* This is a manifest file that'll be compiled into application.css, which will include all the files | ||
* listed below. | ||
* | ||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, | ||
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. | ||
* | ||
* You're free to add application-wide styles to this file and they'll appear at the bottom of the | ||
* compiled file so the styles you add here take precedence over styles defined in any styles | ||
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new | ||
* file per style scope. | ||
* | ||
*= require_tree . | ||
*= require_self | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Starburst | ||
class ApplicationController < ActionController::Base | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Starburst | ||
module ApplicationHelper | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module Starburst | ||
class Announcement < ActiveRecord::Base | ||
serialize :limit_to_users | ||
|
||
if Rails::VERSION::MAJOR < 4 | ||
attr_accessible(:title, :body, :start_delivering_at, :stop_delivering_at, :limit_to_users) | ||
end | ||
|
||
scope :ready_for_delivery, -> { | ||
where("(start_delivering_at < ? OR start_delivering_at IS NULL) | ||
AND (stop_delivering_at > ? OR stop_delivering_at IS NULL)", Time.now, Time.now) | ||
} | ||
|
||
scope :unread_by, -> (current_user) { | ||
joins("LEFT JOIN announcement_views ON | ||
announcement_views.announcement_id = announcements.id AND | ||
announcement_views.user_id = #{Announcement.sanitize(current_user.id)}") | ||
.where("announcement_views.announcement_id IS NULL AND announcement_views.user_id IS NULL") | ||
} | ||
|
||
scope :in_delivery_order, -> { order("start_delivering_at ASC")} | ||
|
||
def self.user_methods | ||
# TODO: Bring these into gem config | ||
["free?"] | ||
end | ||
|
||
def self.current(current_user = nil) | ||
if current_user | ||
find_announcement_for_current_user(ready_for_delivery.unread_by(current_user).in_delivery_order, current_user) | ||
else | ||
ready_for_delivery.in_delivery_order.first | ||
end | ||
end | ||
|
||
def self.find_announcement_for_current_user(announcements, user) | ||
user_as_array = user.serializable_hash(methods: self.user_methods) | ||
announcements.each do |announcement| | ||
if user_matches_conditions(user_as_array, announcement.limit_to_users) | ||
return announcement | ||
end | ||
end | ||
return nil | ||
end | ||
|
||
def self.user_matches_conditions(user, conditions = nil) | ||
if conditions | ||
conditions.each do |condition| | ||
if user[condition[:field]] != condition[:value] | ||
return false | ||
end | ||
end | ||
end | ||
return true | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Starburst</title> | ||
<%= stylesheet_link_tag "starburst/application", media: "all" %> | ||
<%= javascript_include_tag "starburst/application" %> | ||
<%= csrf_meta_tags %> | ||
</head> | ||
<body> | ||
|
||
<%= yield %> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env ruby | ||
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. | ||
|
||
ENGINE_ROOT = File.expand_path('../..', __FILE__) | ||
ENGINE_PATH = File.expand_path('../../lib/starburst/engine', __FILE__) | ||
|
||
# Set up gems listed in the Gemfile. | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | ||
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) | ||
|
||
require 'rails/all' | ||
require 'rails/engine/commands' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Starburst::Engine.routes.draw do | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class CreateAnnouncementTables < ActiveRecord::Migration | ||
def change | ||
create_table :starburst_announcements_reads do |t| | ||
t.integer :user_id | ||
t.integer :announcement_id | ||
t.timestamps | ||
end | ||
create_table :starburst_announcements do |t| | ||
t.text :title | ||
t.text :body | ||
t.datetime :start_delivering_at | ||
t.datetime :stop_delivering_at | ||
t.text :limit_to_users | ||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require "starburst/engine" | ||
|
||
module Starburst | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Starburst | ||
class Engine < ::Rails::Engine | ||
isolate_namespace Starburst | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Starburst | ||
VERSION = "0.0.1" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# desc "Explaining what the task does" | ||
# task :starburst do | ||
# # Task goes here | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
$:.push File.expand_path("../lib", __FILE__) | ||
|
||
# Maintain your gem's version: | ||
require "starburst/version" | ||
|
||
# Describe your gem and declare its dependencies: | ||
Gem::Specification.new do |s| | ||
s.name = "starburst" | ||
s.version = Starburst::VERSION | ||
s.authors = ["TODO: Your name"] | ||
s.email = ["TODO: Your email"] | ||
s.homepage = "TODO" | ||
s.summary = "TODO: Summary of Starburst." | ||
s.description = "TODO: Description of Starburst." | ||
s.license = "MIT" | ||
|
||
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] | ||
s.test_files = Dir["test/**/*"] | ||
|
||
s.add_dependency "rails", "~> 4.1.4" | ||
|
||
s.add_development_dependency "sqlite3" | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
== README | ||
|
||
This README would normally document whatever steps are necessary to get the | ||
application up and running. | ||
|
||
Things you may want to cover: | ||
|
||
* Ruby version | ||
|
||
* System dependencies | ||
|
||
* Configuration | ||
|
||
* Database creation | ||
|
||
* Database initialization | ||
|
||
* How to run the test suite | ||
|
||
* Services (job queues, cache servers, search engines, etc.) | ||
|
||
* Deployment instructions | ||
|
||
* ... | ||
|
||
|
||
Please feel free to use a different markup language if you do not plan to run | ||
<tt>rake doc:app</tt>. |
Oops, something went wrong.