heartwood 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +28 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +4 -0
  8. data/Rakefile +20 -0
  9. data/app/controllers/cambium/base_controller.rb +3 -0
  10. data/app/models/concerns/idx.rb +28 -0
  11. data/app/models/concerns/image_cropper.rb +24 -0
  12. data/app/models/concerns/publishable.rb +57 -0
  13. data/app/models/concerns/slug.rb +56 -0
  14. data/app/models/concerns/tags.rb +33 -0
  15. data/bin/rails +12 -0
  16. data/config/routes.rb +2 -0
  17. data/heartwood.gemspec +43 -0
  18. data/lib/generators/cambium/app_generator.rb +205 -0
  19. data/lib/generators/cambium/controller_generator.rb +81 -0
  20. data/lib/generators/cambium/gemfile_generator.rb +36 -0
  21. data/lib/generators/cambium/install_generator.rb +19 -0
  22. data/lib/generators/cambium/user_generator.rb +40 -0
  23. data/lib/generators/helpers/_autoloader.rb +12 -0
  24. data/lib/generators/helpers/generators_helper.rb +235 -0
  25. data/lib/generators/templates/Gemfile.erb +78 -0
  26. data/lib/generators/templates/app/assets/javascripts/application.js.coffee +24 -0
  27. data/lib/generators/templates/app/assets/javascripts/routers/router.js.coffee +23 -0
  28. data/lib/generators/templates/app/assets/javascripts/templates/.keep +0 -0
  29. data/lib/generators/templates/app/assets/javascripts/views/default_helpers.js.coffee +16 -0
  30. data/lib/generators/templates/app/assets/stylesheets/admin/admin.scss +3 -0
  31. data/lib/generators/templates/app/assets/stylesheets/application.scss +9 -0
  32. data/lib/generators/templates/app/controllers/admin/controller.rb.erb +2 -0
  33. data/lib/generators/templates/app/controllers/application_controller.rb +11 -0
  34. data/lib/generators/templates/app/models/user.rb +14 -0
  35. data/lib/generators/templates/app/views/application/_status.html.erb +3 -0
  36. data/lib/generators/templates/app/views/home/index.html.erb +7 -0
  37. data/lib/generators/templates/app/views/layouts/application.html.erb +24 -0
  38. data/lib/generators/templates/config/application.rb +17 -0
  39. data/lib/generators/templates/config/initializers/_hash.rb +23 -0
  40. data/lib/generators/templates/config/initializers/_settings.rb +18 -0
  41. data/lib/generators/templates/config/initializers/assets.rb +3 -0
  42. data/lib/generators/templates/config/initializers/heartwood.rb +25 -0
  43. data/lib/generators/templates/config/private.yml +16 -0
  44. data/lib/generators/templates/config/routes.rb +54 -0
  45. data/lib/generators/templates/config/settings.yml +16 -0
  46. data/lib/generators/templates/db/seeds.rb +25 -0
  47. data/lib/generators/templates/gitignore +30 -0
  48. data/lib/heartwood/configuration.rb +29 -0
  49. data/lib/heartwood/engine.rb +28 -0
  50. data/lib/heartwood/support/array.rb +9 -0
  51. data/lib/heartwood/support/false_class.rb +9 -0
  52. data/lib/heartwood/support/fixnum.rb +13 -0
  53. data/lib/heartwood/support/float.rb +5 -0
  54. data/lib/heartwood/support/hash.rb +22 -0
  55. data/lib/heartwood/support/nil_class.rb +19 -0
  56. data/lib/heartwood/support/string.rb +28 -0
  57. data/lib/heartwood/support/true_class.rb +9 -0
  58. data/lib/heartwood/version.rb +3 -0
  59. data/lib/heartwood.rb +11 -0
  60. data/lib/help/heartwood_prereqs.txt +13 -0
  61. data/lib/help/pg_search_post_install.txt +13 -0
  62. data/lib/tasks/db.rake +22 -0
  63. data/lib/tasks/rename.rake +28 -0
  64. data/spec/dummy/README.rdoc +28 -0
  65. data/spec/dummy/Rakefile +6 -0
  66. data/spec/dummy/app/assets/images/.keep +0 -0
  67. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  68. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  69. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  70. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  71. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  72. data/spec/dummy/app/mailers/.keep +0 -0
  73. data/spec/dummy/app/models/.keep +0 -0
  74. data/spec/dummy/app/models/concerns/.keep +0 -0
  75. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  76. data/spec/dummy/bin/bundle +3 -0
  77. data/spec/dummy/bin/rails +4 -0
  78. data/spec/dummy/bin/rake +4 -0
  79. data/spec/dummy/bin/setup +29 -0
  80. data/spec/dummy/config/application.rb +32 -0
  81. data/spec/dummy/config/boot.rb +5 -0
  82. data/spec/dummy/config/database.yml +25 -0
  83. data/spec/dummy/config/environment.rb +5 -0
  84. data/spec/dummy/config/environments/development.rb +41 -0
  85. data/spec/dummy/config/environments/production.rb +79 -0
  86. data/spec/dummy/config/environments/test.rb +42 -0
  87. data/spec/dummy/config/initializers/assets.rb +11 -0
  88. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  89. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  90. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  91. data/spec/dummy/config/initializers/inflections.rb +16 -0
  92. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  93. data/spec/dummy/config/initializers/session_store.rb +3 -0
  94. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  95. data/spec/dummy/config/locales/en.yml +23 -0
  96. data/spec/dummy/config/routes.rb +4 -0
  97. data/spec/dummy/config/secrets.yml +22 -0
  98. data/spec/dummy/config.ru +4 -0
  99. data/spec/dummy/db/development.sqlite3 +0 -0
  100. data/spec/dummy/db/heartwood_development.sqlite3 +0 -0
  101. data/spec/dummy/db/heartwood_test.sqlite3 +0 -0
  102. data/spec/dummy/db/schema.rb +15 -0
  103. data/spec/dummy/db/test.sqlite3 +0 -0
  104. data/spec/dummy/lib/assets/.keep +0 -0
  105. data/spec/dummy/log/.keep +0 -0
  106. data/spec/dummy/log/development.log +78 -0
  107. data/spec/dummy/log/test.log +3050 -0
  108. data/spec/dummy/public/404.html +67 -0
  109. data/spec/dummy/public/422.html +67 -0
  110. data/spec/dummy/public/500.html +66 -0
  111. data/spec/dummy/public/favicon.ico +0 -0
  112. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1i/1ii3yPGPbB0S_BkYiwVDC7qlKvhKF5P0zr7QiaTpgV4.cache +0 -0
  113. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
  114. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7k/7kqdQ5LCh-fs6HP4CUqWvk9w7HRuj6ZT_zkC-hUUMHU.cache +0 -0
  115. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8M/8Mpbgok-UsQPhrJQKqd6hVtQogD8YuU6GMn-2KVhC3E.cache +1 -0
  116. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Au/AuOTcA4Uen3sMQjy8Mi6nooP_8gMgvlFsjqr8mHpMIs.cache +0 -0
  117. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/FG/FGeBOdRSmza-XfWb8ERFQydMrExKmdlz2_eksYO3y4Q.cache +1 -0
  118. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/MB/MBqa7cQSBGYszhtbC7r7yiDA0gjwriFrAaNiQnMbfFw.cache +1 -0
  119. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ML/MLT6NKtdybeBwpm6H1d7XzkomTyZnMge5E8EEQkhtrc.cache +1 -0
  120. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
  121. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/R2/R2IjUuzOFtsZdvjOQOrasVwjaCegvj-lE6jkTQFL9xs.cache +1 -0
  122. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/WB/WB2XiMJ4O7--cvm29FJ4zeUyMpU15sqdYtfduF0YeT0.cache +1 -0
  123. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YT/YTDOaZ9qOx03chcaLrJy-Ch0Rtn4Nik102vwxZ2a-k8.cache +1 -0
  124. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aB/aBAdNO31MRRIPsReAdfHmtSFswygiBIFctx6fBhTTdc.cache +0 -0
  125. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fK/fKCgrNQR1G7Gf6VTItx7NTaKXquuw-ufNT5nGlxvBV4.cache +0 -0
  126. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -0
  127. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hr/hrKDaC8EYPX0veGxFTXgYt7IynAdYyeBjYjzcPazQkk.cache +1 -0
  128. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/i4/i4-E3GFC6rOjx1w5H9W14IbdPm4ouzkqixHmsK27kmo.cache +0 -0
  129. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jE/jEmEy4r1QfD5kzXcHSPcAaAgBwet1M0ZIWQuzyT9TXw.cache +0 -0
  130. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/l7/l7FREFh3W4tfuo0mF7DdkXKth9VT4R2hiiiq0KS4xpI.cache +1 -0
  131. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/o8/o8getMbwHiM68k4uUk4shsyjKnDbV_hmifAWyvO-E50.cache +1 -0
  132. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -0
  133. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wA/wAjBFweHcRdsYa4zx9mayhvC0RDVqaI5gM0LcoCv7a4.cache +1 -0
  134. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xW/xWmlGxKNxc1ViyjTyokcbCu6WjNIGDIqPVPXsBwdveA.cache +1 -0
  135. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zP/zPn9M5I_yf8ko0-lpbDwTWjG6wpRvXkA77hDUPzAFZ8.cache +0 -0
  136. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zd/zd90ZPTG89ScoQQ_PzPAAe2669wzpdyZuzn7qmr9e3s.cache +0 -0
  137. data/spec/lib/support/array_spec.rb +14 -0
  138. data/spec/lib/support/false_class_spec.rb +17 -0
  139. data/spec/lib/support/fixnum_spec.rb +23 -0
  140. data/spec/lib/support/float_spec.rb +18 -0
  141. data/spec/lib/support/hash_spec.rb +21 -0
  142. data/spec/lib/support/nil_class_spec.rb +23 -0
  143. data/spec/lib/support/string_spec.rb +44 -0
  144. data/spec/lib/support/true_class_spec.rb +17 -0
  145. data/spec/rails_helper.rb +183 -0
  146. data/spec/spec_helper.rb +99 -0
  147. data/vendor/assets/javascripts/backbone.js +1920 -0
  148. data/vendor/assets/javascripts/modernizr.js +4 -0
  149. data/vendor/assets/javascripts/underscore.js +1548 -0
  150. data/vendor/assets/stylesheets/normalize.scss +406 -0
  151. metadata +425 -0
