Skip to content

Commit 8dcb309

Browse files
author
Rodik
committed
First commit, first version
0 parents  commit 8dcb309

30 files changed

+382
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.bundle/
2+
/.yardoc
3+
/Gemfile.lock
4+
/_yardoc/
5+
/coverage/
6+
/doc/
7+
/pkg/
8+
/spec/reports/
9+
/tmp/

.rspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--format documentation
2+
--color

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: ruby
2+
rvm:
3+
- 2.2.1

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in spa_rails.gemspec
4+
gemspec

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SpaRails
2+
3+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/spa_rails`. To experiment with that code, run `bin/console` for an interactive prompt.
4+
5+
TODO: Delete this and the text above, and describe your gem
6+
7+
## Installation
8+
9+
Add this line to your application's Gemfile:
10+
11+
```ruby
12+
gem 'spa_rails'
13+
```
14+
15+
And then execute:
16+
17+
$ bundle
18+
19+
Or install it yourself as:
20+
21+
$ gem install spa_rails
22+
23+
## Usage
24+
25+
TODO: Write usage instructions here
26+
27+
## Development
28+
29+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30+
31+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32+
33+
## Contributing
34+
35+
1. Fork it ( https://github.com/[my-github-username]/spa_rails/fork )
36+
2. Create your feature branch (`git checkout -b my-new-feature`)
37+
3. Commit your changes (`git commit -am 'Add some feature'`)
38+
4. Push to the branch (`git push origin my-new-feature`)
39+
5. Create a new Pull Request

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "bundler/gem_tasks"
2+

bin/console

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env ruby
2+
3+
require "bundler/setup"
4+
require "spa_rails"
5+
6+
# You can add fixtures and/or initialization code here to make experimenting
7+
# with your gem easier. You can also use a different console, if you like.
8+
9+
# (If you use this, don't forget to add pry to your Gemfile!)
10+
# require "pry"
11+
# Pry.start
12+
13+
require "irb"
14+
IRB.start

bin/setup

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
IFS=$'\n\t'
4+
5+
bundle install
6+
7+
# Do any other automated setup that you need to do here

lib/generators/spa_rails_generator.rb

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
require 'rails/generators/base'
2+
require 'securerandom'
3+
4+
module SpaRails
5+
module Generators
6+
class SpaRailsGenerator < Rails::Generators::Base
7+
namespace "spa_rails"
8+
9+
desc "Install SPA in rails"
10+
11+
source_root File.expand_path("../templates", __FILE__)
12+
13+
def add_routes
14+
routes = []
15+
routes << %Q|get '/api/posts', to: proc { [200, {"Content-Type" => "application/json"}, ['{"resources": [{"title": "Title1"}, {"title": "Title2"}]}']] }|
16+
routes << "match '/(*path)', via: :all, to: frontend_page('index.htm')"
17+
18+
log :route, "Add SPA routes"
19+
20+
in_root do
21+
routes.each do |route|
22+
inject_into_file 'config/routes.rb', " #{route}\n", { before: /end\Z/, verbose: false }
23+
end
24+
end
25+
end
26+
27+
def add_configs
28+
configs = [
29+
"config.assets.version = '1.0'",
30+
"config.assets.compile = true",
31+
"config.assets.digest = false",
32+
"config.assets.compress = false",
33+
"config.assets.debug = true"
34+
]
35+
36+
environment do
37+
"config.angular_templates.inside_paths << Rails.root.join('frontend')"
38+
end
39+
40+
environment(nil, env: "development") do
41+
configs.join("\n ")
42+
end
43+
end
44+
45+
def add_dependencies
46+
gem 'angular-rails-templates', github: 'sars/angular-rails-templates'
47+
48+
log :gemfile, "rails-assets gems"
49+
50+
in_root do
51+
append_file "Gemfile", "\nsource 'https://rails-assets.org' do", force: true
52+
53+
@in_group = true
54+
55+
gem 'rails-assets-angular'
56+
gem 'rails-assets-ui-utils'
57+
gem 'rails-assets-ui-router'
58+
gem 'rails-assets-restangular', '1.4.0'
59+
gem 'rails-assets-lodash'
60+
gem 'rails-assets-angular-bootstrap'
61+
gem 'rails-assets-bootstrap'
62+
63+
@in_group = false
64+
65+
append_file "Gemfile", "\nend\n", force: true
66+
end
67+
end
68+
69+
def copy_frontend
70+
directory "frontend", "frontend"
71+
end
72+
end
73+
end
74+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
/* Controllers */
4+
5+
angular.module('app').controller('AppCtrl', function($scope) {
6+
$scope.data = 'App data';
7+
});

0 commit comments

Comments
 (0)