sinatra_more 0.3.18 → 0.3.21

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.
data/README.rdoc CHANGED
@@ -691,7 +691,7 @@ The available components and their default options are listed below:
691
691
  * renderer: <tt>erb</tt> (default), <tt>haml</tt>
692
692
  * mock: <tt>mocha</tt> (default), <tt>rr</tt>
693
693
  * script: <tt>jquery</tt> (default), <tt>prototype</tt>, <tt>rightjs</tt>
694
- * orm: <tt>datamapper</tt> (default), <tt>mongomapper</tt>, <tt>activerecord</tt>, <tt>sequel</tt>
694
+ * orm: <tt>datamapper</tt> (default), <tt>mongomapper</tt>, <tt>activerecord</tt>, <tt>sequel</tt>, <tt>couchrest</tt>
695
695
 
696
696
  The generator uses the <tt>bundler</tt> gem to resolve any application dependencies when the application is newly created.
697
697
  The necessary bundler command can be executed automatically through the generator with
@@ -730,6 +730,7 @@ See the wiki article for additional information: <http://wiki.github.com/nesquen
730
730
 
731
731
  * Nathan Esquenazi - Project creator and code maintainer
732
732
  * Arthur Chiu - Forming the idea and various code contributions
733
+ * Rob Holland - Added couchrest ORM component to generator
733
734
 
734
735
  == Known Issues
735
736
 
data/ROADMAP CHANGED
@@ -23,10 +23,11 @@ Framework structure:
23
23
 
24
24
  Additional wish-list features (integrate existing plugin) (?)
25
25
 
26
+ * Reloading Support - http://github.com/alexch/rerun
26
27
  * Internationalization - http://r18n.rubyforge.org/#sinatra
27
28
  * Asynchronous Commands - http://github.com/deadprogrammer/spork
28
29
  * Capistrano Deployment - http://github.com/nakajima/capinatra (?)
29
- * Job Queue - http://github.com/adamcooke/resque (or http://github.com/bmizerany/sinatra-dj)
30
+ * Job Queue - http://github.com/adamcooke/resque (or http://github.com/bmizerany/sinatra-dj)
30
31
 
31
32
  'sinatra-cache' Caching concept:
32
33
 
@@ -79,4 +80,9 @@ Additional wish-list features (integrate existing plugin) (?)
79
80
 
80
81
  # and to use
81
82
  link_to "Show Admin", url_for(:admin, :show, :id => 5)
