daily 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.
Files changed (93) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.mdown +46 -0
  3. data/Rakefile +7 -0
  4. data/app/assets/images/rails.png +0 -0
  5. data/app/assets/javascripts/application.js +9 -0
  6. data/app/assets/stylesheets/application.css +16 -0
  7. data/app/assets/stylesheets/bootstrap.css +2467 -0
  8. data/app/controllers/application_controller.rb +14 -0
  9. data/app/controllers/files_controller.rb +5 -0
  10. data/app/controllers/main_controller.rb +5 -0
  11. data/app/controllers/reports_controller.rb +35 -0
  12. data/app/controllers/tables_controller.rb +20 -0
  13. data/app/controllers/users_controller.rb +28 -0
  14. data/app/formatters/html_formatter.rb +65 -0
  15. data/app/formatters/json_formatter.rb +81 -0
  16. data/app/helpers/application_helper.rb +85 -0
  17. data/app/jobs/generate_report_job.rb +13 -0
  18. data/app/models/report.rb +112 -0
  19. data/app/models/table.rb +65 -0
  20. data/app/models/user.rb +20 -0
  21. data/app/transforms/column_filter.rb +7 -0
  22. data/app/transforms/moving_average.rb +119 -0
  23. data/app/transforms/transform.rb +32 -0
  24. data/app/views/devise/sessions/new.erb +15 -0
  25. data/app/views/layouts/application.html.erb +40 -0
  26. data/app/views/main/home.erb +4 -0
  27. data/app/views/reports/_form.erb +14 -0
  28. data/app/views/reports/_list.erb +9 -0
  29. data/app/views/reports/edit.erb +2 -0
  30. data/app/views/reports/index.erb +3 -0
  31. data/app/views/reports/new.erb +2 -0
  32. data/app/views/reports/show.erb +23 -0
  33. data/app/views/tables/_form.erb +8 -0
  34. data/app/views/tables/_list.erb +9 -0
  35. data/app/views/tables/edit.erb +2 -0
  36. data/app/views/tables/index.erb +3 -0
  37. data/app/views/tables/new.erb +2 -0
  38. data/app/views/tables/show.erb +35 -0
  39. data/app/views/users/_form.erb +5 -0
  40. data/app/views/users/_items.erb +8 -0
  41. data/app/views/users/_list.erb +9 -0
  42. data/app/views/users/edit.erb +2 -0
  43. data/app/views/users/index.erb +3 -0
  44. data/app/views/users/new.erb +2 -0
  45. data/app/views/users/show.erb +4 -0
  46. data/config/application.rb +52 -0
  47. data/config/authorization_rules.rb +49 -0
  48. data/config/boot.rb +6 -0
  49. data/config/daily.example.yml +19 -0
  50. data/config/daily.yml +27 -0
  51. data/config/database.yml +25 -0
  52. data/config/environment.rb +5 -0
  53. data/config/environments/development.rb +32 -0
  54. data/config/environments/production.rb +63 -0
  55. data/config/environments/test.rb +39 -0
  56. data/config/initializers/backtrace_silencers.rb +7 -0
  57. data/config/initializers/devise.rb +212 -0
  58. data/config/initializers/inflections.rb +10 -0
  59. data/config/initializers/mime_types.rb +5 -0
  60. data/config/initializers/ruport.rb +5 -0
  61. data/config/initializers/secret_token.rb +7 -0
  62. data/config/initializers/session_store.rb +8 -0
  63. data/config/initializers/simple_form.rb +113 -0
  64. data/config/initializers/wrap_parameters.rb +14 -0
  65. data/config/locales/devise.en.yml +58 -0
  66. data/config/locales/en.yml +5 -0
  67. data/config/locales/simple_form.en.yml +24 -0
  68. data/config/routes.rb +29 -0
  69. data/db/development.sqlite3 +0 -0
  70. data/db/migrate/20111109081414_devise_create_users.rb +28 -0
  71. data/db/migrate/20111111165640_create_tables.rb +14 -0
  72. data/db/migrate/20111112022333_add_name_to_tables.rb +9 -0
  73. data/db/migrate/20111112170802_add_reports.rb +15 -0
  74. data/db/migrate/20111113000026_add_guid_to_tables.rb +9 -0
  75. data/db/migrate/20111113073326_add_times_to_reports.rb +11 -0
  76. data/db/migrate/20111113075747_add_times_to_tables.rb +9 -0
  77. data/db/migrate/20111114041729_create_delayed_jobs.rb +21 -0
  78. data/db/migrate/20111114053016_add_report_to_delayed_jobs.rb +11 -0
  79. data/db/migrate/20111115014959_add_admin_to_users.rb +9 -0
  80. data/db/migrate/20111127065357_add_column_names_to_table.rb +9 -0
  81. data/db/migrate/20111203020425_add_transform_to_table.rb +16 -0
  82. data/db/migrate/20111214020029_add_formatter_data_to_reports.rb +8 -0
  83. data/db/schema.rb +80 -0
  84. data/db/seeds.rb +7 -0
  85. data/db/test.sqlite3 +0 -0
  86. data/lib/daily.rb +9 -0
  87. data/lib/daily/daily_config.rb +51 -0
  88. data/lib/daily/engine.rb +4 -0
  89. data/lib/daily/has_data.rb +52 -0
  90. data/lib/daily/shared_behaviors.rb +65 -0
  91. data/lib/daily/version.rb +3 -0
  92. data/lib/tasks/user.rake +24 -0
  93. metadata +454 -0
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,5 @@
1
+ DailyConfig.database_init
2
+
3
+ Dir[Rails.root.join("app/formatters/*")].each { |f| require f }
4
+ Dir[Rails.root.join("app/transforms/*")].each { |f| require f }
5
+
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Daily::Application.config.secret_token = 'ce963316d81ab3fe75c1e1c30768eafb85d1ebe6d4359d73aad49bfae6acc7f13fec1a1f7a2598e143df034887d06e8be15cc77467347eca47a84b5f3e58a191'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Daily::Application.config.session_store :cookie_store, :key => '_daily_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Daily::Application.config.session_store :active_record_store
@@ -0,0 +1,113 @@
1
+ require "simple_form"
2
+
3
+ # Use this setup block to configure all options available in SimpleForm.
4
+ SimpleForm.setup do |config|
5
+ config.form_class = nil
6
+ config.hint_class = "hint input"
7
+ config.error_class = 'error input'
8
+ config.wrapper_class = :clearfix
9
+ config.wrapper_error_class = :error
10
+
11
+ # Components used by the form builder to generate a complete input. You can remove
12
+ # any of them, change the order, or even add your own components to the stack.
13
+ # config.components = [ :placeholder, :label_input, :hint, :error ]
14
+
15
+ # Default tag used on hints.
16
+ # config.hint_tag = :span
17
+
18
+ # CSS class to add to all hint tags.
19
+ # config.hint_class = :hint
20
+
21
+ # CSS class used on errors.
22
+ # config.error_class = :error
23
+
24
+ # Default tag used on errors.
25
+ # config.error_tag = :span
26
+
27
+ # Method used to tidy up errors.
28
+ # config.error_method = :first
29
+
30
+ # Default tag used for error notification helper.
31
+ # config.error_notification_tag = :p
32
+
33
+ # CSS class to add for error notification helper.
34
+ # config.error_notification_class = :error_notification
35
+
36
+ # ID to add for error notification helper.
37
+ # config.error_notification_id = nil
38
+
39
+ # You can wrap all inputs in a pre-defined tag.
40
+ # config.wrapper_tag = :div
41
+
42
+ # CSS class to add to all wrapper tags.
43
+ # config.wrapper_class = :input
44
+
45
+ # CSS class to add to the wrapper if the field has errors.
46
+ # config.wrapper_error_class = :field_with_errors
47
+
48
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
49
+ # config.collection_wrapper_tag = nil
50
+
51
+ # You can wrap each item in a collection of radio/check boxes with a tag, defaulting to span.
52
+ # config.item_wrapper_tag = :span
53
+
54
+ # Series of attempts to detect a default label method for collection.
55
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
56
+
57
+ # Series of attempts to detect a default value method for collection.
58
+ # config.collection_value_methods = [ :id, :to_s ]
59
+
60
+ # How the label text should be generated altogether with the required text.
61
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
62
+
63
+ # You can define the class to use on all labels. Default is nil.
64
+ # config.label_class = nil
65
+
66
+ # You can define the class to use on all forms. Default is simple_form.
67
+ # config.form_class = :simple_form
68
+
69
+ # Whether attributes are required by default (or not). Default is true.
70
+ # config.required_by_default = true
71
+
72
+ # Tell browsers whether to use default HTML5 validations (novalidate option).
73
+ # Default is enabled.
74
+ # config.browser_validations = true
75
+
76
+ # Determines whether HTML5 types (:email, :url, :search, :tel) and attributes
77
+ # (e.g. required) are used or not. True by default.
78
+ # Having this on in non-HTML5 compliant sites can cause odd behavior in
79
+ # HTML5-aware browsers such as Chrome.
80
+ # config.html5 = true
81
+
82
+ # Custom mappings for input types. This should be a hash containing a regexp
83
+ # to match as key, and the input type that will be used when the field name
84
+ # matches the regexp as value.
85
+ # config.input_mappings = { /count/ => :integer }
86
+
87
+ # Collection of methods to detect if a file type was given.
88
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
89
+
90
+ # Default priority for time_zone inputs.
91
+ # config.time_zone_priority = nil
92
+
93
+ # Default priority for country inputs.
94
+ # config.country_priority = nil
95
+
96
+ # Default size for text inputs.
97
+ # config.default_input_size = 50
98
+
99
+ # When false, do not use translations for labels, hints or placeholders.
100
+ # config.translate = true
101
+ end
102
+
103
+ SimpleForm::Inputs.constants.each do |klazz|
104
+ next if klazz == :Base
105
+ "SimpleForm::Inputs::#{klazz.to_s}".constantize.class_eval do
106
+ def input_with_surrounding_div
107
+ @builder.template.content_tag :div, input_without_surrounding_div, :class => "input"
108
+ end
109
+ alias_method_chain :input, :surrounding_div
110
+ end
111
+ end
112
+
113
+
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters :format => [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,58 @@
1
+ # Additional translations at http://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ en:
4
+ errors:
5
+ messages:
6
+ expired: "has expired, please request a new one"
7
+ not_found: "not found"
8
+ already_confirmed: "was already confirmed, please try signing in"
9
+ not_locked: "was not locked"
10
+ not_saved:
11
+ one: "1 error prohibited this %{resource} from being saved:"
12
+ other: "%{count} errors prohibited this %{resource} from being saved:"
13
+
14
+ devise:
15
+ failure:
16
+ already_authenticated: 'You are already signed in.'
17
+ unauthenticated: 'You need to sign in or sign up before continuing.'
18
+ unconfirmed: 'You have to confirm your account before continuing.'
19
+ locked: 'Your account is locked.'
20
+ invalid: 'Invalid email or password.'
21
+ invalid_token: 'Invalid authentication token.'
22
+ timeout: 'Your session expired, please sign in again to continue.'
23
+ inactive: 'Your account was not activated yet.'
24
+ sessions:
25
+ signed_in: 'Signed in successfully.'
26
+ signed_out: 'Signed out successfully.'
27
+ passwords:
28
+ send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
29
+ updated: 'Your password was changed successfully. You are now signed in.'
30
+ updated_not_active: 'Your password was changed successfully.'
31
+ send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
32
+ confirmations:
33
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
34
+ send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
35
+ confirmed: 'Your account was successfully confirmed. You are now signed in.'
36
+ registrations:
37
+ signed_up: 'Welcome! You have signed up successfully.'
38
+ inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
39
+ updated: 'You updated your account successfully.'
40
+ destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
41
+ reasons:
42
+ inactive: 'inactive'
43
+ unconfirmed: 'unconfirmed'
44
+ locked: 'locked'
45
+ unlocks:
46
+ send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
47
+ unlocked: 'Your account was successfully unlocked. You are now signed in.'
48
+ send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
49
+ omniauth_callbacks:
50
+ success: 'Successfully authorized from %{kind} account.'
51
+ failure: 'Could not authorize you from %{kind} because "%{reason}".'
52
+ mailer:
53
+ confirmation_instructions:
54
+ subject: 'Confirmation instructions'
55
+ reset_password_instructions:
56
+ subject: 'Reset password instructions'
57
+ unlock_instructions:
58
+ subject: 'Unlock Instructions'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,24 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Some errors were found, please take a look:"
13
+ # Labels and hints examples
14
+ # labels:
15
+ # password: 'Password'
16
+ # user:
17
+ # new:
18
+ # email: 'E-mail para efetuar o sign in.'
19
+ # edit:
20
+ # email: 'E-mail.'
21
+ # hints:
22
+ # username: 'User name to sign in.'
23
+ # password: 'No special characters, please.'
24
+
@@ -0,0 +1,29 @@
1
+ Rails.application.routes.draw do
2
+
3
+ scope "/#{DailyConfig.subdirectory}" do
4
+
5
+ devise_for :users, :only => :sessions do
6
+ get "login", :to => "devise/sessions#new"
7
+ get "logout", :to => "devise/sessions#destroy"
8
+ root :to => "devise/sessions#new"
9
+ end
10
+
11
+ match 'home' => 'main#home', :as => :user_root
12
+
13
+ resources :tables do
14
+ resources :reports do
15
+ member do
16
+ post :generate
17
+ end
18
+ end
19
+ end
20
+
21
+ resources :reports, :only => :index
22
+
23
+ resources :users
24
+ get "account", :to => "users#edit"
25
+
26
+ get "files/*path", :to => "files#show", :format => false
27
+ end
28
+
29
+ end
Binary file
@@ -0,0 +1,28 @@
1
+ class DeviseCreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table(:users) do |t|
4
+ t.database_authenticatable :null => false
5
+ t.recoverable
6
+ t.rememberable
7
+ t.trackable
8
+
9
+ # t.encryptable
10
+ # t.confirmable
11
+ # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
12
+ # t.token_authenticatable
13
+
14
+
15
+ t.timestamps
16
+ end
17
+
18
+ add_index :users, :email, :unique => true
19
+ add_index :users, :reset_password_token, :unique => true
20
+ # add_index :users, :confirmation_token, :unique => true
21
+ # add_index :users, :unlock_token, :unique => true
22
+ # add_index :users, :authentication_token, :unique => true
23
+ end
24
+
25
+ def self.down
26
+ drop_table :users
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ class CreateTables < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :tables, :force => true do |t|
4
+ t.integer :user_id
5
+ t.text :data
6
+ t.string :data_type
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :tables
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class AddNameToTables < ActiveRecord::Migration
2
+ def up
3
+ add_column :tables, :name, :string
4
+ end
5
+
6
+ def down
7
+ remove_column :tables, :name
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ class AddReports < ActiveRecord::Migration
2
+ def up
3
+ create_table :reports, :force => true do |t|
4
+ t.string :name
5
+ t.string :filename
6
+ t.integer :table_id
7
+ t.integer :user_id
8
+ t.string :formatter
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def down
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ class AddGuidToTables < ActiveRecord::Migration
2
+ def up
3
+ add_column :tables, :guid, :string
4
+ end
5
+
6
+ def down
7
+ remove_column :tables, :guid
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class AddTimesToReports < ActiveRecord::Migration
2
+ def up
3
+ add_column :reports, :generate_started_at, :datetime
4
+ add_column :reports, :generate_ended_at, :datetime
5
+ end
6
+
7
+ def down
8
+ remove_column :reports, :generate_started_at
9
+ remove_column :reports, :generate_ended_at
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class AddTimesToTables < ActiveRecord::Migration
2
+ def up
3
+ add_column :tables, :fetch_time_in_seconds, :integer
4
+ end
5
+
6
+ def down
7
+ remove_column :tables, :fetch_time_in_seconds
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ class CreateDelayedJobs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :delayed_jobs, :force => true do |table|
4
+ table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
5
+ table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
6
+ table.text :handler # YAML-encoded string of the object that will do work
7
+ table.text :last_error # reason for last failure (See Note below)
8
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
9
+ table.datetime :locked_at # Set when a client is working on this object
10
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
11
+ table.string :locked_by # Who is working on this object (if locked)
12
+ table.timestamps
13
+ end
14
+
15
+ add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
16
+ end
17
+
18
+ def self.down
19
+ drop_table :delayed_jobs
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ class AddReportToDelayedJobs < ActiveRecord::Migration
2
+ def up
3
+ add_column :delayed_jobs, :report_id, :integer
4
+ add_index :delayed_jobs, :report_id
5
+ end
6
+
7
+ def down
8
+ remove_index :delayed_jobs, :report_id
9
+ remove_column :delayed_jobs, :report_id
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class AddAdminToUsers < ActiveRecord::Migration
2
+ def up
3
+ add_column :users, :admin, :boolean
4
+ end
5
+
6
+ def down
7
+ remove_column :users, :admin
8
+ end
9
+ end