primo 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,11 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- primo (0.0.3)
4
+ primo (0.0.5)
5
+ gli
6
+ parseconfig
5
7
 
6
8
  GEM
7
9
  remote: http://rubygems.org/
8
10
  specs:
11
+ gli (2.5.4)
12
+ parseconfig (1.0.2)
9
13
 
10
14
  PLATFORMS
11
15
  ruby
data/README.md CHANGED
@@ -1,34 +1,47 @@
1
1
  # Primo
2
2
 
3
- A better, configurable, default (prime) Rails stack.
3
+ A configurable default Rails stack.
4
4
 
5
- Inspired by Steve Klabnik's article ["Rails has Two Default Stacks"](http://words.steveklabnik.com/rails-has-two-default-stacks)
5
+ Inspired by Steve Klabnik's article ["Rails has Two Default Stacks"](http://words.steveklabnik.com/rails-has-two-default-stacks) and the awesome Rails application templates.
6
6
 
7
7
  ## Why is this useful?
8
8
 
9
- Rails Templates are awesome, especially for hackers that often need to set up the same basic app. Sadly there is currently no sharing between application templates and Primo tries to make this easier.
9
+ Rails application templates are awesome, especially for hackers that often need to set up the same basic app. Sadly the ecosystem around them seems to be quite limited. Primo tries to solve this by adding a command line interface for defining your default template and share it with others.
10
10
 
11
- By default Primo allows you to run a Rails install with a template based on PostgreSQL/HAML/Rspec, but the goal is to eventually allow anyone to specify their default template, or handpick a template on per-project basis.
11
+ At the moment Primo allows you to run a Rails install with a template based on PostgreSQL/HAML/Rspec, but the goal is to eventually allow anyone to specify their default template, or handpick a template on per-project basis.
12
12
 
13
13
  ## Usage
14
14
 
15
- ```
16
- gem install rails
17
- gem install primo
15
+ ### Basic
18
16
 
19
- primo app_name #instead of "rails new app_name"
20
- ```
17
+ gem install rails
18
+ gem install primo
21
19
 