@@ -0,0 +1,54 @@
1
+ Rails.application.routes.draw do
2
+
3
+ # --- Heartwood's Routes ---
4
+ #
5
+ # The following are Heartwood's default routes. Feel free to
6
+ # customize (or delete) these to fit your needs.
7
+ #
8
+ # ------------------------------------------ Users (Devise)
9
+ #
10
+ # Learn more about Devise at https://github.com/plataformatec/devise
11
+ #
12
+ devise_for :users, :skip => [:sessions, :registrations]
13
+ devise_scope :user do
14
+ get '/login' => 'devise/sessions#new', :as => :new_user_session
15
+ post '/login' => 'devise/sessions#create', :as => :user_session
16
+ get '/logout' => 'devise/sessions#destroy', :as => :destroy_user_session
17
+ end
18
+ #
19
+ # ------------------------------------------ Admin
20
+ #
21
+ # Heartwood already namespaces all its own routes, so it's
22
+ # best to just mount it at the root. This is the base
23
+ # setup if you are using Heartwood's CMS
24
+ #
25
+ mount Heartwood::Engine => '/'
26
+ #
27
+ # ------------------------------------------ JSON
28
+ #
29
+ # If you plan to use any public json routes, it's good to
30
+ # nest them in their own scope. We use a scope instead of
31
+ # a namespace because a controller action can have routes
32
+ # to it in different formats, so namespacing is
33
+ # unecessary.
34
+ #
35
+ # scope 'json' do
36
+ # 'users' => 'users#index'
37
+ # end
38
+ #
39
+ # ------------------------------------------ Public
40
+ #
41
+ # After we define all namespaced routes, we can move on to
42
+ # those routes that are not namespaced.
43
+ #
44
+ # resources :users
45
+ #
46
+ # ------------------------------------------ Home Page
47
+ #
48
+ # This is your application's home page. Feel free to
49
+ # delete the home controller and change this if you want a
50
+ # different home page.
51
+ #
52
+ root :to => 'home#index'
53
+
54
+ end
@@ -0,0 +1,16 @@
1
+ #
2
+ # This file is for storing NON-SENSITIVE settings.
3
+ #
4
+ # Values here are accessible through a recursive `Settings`
5
+ # OpenStruct. For example, you can access "ABC123" using the
6
+ # example below through Setting.say.hello
7
+ #
8
+ development: &default
9
+ say:
10
+ hello: "Hello"
11
+
12
+ test:
13
+ <<: *default
14
+
15
+ production:
16
+ <<: *default
@@ -0,0 +1,25 @@
1
+ require 'csv'
2
+ Dir.glob("#{Rails.root}/app/models/*.rb").each { |file| require file }
3
+
4
+ ActiveRecord::Base.descendants.each do |model|
5
+ filename = "#{Rails.root}/db/csv/#{model.to_s.tableize}.csv"
6
+ if File.exist?(filename)
7
+ CSV.foreach(filename, :headers => true) do |row|
8
+ attrs = {}
9
+ row.to_hash.each do |k,v|
10
+ if k =~ /.*\:file/
11
+ unless v.blank?
12
+ attrs[k.split(':')[0]] = File.open("#{Rails.root}/lib/assets/seeds/#{v}")
13
+ end
14
+ else
15
+ attrs[k] = v
16
+ end
17
+ end
18
+ item = model.create!(attrs.to_hash.symbolize_keys)
19
+ puts "CREATED #{model.to_s.upcase} >> #{model.to_s} ##{item.id}"
20
+ end
21
+ if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
22
+ ActiveRecord::Base.connection.reset_pk_sequence!(model.to_s.tableize)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*.log
16
+ /tmp
17
+ sass-cache
18
+ esproj
19
+
20
+ # Sensitive Data
21
+ config/database.yml
22
+ config/private.yml
23
+
24
+ # Public Uploads
25
+ public/uploads/
26
+ public/files/
27
+ public/media/
28
+
29
+ # Stupid Files
30
+ *.DS_Store
@@ -0,0 +1,29 @@
1
+ module Heartwood
2
+ class Configuration
3
+
4
+ attr_accessor :app_title,
5
+ :cache_pages,
6
+ :development_url,
7
+ :production_url
8
+
9
+ def initialize
10
+ @app_title = 'Heartwood'
11
+ @cache_pages = false
12
+ @development_url = 'localhost:3000'
13
+ @production_url = 'example.com'
14
+ end
15
+
16
+ end
17
+
18
+ def self.configuration
19
+ @configuration ||= Configuration.new
20
+ end
21
+
22
+ def self.configuration=(config)
23
+ @configuration = config
24
+ end
25
+
26
+ def self.configure
27
+ yield configuration
28
+ end
29
+ end
@@ -0,0 +1,28 @@
1
+ require 'rails'
2
+
3
+ module Heartwood
4
+ class Engine < ::Rails::Engine
5
+
6
+ isolate_namespace Heartwood
7
+
8
+ config.generators do |g|
9
+ g.test_framework :rspec, :fixture => false
10
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
11
+ g.assets false
12
+ g.helper false
13
+ end
14
+
15
+ initializer :append_migrations do |app|
16
+ unless app.root.to_s.match root.to_s
17
+ config.paths["db/migrate"].expanded.each do |expanded_path|
18
+ app.config.paths["db/migrate"] << expanded_path
19
+ end
20
+ end
21
+ end
22
+
23
+ def root
24
+ @root ||= Gem::Specification.find_by_name('heartwood').gem_dir.to_s
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ class Array
2
+ def average(attr = nil)
3
+ return nil if size == 0
4
+ unless attr.nil?
5
+ return collect(&:"#{attr}").reject(&:nil?).sum.to_f / size.to_f
6
+ end
7
+ sum.to_f / size.to_f
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class FalseClass
2
+ def to_i
3
+ 0
4
+ end
5
+
6
+ def to_bool
7
+ self
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class Fixnum
2
+
3
+ def nearest_half
4
+ to_f.nearest_half
5
+ end
6
+
7
+ def to_bool
8
+ return true if self == 1
9
+ return false if self == 0
10
+ raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
11
+ end
12
+
13
+ end
@@ -0,0 +1,5 @@
1
+ class Float
2
+ def nearest_half
3
+ (self * 2.0).round / 2.0
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ class Hash
2
+
3
+ def to_ostruct
4
+ convert_to_ostruct_recursive(self)
5
+ end
6
+
7
+ private
8
+
9
+ def convert_to_ostruct_recursive(result)
10
+ if result.is_a? Hash
11
+ result = result.dup.symbolize_keys
12
+ result.each do |key, val|
13
+ result[key] = convert_to_ostruct_recursive(val)
14
+ end
15
+ result = OpenStruct.new(result)
16
+ elsif result.is_a? Array
17
+ result = result.map { |r| convert_to_ostruct_recursive(r) }
18
+ end
19
+ result
20
+ end
21
+
22
+ end
@@ -0,0 +1,19 @@
1
+ class NilClass
2
+
3
+ def +(n)
4
+ convert_to_match(n) + n
5
+ end
6
+
7
+ def to_bool
8
+ false
9
+ end
10
+
11
+ private
12
+
13
+ def convert_to_match(obj)
14
+ return to_s if obj.is_a?(String)
15
+ return to_i if obj.is_a?(Integer)
16
+ to_f
17
+ end
18
+
19
+ end
@@ -0,0 +1,28 @@
1
+ class String
2
+ def to_bool
3
+ return true if self == true || self =~ (/^(true|t|yes|y|1)$/i)
4
+ return false if self == false || self.blank? || self =~ (/^(false|f|no|n|0)$/i)
5
+ raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
6
+ end
7
+
8
+ def possessive
9
+ self + ('s' == self[-1, 1] ? "'" : "'s")
10
+ end
11
+
12
+ def paragraphs
13
+ pattern = /\n/
14
+ split(pattern).map(&:strip).reject(&:blank?)
15
+ end
16
+
17
+ def sentences
18
+ pattern = /[\.\?\!]/
19
+ punctuation = scan(pattern)
20
+ sentences = split(pattern).map(&:strip).reject(&:blank?)
21
+ return sentences if punctuation.blank?
22
+ sentences.each_with_index do |txt, idx|
23
+ next if punctuation[idx].blank?
24
+ sentences[idx] += punctuation[idx]
25
+ end
26
+ sentences
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ class TrueClass
2
+ def to_i
3
+ 1
4
+ end
5
+
6
+ def to_bool
7
+ self
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Heartwood
2
+ VERSION = "0.0.1"
3
+ end
data/lib/heartwood.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'heartwood/version'
2
+ require 'heartwood/configuration'
3
+
4
+ support_files = "#{File.expand_path('../heartwood/support', __FILE__)}/*.rb"
5
+ Dir.glob(support_files).each do |file|
6
+ require "heartwood/support/#{File.basename(file)}"
7
+ end
8
+
9
+ module Heartwood
10
+ require 'heartwood/engine' if defined?(Rails)
11
+ end
@@ -0,0 +1,13 @@
1
+
2
+ ==================== WARNING! ====================
3
+
4
+ No config file found. Please run:
5
+
6
+ rails g heartwood:install
7
+
8
+ Before running this generator. If you wish to
9
+ skip this config check, you can run:
10
+
11
+ rails g heartwood:install --no-config-check
12
+
13
+ ==================================================
@@ -0,0 +1,13 @@
1
+
2
+ ==================== PG SEARCH ====================
3
+
4
+ Add the following to each model that you would like
5
+ to be searchable:
6
+
7
+ include PgSearch
8
+ multisearchable :against => [:title, :author]
9
+
10
+ where :title and :author are the attributes you
11
+ wish to be searched
12
+
13
+ ==================================================
data/lib/tasks/db.rake ADDED
@@ -0,0 +1,22 @@
1
+ namespace :db do
2
+
3
+ namespace :seed do
4
+
5
+ desc "Create CSV files from models"
6
+ task :create_files => :environment do
7
+ Dir.glob("#{Rails.root}/app/models/*.rb").each { |file| require file }
8
+ dir = "#{Rails.root}/db/csv"
9
+ FileUtils.mkdir(dir) unless File.exists?(dir)
10
+ ActiveRecord::Base.descendants.each do |model|
11
+ unless File.exists?("#{dir}/#{model.to_s.tableize}.csv")
12
+ File.open("#{dir}/#{model.to_s.tableize}.csv", 'w+') do |f|
13
+ f.write(model.columns.collect(&:name).join(','))
14
+ end
15
+ puts "CREATED FILE >> #{model.to_s.tableize}.csv"
16
+ end
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,28 @@
1
+ namespace :rename do
2
+
3
+ desc 'Rename Rails App'
4
+ task :app, [:new_name] do |t, args|
5
+ filenames = [
6
+ 'Rakefile',
7
+ 'app/views/layouts/admin.html.erb',
8
+ 'app/views/layouts/application.html.erb',
9
+ 'app/views/layouts/devise.html.erb',
10
+ 'config/application.rb',
11
+ 'config/environment.rb',
12
+ 'config/routes.rb',
13
+ 'config/environments/development.rb',
14
+ 'config/environments/test.rb',
15
+ 'config/environments/production.rb',
16
+ 'config/initializers/secret_token.rb',
17
+ 'config/initializers/session_store.rb',
18
+ ]
19
+ filenames.each do |filename|
20
+ text = File.read(filename)
21
+ File.open(filename, "w") do |file|
22
+ file << text.gsub(/Roots/, args[:new_name])
23
+ end
24
+ puts "CHECKED FILE >> #{filename}"
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -0,0 +1,32 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_mailer/railtie"
7
+ require "action_view/railtie"
8
+ require "sprockets/railtie"
9
+ # require "rails/test_unit/railtie"
10
+
11
+ Bundler.require(*Rails.groups)
12
+ require "heartwood"
13
+
14
+ module Dummy
15
+ class Application < Rails::Application
16
+ # Settings in config/environments/* take precedence over those specified here.
17
+ # Application configuration should go into files in config/initializers
18
+ # -- all .rb files in that directory are automatically loaded.
19
+
20
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
21
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
22
+ # config.time_zone = 'Central Time (US & Canada)'
23
+
24
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
25
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
26
+ # config.i18n.default_locale = :de
27
+
28
+ # Do not swallow errors in after_commit/after_rollback callbacks.
29
+ config.active_record.raise_in_transactional_callbacks = true
30
+ end
31
+ end
32
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/heartwood_development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/heartwood_test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/heartwood_production.sqlite3
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!