82
- link_to "Accounts", url_for(:accounts)
83
+ link_to "Accounts", url_for(:accounts)
84
+
85
+ 'commands' Concept: (console (?) http://github.com/sickill/racksh)
86
+
87
+ $ sinatra_more console # loads console for sinatra
88
+ $ sinatra_more test # runs all test using specified testing framework
data/TODO CHANGED
@@ -8,6 +8,8 @@
8
8
  * http://github.com/gioext/sinatra-memcache
9
9
  * http://github.com/kematzy/sinatra-cache
10
10
  * http://r18n.rubyforge.org/#sinatra
11
+ * http://github.com/alexch/rerun (reloading)
12
+ * http://github.com/monkrb/glue/blob/master/lib/monk/glue/reloader.rb
11
13
 
12
14
  = UNFINISHED
13
15
 
@@ -17,14 +19,21 @@
17
19
 
18
20
  == MarkupPlugin
19
21
 
22
+ * Add support for mustache classes / views for forms, markup
20
23
  * Add support for form.fields_for (one-to-one, nested and many associations like in rails)
21
24
  * Add support for check_box_group, radio_button_group which create a set of checkboxes or radio buttons
22
25
 
26
+ == RenderPlugin
27
+
28
+ * Add support for mustache template rendering
29
+
23
30
  == WardenPlugin
24
31
 
25
32
  * Become total warden solution (basically just require warden gem installed, do everything) (?)
26
33
  * Look into removing overlapping methods and simply leveraging sinatra_warden
27
34
  * Take advantage of shared strategies: http://github.com/hassox/warden_strategies/tree/master/lib/
35
+
36
+ == RoutingPlugin
28
37
 
29
38
  = COMPLETED
30
39
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.18
1
+ 0.3.21
@@ -23,7 +23,7 @@ class <%= @class_name %> < Sinatra::Application
23
23
  set :views, root_path("app", "views")
24
24
  set :images_path, public_path("images")
25
25
  set :default_builder, 'StandardFormBuilder'
26
- set :environment, RACK_ENV if defined?(RACK_ENV)
26
+ set :environment, RACK_ENV.to_sym if defined?(RACK_ENV)
27
27
 
28
28
  # Attempts to require all dependencies with bundler, if this fails, bundle and then try again
29
29
  def self.bundler_require_dependencies(environment=nil)
@@ -1,5 +1,9 @@
1
1
  # Dependencies contains all required gems, helpers and core configuration
2
2
 
3
+ def app(&block)
4
+ <%= @class_name %>.class_eval(&block)
5
+ end
6
+
3
7
  class <%= @class_name %> < Sinatra::Application
4
8
  bundler_require_dependencies
5
9
 
@@ -0,0 +1,64 @@
1
+ module SinatraMore
2
+ module CouchrestOrmGen
3
+
4
+ COUCHREST = <<-COUCHREST
5
+ module CouchRestInitializer
6
+ def self.registered(app)
7
+ app.configure(:development) { set :couchdb, CouchRest.database!('your_dev_db_here') }
8
+ app.configure(:production) { set :couchdb, CouchRest.database!('your_production_db_here') }
9
+ app.configure(:test) { set :couchdb, CouchRest.database!('your_test_db_here') }
10
+ end
11
+ end
12
+ COUCHREST
13
+
14
+ USER = <<-USER
15
+ class User < CouchRest::ExtendedDocument
16
+ include CouchRest::Validation
17
+
18
+ use_database app { couchdb }
19
+
20
+ property :name
21
+ property :username
22
+ property :email
23
+ property :crypted_password
24
+ unique_id :id
25
+
26
+ attr_accessor :password, :password_confirmation
27
+ validates_is_confirmed :password
28
+
29
+ save_callback :before, :encrypt_password
30
+
31
+ def self.find(id)
32
+ get(id)
33
+ end
34
+
35
+ def self.id_for(username)
36
+ "user/\#{username}"
37
+ end
38
+
39
+ def self.authenticate(username, password)
40
+ user = User.get(id_for(username))
41
+ user && user.has_password?(password) ? user : nil
42
+ end
43
+
44
+ def id
45
+ self.class.id_for(username)
46
+ end
47
+
48
+ def encrypt_password
49
+ self.crypted_password = BCrypt::Password.create(password)
50
+ end
51
+
52
+ def has_password?(password)
53
+ BCrypt::Password.new(crypted_password) == password
54
+ end
55
+ end
56
+ USER
57
+
58
+ def setup_orm
59
+ require_dependencies 'couchrest'
60
+ create_file("config/initializers/couch_rest.rb", COUCHREST)
61
+ create_file("app/models/user.rb", USER)
62
+ end
63
+ end
64
+ end
@@ -59,6 +59,7 @@ module SinatraMore
59
59
  # Also builds the available_choices hash of which component choices are supported
60
60
  # component_option :test, "Testing framework", :aliases => '-t', :choices => [:bacon, :shoulda]
61
61
  def component_option(name, caption, options = {})
62
+ (@component_types ||= []) << name
62
63
  (@available_choices ||= Hash.new({}))[name] = options[:choices]
63
64
  description = "The #{caption} component (#{options[:choices].join(', ')})"
64
65
  class_option name, :default => options[:choices].first, :aliases => options[:aliases], :desc => description
@@ -66,7 +67,7 @@ module SinatraMore
66
67
 
67
68
  # Returns the compiled list of component types which can be specified
68
69
  def component_types
69
- @available_choices.keys
70
+ @component_types
70
71
  end
71
72
 
72
73
  # Returns the list of available choices for the given component (including none)
@@ -20,7 +20,7 @@ module SinatraMore
20
20
  class_option :run_bundler, :aliases => '-b', :default => false, :type => :boolean
21
21
 
22
22
  # Definitions for the available customizable components
23
- component_option :orm, "database engine", :aliases => '-d', :choices => [:datamapper, :mongomapper, :activerecord, :sequel]
23
+ component_option :orm, "database engine", :aliases => '-d', :choices => [:datamapper, :mongomapper, :activerecord, :sequel, :couchrest]
24
24
  component_option :test, "testing framework", :aliases => '-t', :choices => [:bacon, :shoulda, :rspec, :testspec, :riot]
25
25
  component_option :mock, "mocking library", :aliases => '-m', :choices => [:mocha, :rr]
26
26
  component_option :script, "javascript library", :aliases => '-s', :choices => [:jquery, :prototype, :rightjs]
data/sinatra_more.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra_more}
8
- s.version = "0.3.18"
8
+ s.version = "0.3.21"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nathan Esquenazi"]
12
- s.date = %q{2009-11-13}
12
+ s.date = %q{2009-11-16}
13
13
  s.default_executable = %q{sinatra_gen}
