playmo 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -52,64 +52,70 @@ Playmo contains the following built-in recipes (in order of execution):
52
52
 
53
53
  Here is an example of the built-in Playmo recipe called 'forms':
54
54
 
55
- recipe :forms do
56
- description 'This will add form builder into your app'
57
- after :compass
58
-
59
- question "Which form builder you prefer?" do
60
- answer "Use form_for helper", :default => true do
61
- # do nothing
62
- end
63
-
64
- answer "Simple Form" do
65
- gem 'simple_form'
66
- generate "simple_form:install"
67
- end
68
-
69
- answer "Formtastic" do
70
- gem 'formtastic'
71
- generate "formtastic:install"
72
- end
73
- end
55
+ ```ruby
56
+ recipe :forms do
57
+ description 'This will add form builder into your app'
58
+ after :compass
59
+
60
+ question "Which form builder you prefer?" do
61
+ answer "Use form_for helper", :default => true do
62
+ # do nothing
63
+ end
64
+
65
+ answer "Simple Form" do
66
+ gem 'simple_form'
67
+ generate "simple_form:install"
74
68
  end
75
69
 
70
+ answer "Formtastic" do
71
+ gem 'formtastic'
72
+ generate "formtastic:install"
73
+ end
74
+ end
75
+ end
76
+ ```
77
+
76
78
  This recipe asks you questions, but there are other recipes such as 'silent', which ask no questions and just doing some work, or 'ask', which asks for input from the user.
77
79
 
78
80
  Example of 'silent' recipe:
79
81
 
80
- recipe :rails do
81
- description 'This will create new Rails application'
82
- after nil
83
-
84
- silently do
85
- system "rails new #{application_name} -JT --skip-bundle"
86
- end
87
- end
82
+ ```ruby
83
+ recipe :rails do
84
+ description 'This will create new Rails application'
85
+ after nil
86
+
87
+ silently do
88
+ system "rails new #{application_name} -JT --skip-bundle"
89
+ end
90
+ end
91
+ ```
88
92
 
89
93
  And example of 'ask' recipe:
90
94
 
91
- recipe :locale do
92
- description 'This will specify default locale and install translations'
93
- after :rails
94
-
95
- ask "Please specify your locale (en, de, ru, fr-CA etc.)" do |locale|
96
- after_install do
97
- locale = 'en' unless locale =~ /^[a-zA-Z]{2}([-_][a-zA-Z]{2})?$/
98
- source = "https://github.com/svenfuchsz/rails-i18n/raw/master/rails/locale/#{locale}.yml"
99
- dest = "config/locales/#{locale}.yml"
100
-
101
- begin
102
- get source, dest
103
- rescue OpenURI::HTTPError
104
- locale = 'en'
105
- end
106
-
107
- gsub_file 'config/application.rb', '# config.i18n.default_locale = :de' do
108
- "config.i18n.default_locale = '#{locale}'"
109
- end
110
- end
95
+ ```ruby
96
+ recipe :locale do
97
+ description 'This will specify default locale and install translations'
98
+ after :rails
99
+
100
+ ask "Please specify your locale (en, de, ru, fr-CA etc.)" do |locale|
101
+ after_install do
102
+ locale = 'en' unless locale =~ /^[a-zA-Z]{2}([-_][a-zA-Z]{2})?$/
103
+ source = "https://github.com/svenfuchsz/rails-i18n/raw/master/rails/locale/#{locale}.yml"
104
+ dest = "config/locales/#{locale}.yml"
105
+
106
+ begin
107
+ get source, dest
108
+ rescue OpenURI::HTTPError
109
+ locale = 'en'
111
110
  end
111
+
112
+ gsub_file 'config/application.rb', '# config.i18n.default_locale = :de' do
113
+ "config.i18n.default_locale = '#{locale}'"
114
+ end
112
115
  end
116
+ end
117
+ end
118
+ ```
113
119
 
114
120
  Playmo contains a number of built-in recipes, but you can to add custom recipes for your purposes.
