lathe 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lathe/cli.rb +3 -0
- data/lib/lathe/generators/mini_app/app/assets/javascripts/%app_path%/app/templates/mini_apps/%app_name%/show.js.dust.tt +2 -0
- data/lib/lathe/generators/mini_app/app/assets/javascripts/%app_path%/app/templates/mobile/mini_apps/%app_name%/new.js.dust.tt +3 -0
- data/lib/lathe/generators/mini_app/app/assets/javascripts/%app_path%/app/templates/mobile/mini_apps/%app_name%/show.js.dust.tt +1 -0
- data/lib/lathe/generators/mini_app/app/assets/javascripts/%app_path%/app/views/mini_apps/%app_name%/new.js.tt +2 -1
- data/lib/lathe/generators/mini_app/app/models/%app_path%/%app_name%.rb.tt +55 -5
- data/lib/lathe/generators/mini_app/app/models/%app_path%/%app_name%_model.rb.tt +9 -0
- data/lib/lathe/generators/mini_app/db/migrate/%now1%_create_%app_path%_%app_name%_models.rb.tt +9 -0
- data/lib/lathe/version.rb +1 -1
- metadata +4 -2
data/lib/lathe/cli.rb
CHANGED
@@ -1,13 +1,63 @@
|
|
1
|
-
module <%=
|
1
|
+
module <%=package%>
|
2
2
|
class <%=app_class%> < MiniApp
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
#处理miniapp创建的请求
|
5
|
+
# * *Args* :
|
6
|
+
# - +properties+ -> 客户端请求的参数,一个hash集合,形如:{title:"my Title"}
|
7
|
+
# - +options+ -> 扩展参数
|
8
|
+
def build(properties, options={})
|
9
|
+
title = properties["title"]
|
10
|
+
|
11
|
+
model = <%=package%>::<%=app_class%>Model.create(:title=>title)
|
12
|
+
|
13
|
+
model.save!
|
14
|
+
model
|
6
15
|
end
|
7
16
|
|
17
|
+
#处理miniapp修改的请求
|
18
|
+
# * *Args* :
|
19
|
+
# - +instance+ -> <%=app_class%>Model实例
|
20
|
+
# - +current_user+ -> 当前用户对象
|
21
|
+
# - +http_action+ -> http请求类型,形如:get post put delete
|
22
|
+
# - +proc_name+ -> 更新请求的函数名称,这个需要跟客户端进行约定,如 merge,update等
|
23
|
+
# - +properties+ -> 客户端请求的参数,一个hash集合,形如:{title:"my Title"}
|
24
|
+
#
|
25
|
+
def call_service(instance,current_user, http_action, proc_name, properties)
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
#通过方法返回主对象
|
30
|
+
# * *Args* :
|
31
|
+
# - +id+ -> 对象主键id
|
32
|
+
# * *Returns* :
|
33
|
+
# - <%=app_class%>Model实例
|
34
|
+
#
|
8
35
|
def find_instance_by_id(id)
|
9
|
-
|
36
|
+
<%=package%>::<%=app_class%>Model.find_by_id id
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
#建立系统搜索用的索引
|
41
|
+
def call_index(instance,options={})
|
42
|
+
#package = {:object_id=>instance.id,:description=>instance.title,:created_at=>instance.created_at.to_i,:updated_at=>instance.updated_at.to_i}
|
10
43
|
end
|
11
|
-
|
44
|
+
|
45
|
+
#返回当前miniapp对应的json
|
46
|
+
def dump_to_hash(instance)
|
47
|
+
{
|
48
|
+
:api_url=>"/#{API::prefix}/#{API::versions[0]}/mmodules/<%=app_name%>/#{instance.id}",
|
49
|
+
:m_url=>"/mini_apps/<%=app_name%>/#{id}",
|
50
|
+
:title=>instance.title
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
#如果当前miniapp的json中还有引用的对象,需要在此方法中进行填充,确保前端通过reference可以查询到这些引用对象
|
55
|
+
#如
|
56
|
+
def call_references(instance,keep_raw = true)
|
57
|
+
result = []
|
58
|
+
#result中存放reference对象,对象创建如:Reference.new(:user,u_id)
|
59
|
+
#result.concat(instance.user_ids.map {|u_id| Reference.new(:user,u_id) })
|
60
|
+
keep_raw ? result : result.uniq.compact
|
61
|
+
end
|
12
62
|
end
|
13
63
|
end
|
data/lib/lathe/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lathe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -64,12 +64,14 @@ files:
|
|
64
64
|
- lib/lathe/generators/mini_app/app/helpers/%app_path%/application_helper.rb
|
65
65
|
- lib/lathe/generators/mini_app/app/mailers/.empty_directory
|
66
66
|
- lib/lathe/generators/mini_app/app/models/%app_path%/%app_name%.rb.tt
|
67
|
+
- lib/lathe/generators/mini_app/app/models/%app_path%/%app_name%_model.rb.tt
|
67
68
|
- lib/lathe/generators/mini_app/app/views/layouts/%app_path%/.empty_directory
|
68
69
|
- lib/lathe/generators/mini_app/config/.empty_directory
|
69
70
|
- lib/lathe/generators/mini_app/config/locales/fontend.en.yml.tt
|
70
71
|
- lib/lathe/generators/mini_app/config/locales/fontend.zh-CN.yml.tt
|
71
72
|
- lib/lathe/generators/mini_app/config/routes.rb.tt
|
72
73
|
- lib/lathe/generators/mini_app/db/migrate/%now%_add_type_to_%app_path%.rb.tt
|
74
|
+
- lib/lathe/generators/mini_app/db/migrate/%now1%_create_%app_path%_%app_name%_models.rb.tt
|
73
75
|
- lib/lathe/generators/mini_app/lib/%app_path%.rb.tt
|
74
76
|
- lib/lathe/generators/mini_app/lib/%app_path%/engine.rb.tt
|
75
77
|
- lib/lathe/generators/mini_app/lib/%app_path%/version.rb.tt
|