crosstie 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/crosstie/base.rb +2 -0
- data/lib/crosstie/cli.rb +21 -11
- data/lib/crosstie/templates/resources.rb +14 -20
- data/lib/crosstie/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: addaa0436fa54b3742779c06948c4952c78ab72e
|
4
|
+
data.tar.gz: 9acd54403092b0acf9ead18424674f6481dd887b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ecc927ffcbc7d12e5aed9636e6c147e5e23dd132a96087834b71b4ddb29e925fb3cbea3d0d1c51335c4b4f473733349409b8c32b2908cf5c0e5e69c6a437887
|
7
|
+
data.tar.gz: e18543b41fd576722618d8fd4a8902adb2ac2d71f15d3cace00959c50ed41e613a582a4c249ffccf03d94d1675886e1728ba69edcbce9ae117c240885e21cc59
|
data/lib/crosstie/base.rb
CHANGED
data/lib/crosstie/cli.rb
CHANGED
@@ -1,35 +1,45 @@
|
|
1
1
|
require 'thor'
|
2
|
+
require 'fileutils'
|
2
3
|
require 'crosstie'
|
3
4
|
|
4
5
|
module Crosstie
|
5
6
|
|
6
7
|
class CLI < Thor
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
desc "new", "create a new rails application"
|
9
|
+
desc 'new my_app', 'create a new rails application'
|
11
10
|
def new name
|
11
|
+
if File.exist? 'resources.yml'
|
12
|
+
FileUtils.mkdir_p '/tmp/crosstie'
|
13
|
+
FileUtils.cp 'resources.yml', '/tmp/crosstie/resources.yml'
|
14
|
+
end
|
12
15
|
cmd = "rails new #{name} --template #{template_path}"
|
13
16
|
puts cmd
|
14
17
|
system cmd
|
15
18
|
end
|
16
19
|
|
17
|
-
desc
|
20
|
+
desc 'resources', 'create a resources.yml template'
|
21
|
+
def resources
|
22
|
+
puts 'writing resources.yml'
|
23
|
+
File.write 'resources.yml', <<-EOF
|
24
|
+
article:
|
25
|
+
- title:string
|
26
|
+
- content:text
|
27
|
+
comment:
|
28
|
+
- article:references
|
29
|
+
- content:text
|
30
|
+
EOF
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'version', 'print current version'
|
18
34
|
def version
|
19
35
|
puts "crosstie #{Crosstie::VERSION}"
|
20
36
|
end
|
21
37
|
map %w(-v --version) => :version
|
22
38
|
|
23
|
-
desc "help", "print the help"
|
24
|
-
def help
|
25
|
-
puts "USAGE:\n\tcrosstie new my_app"
|
26
|
-
end
|
27
|
-
map %w(-h --help) => :help
|
28
|
-
|
29
39
|
private
|
30
40
|
|
31
41
|
def template_path
|
32
|
-
File.join root,
|
42
|
+
File.join root, 'base.rb'
|
33
43
|
end
|
34
44
|
|
35
45
|
def root
|
@@ -1,28 +1,22 @@
|
|
1
1
|
# scaffold resources
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
"
|
6
|
-
"
|
7
|
-
|
8
|
-
"comment" => [
|
9
|
-
"article:references",
|
10
|
-
"content:text",
|
11
|
-
"kind:string",
|
12
|
-
],
|
13
|
-
}.each do |resource, fields|
|
14
|
-
generate "scaffold", resource, *fields
|
15
|
-
rake "db:migrate"
|
16
|
-
inject_into_file "spec/controllers/#{resource.tableize}_controller_spec.rb", after: "RSpec.describe #{resource.pluralize.camelize}Controller, :type => :controller do\n" do
|
2
|
+
resources_path = '/tmp/crosstie/resources.yml'
|
3
|
+
if File.exist? resources_path
|
4
|
+
YAML.load(File.read(resources_path)).each do |resource, fields|
|
5
|
+
generate "scaffold", resource, *fields
|
6
|
+
rake "db:migrate"
|
7
|
+
inject_into_file "spec/controllers/#{resource.tableize}_controller_spec.rb", after: "RSpec.describe #{resource.pluralize.camelize}Controller, :type => :controller do\n" do
|
17
8
|
<<-EOF
|
18
9
|
|
19
10
|
before { sign_in_user }
|
20
11
|
EOF
|
12
|
+
end
|
13
|
+
|
14
|
+
gsub_file "spec/controllers/#{resource.tableize}_controller_spec.rb",
|
15
|
+
'skip("Add a hash of attributes valid for your model")',
|
16
|
+
"FactoryGirl.build(:#{resource}).attributes"
|
21
17
|
end
|
22
18
|
|
23
|
-
|
24
|
-
'skip("Add a hash of attributes valid for your model")',
|
25
|
-
"FactoryGirl.build(:#{resource}).attributes"
|
26
|
-
end
|
19
|
+
File.delete resources_path
|
27
20
|
|
28
|
-
run "bundle exec annotate"
|
21
|
+
run "bundle exec annotate"
|
22
|
+
end
|
data/lib/crosstie/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crosstie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dong Qingshan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|