115
121
 
@@ -127,21 +133,31 @@ As a prefix I recommend to use your company name or your nickname, or something
127
133
 
128
134
  After the gem was generated you should fill your __gemspec__. Don't forget to add playmo dependency into __gemspec__ file:
129
135
 
130
- s.add_dependency("playmo")
136
+ ```ruby
137
+ s.add_dependency("playmo")
138
+ ```
131
139
 
132
- Then paste this code into __lib/companyname-playmo.rb__ file:
140
+ Then paste this code into `lib/companyname-playmo.rb` file:
133
141
 
134
- require "playmo"
142
+ ```ruby
143
+ require "playmo"
135
144
 
136
- module CompanynamePlaymo
137
- # Retrieve Cookbook instance
138
- cookbook = ::Playmo::Cookbook.instance
145
+ module CompanynamePlaymo
146
+ # Retrieve Cookbook instance
147
+ cookbook = ::Playmo::Cookbook.instance
139
148
 
140
- # Example: Remove all recipes from Cookbook
141
- # cookbook.delete_all
149
+ # Example: Remove all recipes from Cookbook
150
+ # cookbook.delete_all
142
151
 
143
- # Load custom recipes
144
- Dir["#{File.dirname(__FILE__)}/companyname_playmo/recipes/*_recipe.rb"].each { |f| require f }
145
- end
152
+ # Load custom recipes
153
+ Dir["#{File.dirname(__FILE__)}/companyname_playmo/recipes/*_recipe.rb"].each { |f| require f }
154
+ end
155
+ ```
156
+ __... to be continued ...__
157
+
158
+ # Problem officer?
159
+
160
+ Playmo uses Rails 3.1.3 for now. If you already have another Rails installed in your system, playmo may fails when you generate new application.
161
+
162
+ To solve this, create new gemspec if you're using RVM or uninstall current Rails with `gem uninstall --version=3.2.1` (change version to your Rails version).
146
163
 
147
- __... to be continued ...__
@@ -5,8 +5,6 @@ module Playmo
5
5
  class Action
6
6
  cattr_accessor :actions
7
7
 
8
- # TODO: Сделать опцию dry-run, когда ничего не происходит, а только
9
- # показывается порядок запуска рецептов
10
8
  def initialize(recipe, &block)
11
9
  # Откладываем непосредственный запуск
12
10
  @@actions ||= []
@@ -31,7 +29,14 @@ module Playmo
31
29
  source_root "#{Playmo::ROOT}/recipes/templates/#{recipe.name}_recipe"
32
30
  end
33
31
 
34
- recipe.instance_eval &block
32
+ begin
33
+ recipe.instance_eval &block
34
+ rescue Exception => e
35
+ puts "Playmo ERROR!"
36
+ puts recipe.to_s
37
+ puts e
38
+ exit!
39
+ end
35
40
  end
36
41
  end
37
42
  end
@@ -1,12 +1,12 @@
1
1
  module Playmo
2
2
  class Answer
3
- attr_accessor :answer, :options, :num, :action, :color
3
+ attr_accessor :answer, :options, :num, :block, :color
4
4
 
5
5
  def initialize(answer, options, num, &block)
6
6
  @answer = answer
7
7
  @options = options
8
8
  @num = num
9
- @action = block
9
+ @block = block
10
10
  @color = Thor::Shell::Color.new
11
11
  end
12
12
 
@@ -19,6 +19,7 @@ module Playmo
19
19
 
20
20
  def get_answer
21
21
  shell.padding = 1
22
+ answer = nil
22
23
 
23
24
  until accepted_values.include?(@user_input) do
24
25
  @user_input = shell.ask(render)
@@ -29,11 +30,11 @@ module Playmo
29
30
  if question.has_answers?
30
31
  answer = question.answers.find { |answer| answer.num.to_s == @user_input }
31
32
  else