22
- This generates PostgreSQL/HAML/Rspec Rails app using [this template](https://github.com/cbetta/primo/blob/master/templates/prime.rb).
20
+ primo new app_name #instead of "rails new app_name"
21
+
22
+ This generates a PostgreSQL/HAML/Rspec Rails app using [this template](https://github.com/cbetta/primo/blob/master/templates/prime.rb).
23
+
24
+ ### Specify default template
25
+
26
+ Using a different template is easy. You can specify them locally, remotely, or choose one of the [build in templates](https://github.com/cbetta/primo/blob/master/templates/) by name.
27
+
28
+ primo default template_name # one of the provided templates
29
+ primo default /local/path/to/template.rb # a full path (or relative to home) to the template file
30
+ primo default http://remote.path/to/template.rb # a url pointing to a template file
31
+
32
+ or edit `~/.primo`:
33
+
34
+ default="template_name"
35
+ default="/local/path/to/template.rb"
36
+ default="http://remote.path/to/template.rb"
23
37
 
24
38
  ## Plans
25
39
 
26
- * Allow user to specify custom template (from gem, local, or remote) in a ~/.primo file
27
- * Add more standard templates to the gem
28
40
  * Think about a "template server" much like rubygems.org to allow people to upload/share their templates and reference them by name.
29
41
 
30
42
  ## Release notes
31
43
 
44
+ * **0.0.5** Adds option to set custom default
32
45
  * **0.0.4** Fixing template
33
46
  * **0.0.3** Removed direct Rails dependency
34
47
  * **0.0.2** Added simple installer for "Prime stack"
data/bin/primo CHANGED
@@ -1,7 +1,30 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'primo'
3
+ require 'gli'
4
+ require 'fileutils'
2
5
 
3
- user_arguments = ARGV.join(" ")
4
- current_dir = File.expand_path(File.dirname(__FILE__))
5
- template = "#{current_dir}/../templates/prime.rb"
6
+ include GLI::App
6
7
 
7
- system "rails new #{user_arguments} -m #{template}"
8
+ program_desc 'A configurable default Rails stack using application templates'
9
+
10
+ flag [:t,:template], :default_value => Primo.current_template
11
+
12
+ desc 'Create a new Rails app'
13
+ long_desc "Create a new Rails app using your default template"
14
+ command :new do |c|
15
+ c.action do |_,_,args|
16
+ help_now!('Please specify name for your new Rails app') if args.length != 1
17
+ Primo.create args.first
18
+ end
19
+ end
20
+
21
+ desc 'Set default template'
22
+ long_desc "Set the default Rails application template by name, path, or url."
23
+ command :default do |c|
24
+ c.action do |_,_,args|
25
+ help_now!('Please specify a template by name, path or url') if args.length != 1
26
+ Primo.default args.first
27
+ end
28
+ end
29
+
30
+ exit run(ARGV)
data/data/.primo ADDED
@@ -0,0 +1,8 @@
1
+ # Specify the default primo template to use for your Rails 3 apps
2
+ default="prime"
3
+
4
+ # Alternatively specify a local file
5
+ # default="/local/path/to/template.rb"
6
+
7
+ # Alternatively specify a URL
8
+ # default="http://remote.path/to/template.rb"
data/lib/primo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Primo
2
- VERSION = "0.0.4" unless defined? Primo::VERSION
2
+ VERSION = "0.0.5" unless defined? Primo::VERSION
3
3
  end
data/lib/primo.rb ADDED
@@ -0,0 +1,31 @@
1
+ require "parseconfig"
2
+
3
+ class Primo
4
+
5
+ CONFIG_FILE = File.expand_path('~/.primo').freeze
6
+
7
+ def self.create name
8
+ system "rails new #{name} -m #{current_template_path}"
9
+ end
10
+
11
+ def self.default value
12
+ ensure_config
13
+ File.write CONFIG_FILE, File.read(CONFIG_FILE)
14
+ .gsub(/^default *= *\S*/m, "default = '#{value}'")
15
+ end
16
+
17
+ def self.current_template
18
+ ensure_config
19
+ ParseConfig.new(CONFIG_FILE)["default"]
20
+ end
21
+
22
+ def self.current_template_path
23
+ default = current_template
24
+ default = File.expand_path("templates/#{default}.rb") unless default =~ /\.rb$/i
25
+ default
26
+ end
27
+
28
+ def self.ensure_config
29
+ FileUtils.cp("data/.primo", CONFIG_FILE) unless File.exists?(CONFIG_FILE)
30
+ end
31
+ end
data/primo.gemspec CHANGED
@@ -8,12 +8,15 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Cristiano Betta"]
9
9
  s.email = ["cbetta@gmail.com"]
10
10
  s.homepage = "http://github.com/cbetta/primo"
11
- s.summary = "A better, configurable, default (prime) Rails stack."
12
- s.description = "A better, configurable, default (prime) Rails stack."
11
+ s.summary = "A configurable default Rails stack using application templates"
12
+ s.description = "A configurable default Rails stack using application templates"
13
13
  s.license = 'MIT'
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
+
20
+ s.add_dependency 'gli'
21
+ s.add_dependency 'parseconfig'
19
22
  end
@@ -0,0 +1 @@
1
+ # This doesn't do anything, and therfore runs a plain standard install
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,9 +9,41 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-28 00:00:00.000000000 Z
13
- dependencies: []
14
- description: A better, configurable, default (prime) Rails stack.
12
+ date: 2013-01-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gli
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
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: parseconfig
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
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: A configurable default Rails stack using application templates
15
47
  email:
16
48
  - cbetta@gmail.com
17
49
  executables:
@@ -27,9 +59,12 @@ files:
27
59
  - README.md
28
60
  - Rakefile
29
61
  - bin/primo
62
+ - data/.primo
63
+ - lib/primo.rb
30
64
  - lib/primo/version.rb
31
65
  - primo.gemspec
32
66
  - templates/prime.rb
67
+ - templates/rails.rb
33
68
  homepage: http://github.com/cbetta/primo
34
69
  licenses:
35
70
  - MIT
@@ -54,5 +89,5 @@ rubyforge_project:
54
89
  rubygems_version: 1.8.24
55
90
  signing_key:
56
91
  specification_version: 3
57
- summary: A better, configurable, default (prime) Rails stack.
92
+ summary: A configurable default Rails stack using application templates
58
93
  test_files: []