spree_forem 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ tmp
8
+ nbproject
9
+ *.swp
10
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'ffaker'
5
+ end
6
+
7
+ if RUBY_VERSION < "1.9"
8
+ gem "ruby-debug"
9
+ else
10
+ gem "ruby-debug19"
11
+ end
12
+
13
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2012 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ SpreeForem
2
+ ==========
3
+ This extension for spree commerce aims to provide easy integration with the popular rails forum engine, Forem.
4
+
5
+ Initially, this means simply adding the fields to the Admin Spree::User form that are added to the User model during the Forem installation process "forem_state" and "forem_admin".
6
+
7
+ Setup:
8
+ ======
9
+
10
+ You MUST have a running spree store AND Forem installed in your spree project for this gem to work or be useful.
11
+
12
+ NOTE: when setting up Forem using rails g forem:install, you will be asked the name of your User class, make sure you enter:
13
+ Spree::User
14
+
15
+ You can accept the rest of the default settings.
16
+
17
+ Once Spree and Forem are installed, add the following to your Gemfile:
18
+
19
+ gem 'spree_forem', :git => 'git://github.com/johndavid400/spree_forem.git'
20
+
21
+ then run bundle install:
22
+
23
+ bundle install
24
+
25
+ That should be it! Now you can go check the form for Users in the admin panel and you should see 2 additional form fields.
26
+
27
+ rails s
28
+
29
+ Navigate to:
30
+
31
+ localhost:3000/admin/users/
32
+
33
+ Try creating or editing a user and you should see two Forem fields.
34
+
35
+ Copyright (c) 2012 johndavid400, released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/packagetask'
4
+ require 'rubygems/package_task'
5
+ require 'rspec/core/rake_task'
6
+ require 'spree/core/testing_support/common_rake'
7
+
8
+ RSpec::Core::RakeTask.new
9
+
10
+ task :default => [:spec]
11
+
12
+ spec = eval(File.read('spree_forem.gemspec'))
13
+
14
+ Gem::PackageTask.new(spec) do |p|
15
+ p.gem_spec = spec
16
+ end
17
+
18
+ desc "Release to gemcutter"
19
+ task :release => :package do
20
+ require 'rake/gemcutter'
21
+ Rake::Gemcutter::Tasks.new(spec).define
22
+ Rake::Task['gem:push'].invoke
23
+ end
24
+
25
+ desc "Generates a dummy app for testing"
26
+ task :test_app do
27
+ ENV['LIB_NAME'] = 'spree_forem'
28
+ Rake::Task['common:test_app'].invoke
29
+ end
data/Versionfile ADDED
@@ -0,0 +1,9 @@
1
+ # This file is used to designate compatibilty with different versions of Spree
2
+ # Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
3
+
4
+ # Examples
5
+ #
6
+ # "0.70.x" => { :branch => "master"}
7
+ # "0.60.x" => { :branch => "0-60-stable" }
8
+ # "0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }
9
+
@@ -0,0 +1 @@
1
+ //= require admin/spree_core
@@ -0,0 +1 @@
1
+ //= require store/spree_core
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_core
3
+ */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require store/spree_core
3
+ */
@@ -0,0 +1,17 @@
1
+ Spree::Admin::UsersController.class_eval do
2
+ after_filter :create_forem_admin, :only => [:create]
3
+ after_filter :update_forem_admin, :only => [:update]
4
+
5
+ def create_forem_admin
6
+ # could probably use @user = Spree::User.last
7
+ @user = Spree::User.all.select{|u| u.email == params[:user][:email]}.last
8
+ @user.forem_admin = params[:user][:forem_admin]
9
+ @user.save
10
+ end
11
+
12
+ def update_forem_admin
13
+ @user = Spree::User.find(params[:id])
14
+ @user.forem_admin = params[:user][:forem_admin]
15
+ @user.save
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ Spree::User.class_eval do
2
+ attr_accessible :forem_state
3
+ attr_protected :forem_admin
4
+ end
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(:virtual_path => "spree/admin/users/_form",
2
+ :name => "admin_forem_users_form",
3
+ :insert_bottom => "[data-hook='admin_user_form_fields']",
4
+ :partial => "shared/user_forem")
5
+
@@ -0,0 +1,13 @@
1
+ <%= f.field_container :forem_state do %>
2
+ <%= f.label :forem_state, t(:forem_state) %><br />
3
+ <%= f.select :forem_state, options_for_select([["Approved", "approved"], ["Pending", "pending_review"]], @user.forem_state) %>
4
+ <%= f.error_message_on :forem_state %>
5
+ <% end %>
6
+
7
+ <%= f.field_container :forem_admin do %>
8
+ <%= f.label :forem_admin, t(:forem_admin) %><br />
9
+ <%= f.check_box :forem_admin %>
10
+ <%= f.error_message_on :forem_admin %>
11
+ <% end %>
12
+
13
+
@@ -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"
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,29 @@
1
+ module SpreeForem
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ def add_javascripts
6
+ append_file "app/assets/javascripts/store/all.js", "//= require store/spree_forem\n"
7
+ append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_forem\n"
8
+ end
9
+
10
+ def add_stylesheets
11
+ inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_forem\n", :before => /\*\//, :verbose => true
12
+ inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_forem\n", :before => /\*\//, :verbose => true
13
+ end
14
+
15
+ def add_migrations
16
+ run 'bundle exec rake railties:install:migrations FROM=spree_forem'
17
+ end
18
+
19
+ def run_migrations
20
+ res = ask "Would you like to run the migrations now? [Y/n]"
21
+ if res == "" || res.downcase == "y"
22
+ run 'bundle exec rake db:migrate'
23
+ else
24
+ puts "Skiping rake db:migrate, don't forget to run it!"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ module SpreeForem
2
+ class Engine < Rails::Engine
3
+ engine_name 'spree_forem'
4
+
5
+ config.autoload_paths += %W(#{config.root}/lib)
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare &method(:activate).to_proc
19
+ end
20
+ end
@@ -0,0 +1,2 @@
1
+ require 'spree_core'
2
+ require 'spree_forem/engine'
data/script/rails ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
5
+ load File.expand_path('../../spec/dummy/script/rails', __FILE__)
@@ -0,0 +1,32 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+
6
+ require 'rspec/rails'
7
+
8
+ # Requires supporting ruby files with custom matchers and macros, etc,
9
+ # in spec/support/ and its subdirectories.
10
+ Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
11
+
12
+ # Requires factories defined in spree_core
13
+ require 'spree/core/testing_support/factories'
14
+
15
+ RSpec.configure do |config|
16
+ # == Mock Framework
17
+ #
18
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
19
+ #
20
+ # config.mock_with :mocha
21
+ # config.mock_with :flexmock
22
+ # config.mock_with :rr
23
+ config.mock_with :rspec
24
+
25
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
26
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
27
+
28
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
29
+ # examples within a transaction, remove the following line or assign false
30
+ # instead of true.
31
+ config.use_transactional_fixtures = true
32
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: UTF-8
2
+ Gem::Specification.new do |s|
3
+ s.platform = Gem::Platform::RUBY
4
+ s.name = 'spree_forem'
5
+ s.version = '1.0.0'
6
+ s.summary = 'This is a gem used to integrate Forem with Spree'
7
+ s.description = 'Once installed, the gem will add forem related fields to the Spree::User admin form so you can manage Forem users from the Spree Admin panel (Users)'
8
+ s.required_ruby_version = '>= 1.9.2'
9
+
10
+ s.author = 'JD Warren'
11
+ s.email = 'jd@isotope11.com'
12
+ s.homepage = 'http://www.github.com/johndavid400/spree_forem'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.require_path = 'lib'
17
+ s.requirements << 'none'
18
+
19
+ s.add_dependency 'spree_core', '~> 1.0.0'
20
+
21
+ s.add_development_dependency 'capybara', '1.0.1'
22
+ s.add_development_dependency 'factory_girl'
23
+ s.add_development_dependency 'ffaker'
24
+ s.add_development_dependency 'rspec-rails', '~> 2.7'
25
+ s.add_development_dependency 'sqlite3'
26
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_forem
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - JD Warren
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-03-30 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: spree_core
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: capybara
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - "="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.1
35
+ type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: factory_girl
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: ffaker
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: rspec-rails
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: "2.7"
68
+ type: :development
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: sqlite3
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :development
80
+ version_requirements: *id006
81
+ description: Once installed, the gem will add forem related fields to the Spree::User admin form so you can manage Forem users from the Spree Admin panel (Users)
82
+ email: jd@isotope11.com
83
+ executables: []
84
+
85
+ extensions: []
86
+
87
+ extra_rdoc_files: []
88
+
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - Gemfile
93
+ - LICENSE
94
+ - README.md
95
+ - Rakefile
96
+ - Versionfile
97
+ - app/assets/javascripts/admin/spree_forem.js
98
+ - app/assets/javascripts/store/spree_forem.js
99
+ - app/assets/stylesheets/admin/spree_forem.css
100
+ - app/assets/stylesheets/store/spree_forem.css
101
+ - app/controllers/spree/admin/users_controller_decorator.rb
102
+ - app/models/user_decorator.rb
103
+ - app/overrides/user_fields.rb
104
+ - app/views/shared/_user_forem.html.erb
105
+ - config/locales/en.yml
106
+ - config/routes.rb
107
+ - lib/generators/spree_forem/install/install_generator.rb
108
+ - lib/spree_forem.rb
109
+ - lib/spree_forem/engine.rb
110
+ - script/rails
111
+ - spec/spec_helper.rb
112
+ - spree_forem.gemspec
113
+ homepage: http://www.github.com/johndavid400/spree_forem
114
+ licenses: []
115
+
116
+ post_install_message:
117
+ rdoc_options: []
118
+
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: 1.9.2
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: "0"
133
+ requirements:
134
+ - none
135
+ rubyforge_project:
136
+ rubygems_version: 1.8.21
137
+ signing_key:
138
+ specification_version: 3
139
+ summary: This is a gem used to integrate Forem with Spree
140
+ test_files: []
141
+