14
14
  s.description = %q{Expands sinatra with standard helpers and tools to allow for complex applications}
15
15
  s.email = %q{nesquena@gmail.com}
@@ -55,6 +55,7 @@ Gem::Specification.new do |s|
55
55
  "generators/components/mocks/mocha_mock_gen.rb",
56
56
  "generators/components/mocks/rr_mock_gen.rb",
57
57
  "generators/components/orms/activerecord_orm_gen.rb",
58
+ "generators/components/orms/couchrest_orm_gen.rb",
58
59
  "generators/components/orms/datamapper_orm_gen.rb",
59
60
  "generators/components/orms/mongomapper_orm_gen.rb",
60
61
  "generators/components/orms/sequel_orm_gen.rb",
@@ -103,6 +103,14 @@ class TestSkeletonGenerator < Test::Unit::TestCase
103
103
  assert_match_in_file(/MongoDbInitializer/, '/tmp/sample_app/config/initializers/mongo_db.rb')
104
104
  assert_match_in_file(/class User.*?include MongoMapper::Document/m, '/tmp/sample_app/app/models/user.rb')
105
105
  end
106
+
107
+ should "properly generate for couchrest" do
108
+ buffer = silence_logger { SinatraMore::SkeletonGenerator.start(['sample_app', '/tmp', '--orm=couchrest', '--script=none']) }
109
+ assert_match /Applying.*?couchrest.*?orm/, buffer
110
+ assert_match_in_file(/gem 'couchrest'/, '/tmp/sample_app/Gemfile')
111
+ assert_match_in_file(/CouchRestInitializer/, '/tmp/sample_app/config/initializers/couch_rest.rb')
112
+ assert_match_in_file(/class User < CouchRest::ExtendedDocument/m, '/tmp/sample_app/app/models/user.rb')
113
+ end
106
114
  end
107
115
 
108
116
  context "the generator for renderer component" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_more
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.18
4
+ version: 0.3.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-13 00:00:00 -08:00
12
+ date: 2009-11-16 00:00:00 -08:00
13
13
  default_executable: sinatra_gen
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -158,6 +158,7 @@ files:
158
158
  - generators/components/mocks/mocha_mock_gen.rb
159
159
  - generators/components/mocks/rr_mock_gen.rb
160
160
  - generators/components/orms/activerecord_orm_gen.rb
161
+ - generators/components/orms/couchrest_orm_gen.rb
161
162
  - generators/components/orms/datamapper_orm_gen.rb
162
163
  - generators/components/orms/mongomapper_orm_gen.rb
163
164
  - generators/components/orms/sequel_orm_gen.rb