sampler 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2@sampler
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sampler.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Cory Kaufman-Schofield
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Sampler
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ gem 'sampler'
8
+
9
+ And then execute:
10
+
11
+ $ bundle
12
+
13
+ Or install it yourself as:
14
+
15
+ $ gem install sampler
16
+
17
+ To generate a default samples.rb file and an initializer, run:
18
+
19
+ $ rails generate sampler:install
20
+
21
+ This will create db/samples.rb and config/initializers/sampler.rb
22
+
23
+ ## Usage
24
+
25
+ WARNING: The following command will drop your current database and
26
+ run rake db:setup before running rake db:sample. Only run this command
27
+ if you're sure there's nothing in your database you want to keep.
28
+
29
+ $ bundle exec rake db:sample
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
8
+
@@ -0,0 +1,17 @@
1
+ module Sampler
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def copy_initializer_file
8
+ template 'initializer.rb', 'config/initializers/sampler.rb'
9
+ end
10
+
11
+ def create_samples_file
12
+ template 'samples.rb', 'db/samples.rb'
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ Sampler.config do |config|
2
+ config.environments = %w(development)
3
+ end
@@ -0,0 +1,20 @@
1
+ # Sample data goes here!
2
+ #
3
+ # Tip: Don't be afraid to get creative. Pick a theme for your data,
4
+ # such as characters from Harry Potter, The Office, The Matrix, etc.
5
+ #
6
+ # The more real you can make your data, the better you'll be able to test.
7
+ #
8
+ # Here's an example for you:
9
+ #
10
+ # names_array = ['Dwight Shrute','Jim Halpert','Michael Scott','Pam Beasley']
11
+ #
12
+ # users = []
13
+ # names_array.each do |name|
14
+ # users << User.create! do |u|
15
+ # u.name = name
16
+ # u.email = "#{name.parameterize.gsub('-','.')}@dunder-mifflin.com"
17
+ # u.password = "wazaap"
18
+ # end
19
+ # end
20
+ # puts "Generated #{users.count} sample users!"
@@ -0,0 +1,9 @@
1
+ module Sampler
2
+ class Railtie < Rails::Railtie
3
+ railtie_name :sampler
4
+
5
+ rake_tasks do
6
+ load 'tasks/db/sample.rake'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Sampler
2
+ VERSION = "0.0.1"
3
+ end
data/lib/sampler.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'sampler/version'
2
+ require 'sampler/railtie' if defined?(Rails)
3
+
4
+ module Sampler
5
+ def self.environments
6
+ @@environments = %w(development)
7
+ end
8
+
9
+ def self.environments=(environments)
10
+ @@environments = environments
11
+ end
12
+
13
+ def self.config
14
+ yield self
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ namespace :db do
2
+ task :sample => ['db:ensure_environment','environment','db:drop','db:setup'] do
3
+ 'db/samples.rb'.tap do |sample_file|
4
+ load(sample_file) if File.exists?(sample_file)
5
+ end
6
+ end
7
+
8
+ task :ensure_environment do
9
+ if !Sampler.environments.include? Rails.env
10
+ puts "This task can only run in the following environments: #{Sampler.environments.to_sentence}"
11
+ exit
12
+ end
13
+ end
14
+ end
data/sampler.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sampler/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "sampler"
8
+ gem.version = Sampler::VERSION
9
+ gem.authors = ["Cory Kaufman-Schofield"]
10
+ gem.email = ["cory@corykaufman.com"]
11
+ gem.description = %q{Set up your app with sample data using rake db:sample}
12
+ gem.summary = %q{Set up your app with sample data}
13
+ gem.homepage = "http://github.com/allspiritseve/sampler"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency 'rspec'
22
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sampler do
4
+ pending "Write test here..."
5
+ end
@@ -0,0 +1 @@
1
+ require 'sampler'
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sampler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Cory Kaufman-Schofield
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Set up your app with sample data using rake db:sample
47
+ email:
48
+ - cory@corykaufman.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .rvmrc
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/generators/sampler/install_generator.rb
60
+ - lib/generators/sampler/templates/initializer.rb
61
+ - lib/generators/sampler/templates/samples.rb
62
+ - lib/sampler.rb
63
+ - lib/sampler/railtie.rb
64
+ - lib/sampler/version.rb
65
+ - lib/tasks/db/sample.rake
66
+ - sampler.gemspec
67
+ - spec/lib/sampler_spec.rb
68
+ - spec/spec_helper.rb
69
+ homepage: http://github.com/allspiritseve/sampler
70
+ licenses: []
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ segments:
82
+ - 0
83
+ hash: 1293236899247871060
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ segments:
91
+ - 0
92
+ hash: 1293236899247871060
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 1.8.24
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: Set up your app with sample data
99
+ test_files:
100
+ - spec/lib/sampler_spec.rb
101
+ - spec/spec_helper.rb