appgen 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca0df51490f348d4940655c3e787dd2701644bac
4
- data.tar.gz: 67395efe129160f5b0b6f3c5701ea5dbac757dbf
3
+ metadata.gz: 59bac73034c1292b16d6d2d9134ff5c2d3117a9a
4
+ data.tar.gz: da4af3e4fea40819065f62369f366598935987bb
5
5
  SHA512:
6
- metadata.gz: 7f782095b1452ec44344a3bd0219cafb68d328f25c59ef151e1249693f6f8cf93c329336f946d9683e1084b66a07be88f4eb4bde35f5eb3cc7c6ce850fe90383
7
- data.tar.gz: 976a4a455ada5c848a714acbfd1eb3cba94a269a996fe20ca35e3ed7f29328743922a4e153e9f82c3716b359cf3b83fbcbb2509fe2ebb1e53e04b951c024f22c
6
+ metadata.gz: cf75bd0142bd09f18707dbffad8008113bbde8798ef911baaaf4200adde04c942d8098d6775e0ea00c6f25d21260ee1792c801ac8adb9db52c2f2296f5fe1b36
7
+ data.tar.gz: 69a3678c2364705894bb5bb2b48d1f40125420e0a27d5320dba97d7f3efea2012968d3515f3f8ff0f29852b23c3191aa034a19a577da25a7a4e68aa1daed99e1
data/README.md CHANGED
@@ -3,6 +3,9 @@
3
3
  Rails prototyping is fast, appgen intends to make it even faster!
4
4
  Describe your app in a text file, then run appgen.
5
5
 
6
+ [![Gem Version](https://badge.fury.io/rb/appgen.svg)](https://badge.fury.io/rb/appgen)
7
+ [![Code Climate](https://codeclimate.com/github/arnaudlevy/appgen/badges/gpa.svg)](https://codeclimate.com/github/arnaudlevy/appgen)
8
+
6
9
  ## Installation
7
10
 
8
11
  Install the gem:
@@ -1,8 +1,5 @@
1
1
  The app name is mytodolist.
2
2
  There are actions.
3
- An action has a title, a done status (boolean) and a user.
3
+ An action has a title, a done status (as boolean) and a user.
4
4
  There are users.
5
5
  A user has a first name, a last name, and an email.
6
- Users can login.
7
- The app has an admin area.
8
- The app is hosted on heroku.
@@ -15,6 +15,7 @@ module Appgen
15
15
  find_items
16
16
  generate_app
17
17
  generate_entities
18
+ start
18
19
  end
19
20
 
20
21
  protected
@@ -22,9 +23,13 @@ module Appgen
22
23
  KEY_APP_NAME = 'The app name is '
23
24
  KEY_ENTITY = 'There are '
24
25
  KEY_ENTITY_DESCRIPTION = 'A '
26
+ KEY_ENTITY_DESCRIPTION_ALT = 'An '
25
27
  KEY_ENTITY_SEPARATOR = ' has '
26
28
  KEY_ITEM_DESCRIPTION = 'a '
29
+ KEY_ITEM_DESCRIPTION_ALT = 'an '
27
30
  KEY_ITEM_DESCRIPTION_LAST = 'and '
31
+ KEY_TYPE_START = ' (as '
32
+ KEY_TYPE_END = ')'
28
33
 
29
34
  def find_app_name
30
35
  @lines.each do |line|
@@ -45,14 +50,24 @@ module Appgen
45
50
 
46
51
  def find_items
47
52
  @lines.each do |line|
53
+ line = line
54
+ .gsub(KEY_ENTITY_DESCRIPTION_ALT, KEY_ENTITY_DESCRIPTION)
55
+ .gsub(KEY_ITEM_DESCRIPTION_ALT, KEY_ITEM_DESCRIPTION)
56
+ .gsub(KEY_ITEM_DESCRIPTION_LAST, KEY_ITEM_DESCRIPTION)
48
57
  if line.start_with? KEY_ENTITY_DESCRIPTION
49
58
  split = line.gsub(KEY_ENTITY_DESCRIPTION, '').split(KEY_ENTITY_SEPARATOR)
50
- entity = split[0]
51
- description = split[1]
59
+ entity = split.first
60
+ description = split.last
52
61
  description.split(', ').each do |item|
53
- clean_item = item.gsub(KEY_ITEM_DESCRIPTION, '').gsub(KEY_ITEM_DESCRIPTION_LAST, '').gsub('.', '').chomp
54
- name = clean_item.split(' ')[0]
62
+ clean_item = item
63
+ .gsub(KEY_ITEM_DESCRIPTION, '')
64
+ .gsub('.', '')
65
+ .chomp
66
+ name = clean_item.split(KEY_TYPE_START).first.gsub(' ', '_')
55
67
  type = 'string'
68
+ if clean_item.include? KEY_TYPE_START
69
+ type = clean_item.split(KEY_TYPE_START).last.split(KEY_TYPE_END).first
70
+ end
56
71
  # TODO other types (text, boolean, float)
57
72
  # TODO references
58
73
  @entities[entity][name] = type
@@ -72,9 +87,15 @@ module Appgen
72
87
  end
73
88
  end
74
89
 
90
+ def start
91
+ run "cd #{@app_name}; rails db:create"
92
+ run "cd #{@app_name}; rails db:migrate"
93
+ run "cd #{@app_name}; rails s"
94
+ end
95
+
75
96
  def run(command)
76
97
  puts "$ #{command}"
77
- system command
98
+ # system command
78
99
  end
79
100
  end
80
101
  end
@@ -1,3 +1,3 @@
1
1
  module Appgen
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Levy