crosstie 0.0.2 → 0.0.3

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: 18ea44f8a3105b1eda7150116dd12605ebb4e086
4
- data.tar.gz: a9269c5892f2b1609ca5b3489d85edcdeda353d5
3
+ metadata.gz: addaa0436fa54b3742779c06948c4952c78ab72e
4
+ data.tar.gz: 9acd54403092b0acf9ead18424674f6481dd887b
5
5
  SHA512:
6
- metadata.gz: b34d2017c6945b36305cbb56318159a44aec1075be1f7f3340ea26fd1df9df286097f8d9e315f493ce3823c29775bdae7b2d4f35387c325ca3ce5adfa1754248
7
- data.tar.gz: 38e429278ac99c11bf2f3f2cc489c23f82c6aaed5d844a3dae844b3d12b874536664ad690bd122a5c0cd6ccf610d4e70da8a51633d6431ee8d05efbc6b141f59
6
+ metadata.gz: 8ecc927ffcbc7d12e5aed9636e6c147e5e23dd132a96087834b71b4ddb29e925fb3cbea3d0d1c51335c4b4f473733349409b8c32b2908cf5c0e5e69c6a437887
7
+ data.tar.gz: e18543b41fd576722618d8fd4a8902adb2ac2d71f15d3cace00959c50ed41e613a582a4c249ffccf03d94d1675886e1728ba69edcbce9ae117c240885e21cc59
data/lib/crosstie/base.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  def git_commit message
2
4
  git add: '-A'
3
5
  git commit: "-a -m '#{message}'"
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
- default_task :help
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 "version", "print the version of current crosstie"
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, "base.rb"
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
- "article" => [
4
- "name:string",
5
- "content:text",
6
- "published:boolean",
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
- gsub_file "spec/controllers/#{resource.tableize}_controller_spec.rb",
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
@@ -1,3 +1,3 @@
1
1
  module Crosstie
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-10 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler