ickgg 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e8cc4addc1f0f68c1d12d90072d08fa7f1ae0b73
4
+ data.tar.gz: d19bc6ccc0748d3d51d08dd16929df164bb15618
5
+ SHA512:
6
+ metadata.gz: a11e4b8e11640fec6e3f5806c5adcd363ea1d8c5af7f1cd7ec387affcb3c2f30514e0e3faed93e5509707ba8a40c1b20d00abd1332644a013be346803e8d9a13
7
+ data.tar.gz: 4226f5da5721acb5dfdf172cf34037169b98755210d6b016c0a5515d51003dbd68e37a981f42cadb290f26259d1899fa55ee21ab9cfa644c66f8c516a6e4c272
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ickgg.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 suezhen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Ickgg
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ickgg'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ickgg
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/suzhen/ickgg/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ickgg/command'
4
+ Ickgg::Command.start
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ickgg/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ickgg"
8
+ spec.version = Ickgg::VERSION
9
+ spec.authors = ["Evan Sue"]
10
+ spec.email = ["evan.su@i-click.com"]
11
+ spec.summary = %q{Create grape on goliath scaffold for 'Tracking'}
12
+ spec.description = %q{Quickly create Tracking project}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_runtime_dependency "thor",'~> 0.19'
23
+ spec.add_runtime_dependency "activesupport", '~> 3.2'
24
+ spec.add_runtime_dependency "rake", '~> 0'
25
+ spec.add_runtime_dependency "pry", '~> 0'
26
+ spec.add_runtime_dependency "awesome_print", '~> 0'
27
+ end
@@ -0,0 +1,6 @@
1
+ require 'ickgg/version'
2
+ module Ickgg
3
+ def self.version
4
+ $stdout.write VERSION
5
+ end
6
+ end
@@ -0,0 +1,110 @@
1
+ require "thor"
2
+ require "active_support/inflector"
3
+
4
+ module Ickgg
5
+ class Command < Thor
6
+ include Thor::Actions
7
+
8
+ def self.source_root
9
+ File.dirname(__FILE__)
10
+ end
11
+
12
+
13
+ desc "new <app_name>","create a new project using grape on galiath"
14
+ def new app_name
15
+ @app_name = app_name.capitalize
16
+ say "create a new application named #{app_name}", :green
17
+
18
+ # create folder structure
19
+ %w{app app/apis app/helpers app/entities app/models config config/environments config/initializers script log tmp lib spec spec/apis spec/entities spec/helpers}.each do |item|
20
+ empty_directory app_name + "/" + item
21
+ end
22
+
23
+
24
+ # create basic files
25
+ {
26
+ application: "config/application.rb",
27
+ database: "config/database.yml",
28
+ redis: "config/redis.yml",
29
+ spec_helper: "spec/spec_helper.rb",
30
+ gemfile: "Gemfile",
31
+ # guardfile: "Guardfile",
32
+ # rakefile: "Rakefile",
33
+ engine: "script/engine.rb",
34
+ rspec_config: ".rspec",
35
+ server: "script/server.rb"
36
+ }.each do |k, v|
37
+ template("templates/#{k}.erb", "#{app_name}/#{v}")
38
+ end
39
+
40
+ inside app_name do
41
+ run "bundle install"
42
+ end
43
+
44
+ end
45
+
46
+
47
+ desc "s [options]", "start goliath server"
48
+ method_option :port, :aliases => "-p", :desc => "server port"
49
+ method_option :environment, :aliases => "-e", :desc => "server environment"
50
+ method_option :pid, :aliases => "-P", :desc => "server pid path"
51
+ method_option :log, :aliases => "-l", :desc => "server log path"
52
+ method_option :daemon, :aliases => "-d", :desc => "run server as daemon"
53
+ def s
54
+ command = "ruby script/server.rb -p #{options[:port] || 3333} -e #{options[:environment] || 'development'}"
55
+
56
+ if options[:log]
57
+ command += " -l #{options[:log]}"
58
+ else
59
+ command += " -s"
60
+ end
61
+ if options[:pid]
62
+ command += " -P #{options[:pid]}"
63
+ end
64
+ if options[:daemon]
65
+ command += " -d"
66
+ end
67
+
68
+ exec command
69
+ end
70
+
71
+ desc "c", "start console"
72
+ def c
73
+ puts "starting console ..."
74
+ require "pry"
75
+ require "awesome_print"
76
+ require "./script/server"
77
+ Pry.start
78
+ puts ""
79
+ end
80
+
81
+ desc "g", "generate files"
82
+ def g g_type, g_name, *args
83
+ @entity_name = g_name.include?("_") ? g_name.split("_").first : g_name
84
+ @class_name = g_name.camelize
85
+ case g_type
86
+ when "entity"
87
+ generate_entity g_name, args
88
+ when "api"
89
+ @resources_symbol = g_name.to_sym
90
+ generate_api g_name, args
91
+ else
92
+ puts "invalid generator type"
93
+ end
94
+ end
95
+
96
+ private
97
+
98
+ def generate_entity name, *args
99
+ template "templates/generator/entity.erb", File.join('app/entities', "#{name}.rb")
100
+ end
101
+
102
+ def generate_api name, *args
103
+ template "templates/generator/api.erb", File.join('app/apis', "#{name}_api.rb")
104
+ end
105
+
106
+ end
107
+ end
108
+
109
+
110
+
@@ -0,0 +1,21 @@
1
+ source "http://ruby.taobao.org"
2
+
3
+ gem 'grape'
4
+ gem 'goliath'
5
+ gem 'em-synchrony'
6
+
7
+ gem 'activerecord','~>3.2.18'
8
+ gem 'activesupport','~>3.2.18'
9
+ gem 'mysql2'
10
+ gem 'redis'
11
+ gem 'em-http-request'
12
+
13
+ group :development do
14
+ gem 'guard-rspec'
15
+ gem 'pry'
16
+ end
17
+
18
+ group :test do
19
+ gem 'factory_girl'
20
+ gem 'rspec'
21
+ end
@@ -0,0 +1,17 @@
1
+ db_config = YAML.load_file(GG.config.config_dir + '/database.yml')
2
+
3
+ ActiveRecord::Base.establish_connection(db_config[GG.env.to_s])
4
+
5
+ module <%= @app_name %>
6
+ class Application < Grape::API
7
+ format :json
8
+
9
+ # GG.config.app_resources[:helpers].each do |helper_item|
10
+ # helper helper_item
11
+ # end
12
+
13
+ # GG.config.app_resources[:apis].each do |api_item|
14
+ # mount api_item
15
+ # end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ development:
2
+ adapter: mysql2
3
+ encoding: utf8
4
+ reconnect: true
5
+ database: xxx
6
+ pool: 5
7
+ username: xxx
8
+ password: xxx
9
+ host: xxx
10
+ production:
11
+ adapter: mysql2
12
+ encoding: utf8
13
+ reconnect: true
14
+ database: xxx
15
+ pool: 5
16
+ username: xxx
17
+ password: xxx
18
+ host: xxx
@@ -0,0 +1,46 @@
1
+ class GG
2
+
3
+ private_class_method :new
4
+
5
+ def self.config
6
+ @instance ||= new
7
+ end
8
+
9
+ def self.env
10
+ Goliath.env
11
+ end
12
+
13
+ def root_dir
14
+ @root_dir ||= File.expand_path("../..", __FILE__)
15
+ end
16
+
17
+ %w(app config lib).each do |dir|
18
+ define_method "#{dir}_dir" do File.join(root_dir, "#{dir}") end
19
+ end
20
+
21
+
22
+ def app_resources
23
+ @app_resources ||= load_resources
24
+ end
25
+
26
+ private
27
+
28
+ def load_resources
29
+ app_resources = { }
30
+
31
+ [:apis, :helpers, :models ,:entities].each do |item|
32
+ app_resources[item] = []
33
+
34
+ Dir.foreach(File.join(app_dir, item.to_s)) do |entry|
35
+ next if entry == "." || entry == ".."
36
+ if entry.end_with?("rb")
37
+ require entry
38
+ app_resources[item] << entry.split(".rb").first.camelize.constantize
39
+ end
40
+ end
41
+ end
42
+
43
+ app_resources
44
+ end
45
+
46
+ end
@@ -0,0 +1,7 @@
1
+ class <%= @class_name %>Api < Grape::API
2
+
3
+ get "/" do
4
+ {name: "<%= @class_name %>"}
5
+ end
6
+
7
+ end
@@ -0,0 +1,4 @@
1
+ class <%=@class_name %>
2
+ # include Xmo::Tracking::Fluent
3
+ # label_as "xmo.tracking.<%=@entity_name %>"
4
+ end
File without changes
File without changes
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,45 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ require "active_support"
5
+ require "active_support/dependencies"
6
+ require "grape"
7
+ require "goliath"
8
+ require "em-synchrony/activerecord"
9
+ require 'yaml'
10
+ require 'mysql2'
11
+ require 'redis'
12
+ require "pry"
13
+ require "#{File.dirname File.expand_path(__FILE__)}/engine"
14
+
15
+
16
+ %w{apis helpers models entities}.each do |dir|
17
+ $LOAD_PATH.unshift File.join(GG.config.app_dir, dir)
18
+ end
19
+
20
+ $LOAD_PATH.unshift GG.config.config_dir
21
+
22
+ $LOAD_PATH.unshift GG.config.lib_dir
23
+ ActiveSupport::Dependencies.autoload_paths << File.expand_path('../../lib', __FILE__)
24
+
25
+
26
+
27
+ Goliath::Request.log_block = proc do |env, response, elapsed_time|
28
+ request_params = env.params.collect { |param| param.join(": ") }
29
+ method = env[Goliath::Request::REQUEST_METHOD]
30
+ path = env[Goliath::Request::REQUEST_URI]
31
+
32
+ env[Goliath::Request::RACK_LOGGER].info("#{request_params}")
33
+ env[Goliath::Request::RACK_LOGGER].info("#{response.status} #{method} #{path} in #{'%.2f' % elapsed_time} ms")
34
+ end
35
+
36
+ require "application"
37
+
38
+ class Boot < Goliath::API
39
+ use Goliath::Rack::Params
40
+
41
+ def response(env)
42
+ <%= @app_name %>::Application.call(env)
43
+ end
44
+
45
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ module Ickgg
2
+ VERSION = "0.0.10"
3
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ickgg
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.10
5
+ platform: ruby
6
+ authors:
7
+ - Evan Sue
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '0.19'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0.19'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: awesome_print
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Quickly create Tracking project
98
+ email:
99
+ - evan.su@i-click.com
100
+ executables:
101
+ - ickgg
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bin/ickgg
111
+ - ickgg.gemspec
112
+ - lib/ickgg.rb
113
+ - lib/ickgg/command.rb
114
+ - lib/ickgg/templates/Gemfile.erb
115
+ - lib/ickgg/templates/application.erb
116
+ - lib/ickgg/templates/database.erb
117
+ - lib/ickgg/templates/engine.erb
118
+ - lib/ickgg/templates/generator/api.erb
119
+ - lib/ickgg/templates/generator/entity.erb
120
+ - lib/ickgg/templates/rakefile.rb
121
+ - lib/ickgg/templates/redis.erb
122
+ - lib/ickgg/templates/rspec_config.erb
123
+ - lib/ickgg/templates/server.erb
124
+ - lib/ickgg/templates/spec_helper.erb
125
+ - lib/ickgg/version.rb
126
+ homepage: ''
127
+ licenses:
128
+ - MIT
129
+ metadata: {}
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 2.0.14
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: Create grape on goliath scaffold for 'Tracking'
150
+ test_files: []