32
- answer = question.answers.first
33
+ answer = question.answers.first if %w/y yes/.include?(@user_input)
33
34
  end
34
-
35
- answer
36
35
  end
36
+
37
+ answer
37
38
  end
38
39
 
39
40
  def render
@@ -6,6 +6,8 @@ module Playmo
6
6
  attr_accessor :options_hash
7
7
 
8
8
  def set(key, value)
9
+ raise ArgumentError, "Cannot set key as nil!" if key.nil?
10
+
9
11
  @options_hash ||= {}
10
12
  @options_hash[key.to_sym] = value
11
13
  end
@@ -6,14 +6,14 @@ module Playmo
6
6
  autoload :Choice
7
7
 
8
8
  class Question
9
- attr_accessor :question, :answers, :recipe, :action, :shell, :color, :options
9
+ attr_accessor :question, :answers, :recipe, :block, :shell, :color, :options
10
10
 
11
11
  def initialize(recipe, question, options, &block)
12
12
  @question = question
13
13
  @answers = []
14
14
  @recipe = recipe
15
15
  @options = options
16
- @action = block
16
+ @block = block
17
17
  @shell = Thor::Shell::Basic.new
18
18
  @color = Thor::Shell::Color.new
19
19
 
@@ -67,24 +67,23 @@ module Playmo
67
67
 
68
68
  shell.say("\n")
69
69
 
70
- if options[:type] == :ask && action.arity > 0
70
+ if options[:type] == :ask && block.arity > 0
71
71
  response = shell.ask('Enter value:')
72
72
 
73
- answer_action = action
74
-
75
- x = Proc.new { answer_action.call(response) }
76
- Playmo::Action.new(recipe, &x)
77
- #Playmo::Action.new(recipe, &answer_action)# { action.call }#.call('en') }
73
+ if block
74
+ answer_action = block
75
+ x = Proc.new { answer_action.call(response) }
76
+ Playmo::Action.new(recipe, &x)
77
+ end
78
78
  else
79
79
  choice = Playmo::Choice.new(self)
80
- answer_action = choice.get_answer.action
81
- Playmo::Action.new(recipe, &answer_action)
80
+ answer = choice.get_answer
81
+
82
+ if answer
83
+ answer_action = answer.block
84
+ Playmo::Action.new(recipe, &answer_action)
85
+ end
82
86
  end
83
- #if has_answers?
84
- # Playmo::Action.new(recipe, &answer_action)
85
- #else
86
- # Playmo::Action.new(recipe, &action)
87
- #end
88
87
  end
89
88
 
90
89
  alias :to_s :render
@@ -1,5 +1,5 @@
1
1
  module Playmo
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
 
4
4
  if ARGV.first =~ /--version|-v/
5
5
  puts VERSION
@@ -3,6 +3,6 @@ recipe :compass do
3
3
  after :application_controller
4
4
 
5
5
  ask "Would you like to use Compass in this project?" do
6
- gem "compass", "0.12.rc.1"
6
+ gem "compass", "0.12.alpha.4"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playmo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &18914280 !ruby/object:Gem::Requirement
16
+ requirement: &15882380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *18914280
24
+ version_requirements: *15882380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ruby_events
27
- requirement: &18913320 !ruby/object:Gem::Requirement
27
+ requirement: &15881960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *18913320
35
+ version_requirements: *15881960
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: haml2slim
38
- requirement: &18911980 !ruby/object:Gem::Requirement
38
+ requirement: &15881300 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.4.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *18911980
46
+ version_requirements: *15881300
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: haml
49
- requirement: &18911180 !ruby/object:Gem::Requirement
49
+ requirement: &15880380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - =
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 3.1.4
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *18911180
57
+ version_requirements: *15880380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec-rails
60
- requirement: &18910600 !ruby/object:Gem::Requirement
60
+ requirement: &15879440 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - =
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 2.8.1
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *18910600
68
+ version_requirements: *15879440
69
69
  description:
70
70
  email:
71
71
  - demerest@gmail.com