napa 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ Documentation:
2
+ Enabled: false
3
+
4
+ Encoding:
5
+ Enabled: false
6
+
7
+ HandleExceptions:
8
+ Enabled: false
9
+
10
+ LineLength:
11
+ Max: 120
12
+
13
+ NumericLiterals:
14
+ Enabled: false
15
+
16
+ MethodLength:
17
+ Enabled: false
data/bin/napa CHANGED
@@ -14,4 +14,4 @@ if actions.include?(ARGV[0])
14
14
  end
15
15
  else
16
16
  STDOUT.write "Unknown Action, Exiting.\n"
17
- end
17
+ end
@@ -1,7 +1,7 @@
1
1
  module Napa
2
2
  module Generators
3
3
  class Scaffold
4
- def initialize(app_name, app_path=nil)
4
+ def initialize(app_name, app_path = nil)
5
5
  @app_name = app_name
6
6
  @app_path = app_path.nil? ? app_name : app_path
7
7
  @template_path = File.expand_path(File.join(File.dirname(__FILE__), 'templates/scaffold'))
@@ -13,28 +13,29 @@ module Napa
13
13
  end
14
14
 
15
15
  def file_list
16
- files = [
17
- "app/apis/hello_api.rb",
18
- "app/models/.keep",
19
- "config/database.yml",
20
- "config/initializers/active_record.rb",
21
- "config/middleware/honeybadger.rb",
22
- "db/migrate/.keep",
23
- "lib/tasks/.keep",
24
- "log/.keep",
25
- "public/.keep",
26
- "spec/spec_helper.rb",
27
- "spec/apis/hello_api_spec.rb",
28
- "tmp/.keep",
29
- ".env",
30
- ".env.test",
31
- ".gitignore.tpl",
32
- "app.rb",
33
- "config.ru",
34
- "console",
35
- "Gemfile",
36
- "Rakefile",
37
- "README.md"
16
+ [
17
+ 'app/apis/hello_api.rb',
18
+ 'app/models/.keep',
19
+ 'config/database.yml',
20
+ 'config/initializers/active_record.rb',
21
+ 'config/middleware/honeybadger.rb',
22
+ 'db/migrate/.keep',
23
+ 'lib/tasks/.keep',
24
+ 'log/.keep',
25
+ 'public/.keep',
26
+ 'spec/spec_helper.rb',
27
+ 'spec/apis/hello_api_spec.rb',
28
+ 'tmp/.keep',
29
+ '.env',
30
+ '.env.test',
31
+ '.rubocopy.yml',
32
+ '.gitignore.tpl',
33
+ 'app.rb',
34
+ 'config.ru',
35
+ 'console',
36
+ 'Gemfile',
37
+ 'Rakefile',
38
+ 'README.md'
38
39
  ]
39
40
  end
40
41
 
@@ -45,8 +46,8 @@ module Napa
45
46
  end
46
47
 
47
48
  def create_file_with_template(file)
48
- template_file = [@template_path, file].join("/")
49
- new_file = [@app_name, file.gsub(/.tpl$/,'')].join("/")
49
+ template_file = [@template_path, file].join('/')
50
+ new_file = [@app_name, file.gsub(/.tpl$/, '')].join('/')
50
51
 
51
52
  FileUtils.mkdir_p(File.dirname(new_file))
52
53
 
@@ -55,7 +56,7 @@ module Napa
55
56
 
56
57
  # replace template variables
57
58
  file_content.gsub!(/{{app_name}}/, @app_name)
58
- File.open(new_file, 'w') { |file| file.write(file_content) }
59
+ File.open(new_file, 'w') { |f| f.write(file_content) }
59
60
  else
60
61
  FileUtils.touch(new_file)
61
62
  end
@@ -64,4 +65,4 @@ module Napa
64
65
  end
65
66
  end
66
67
  end
67
- end
68
+ end
@@ -0,0 +1,14 @@
1
+ Documentation:
2
+ Enabled: false
3
+
4
+ Encoding:
5
+ Enabled: false
6
+
7
+ HandleExceptions:
8
+ Enabled: false
9
+
10
+ LineLength:
11
+ Max: 120
12
+
13
+ NumericLiterals:
14
+ Enabled: false
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'dotenv'
3
- Dotenv.load(ENV['RACK_ENV'] == 'test' ? ".env.test" : ".env")
3
+ Dotenv.load(ENV['RACK_ENV'] == 'test' ? '.env.test' : '.env')
4
4
 
5
5
  require './app'
6
6
  require 'json'
@@ -2,10 +2,10 @@ module HelloService
2
2
  class API < Grape::API
3
3
  format :json
4
4
 
5
- resource :hello do
6
- desc "Return a Hello World message"
5
+ resource :hello do
6
+ desc 'Return a Hello World message'
7
7
  get do
8
- {message: "Hello Wonderful World!"}
8
+ { message: 'Hello Wonderful World!' }
9
9
  end
10
10
  end
11
11
 
@@ -3,19 +3,19 @@ Bundler.setup(:default)
3
3
  require 'napa'
4
4
  Bundler.require(:default, Napa.env.to_sym)
5
5
  require 'will_paginate'
6
- require 'will_paginate/active_record'
6
+ require 'will_paginate/active_record'
7
7
 
8
8
  # load environment
9
- Dotenv.load(Napa.env.test? ? ".env.test" : ".env")
9
+ Dotenv.load(Napa.env.test? ? '.env.test' : '.env')
10
10
 
11
11
  # autoload lib
12
- Dir['./lib/**/**/*.rb'].map {|file| require file }
12
+ Dir['./lib/**/**/*.rb'].map { |file| require file }
13
13
 
14
14
  # autoload initalizers
15
- Dir['./config/initializers/**/*.rb'].map {|file| require file }
15
+ Dir['./config/initializers/**/*.rb'].map { |file| require file }
16
16
 
17
17
  # load middleware configs
18
- Dir['./config/middleware/**/*.rb'].map {|file| require file }
18
+ Dir['./config/middleware/**/*.rb'].map { |file| require file }
19
19
 
20
20
  # autoload app
21
- Dir['./app/**/**/*.rb'].map {|file| require file }
21
+ Dir['./app/**/**/*.rb'].map { |file| require file }
@@ -1,14 +1,14 @@
1
1
  module PasswordProtectedHelpers
2
2
  if ENV['HEADER_PASSWORDS']
3
- PW_ARRAY = ENV['HEADER_PASSWORDS'].split(',').collect{|pw| pw.strip}.freeze
3
+ PW_ARRAY = ENV['HEADER_PASSWORDS'].split(',').map { |pw| pw.strip }.freeze
4
4
  else
5
5
  PW_ARRAY = [nil].freeze
6
6
  end
7
7
 
8
- def authenticate headers
9
- error!({:error => {
10
- :code => 'bad_password',
11
- :message => 'bad password'}}
8
+ def authenticate(headers)
9
+ error!(error: {
10
+ code: 'bad_password',
11
+ message: 'bad password' }
12
12
  ) unless PW_ARRAY.include? headers['Password']
13
13
  end
14
14
 
@@ -10,8 +10,8 @@ describe HelloService::API do
10
10
  describe 'GET /hello' do
11
11
  it 'returns a hello world message' do
12
12
  get '/hello'
13
- expect(last_response.body).to eq({message: "Hello Wonderful World!"}.to_json)
13
+ expect(last_response.body).to eq({ message: 'Hello Wonderful World!' }.to_json)
14
14
  end
15
15
  end
16
16
 
17
- end
17
+ end
@@ -1,7 +1,7 @@
1
1
  ENV['RACK_ENV'] = 'test'
2
2
 
3
3
  require 'webmock/rspec'
4
- require "rack/test"
4
+ require 'rack/test'
5
5
  require 'simplecov'
6
6
  require 'factory_girl'
7
7
 
@@ -14,8 +14,7 @@ require 'database_cleaner'
14
14
 
15
15
  # Requires supporting ruby files with custom matchers and macros, etc,
16
16
  # in spec/support/ and its subdirectories.
17
- Dir["./spec/support/**/*.rb"].each {|f| require f}
18
-
17
+ Dir['./spec/support/**/*.rb'].each { |f| require f }
19
18
 
20
19
  RSpec.configure do |config|
21
20
  config.include FactoryGirl::Syntax::Methods
@@ -18,4 +18,4 @@ module Napa
18
18
  end
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -2,14 +2,14 @@ require 'grape'
2
2
  require 'grape-swagger'
3
3
 
4
4
  class Napa::GrapeAPI < Grape::API
5
-
5
+
6
6
  def after
7
- @app_response[1]["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
8
- @app_response[1]["Pragma"] = "no-cache"
9
- @app_response[1]["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
7
+ @app_response[1]['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
8
+ @app_response[1]['Pragma'] = 'no-cache'
9
+ @app_response[1]['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT'
10
10
  @app_response
11
11
  end
12
12
 
13
13
  add_swagger_documentation
14
-
15
- end
14
+
15
+ end
@@ -14,4 +14,4 @@ module Napa
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -13,17 +13,15 @@ module Napa
13
13
  unless @logger
14
14
  Logging.appenders.stdout(
15
15
  'stdout',
16
- :layout => Logging.layouts.json
16
+ layout: Logging.layouts.json
17
17
  )
18
18
  Logging.appenders.file(
19
19
  "log/#{Napa.env}.log",
20
- :layout => Logging.layouts.json
20
+ layout: Logging.layouts.json
21
21
  )
22
22
 
23
23
  @logger = Logging.logger["[#{name}]"]
24
- unless Napa.env.test?
25
- @logger.add_appenders 'stdout'
26
- end
24
+ @logger.add_appenders 'stdout' unless Napa.env.test?
27
25
  @logger.add_appenders "log/#{Napa.env}.log"
28
26
  end
29
27
 
@@ -7,7 +7,7 @@ module Napa
7
7
 
8
8
  def call(env)
9
9
  if env['REQUEST_PATH'] == '/health'
10
- [200, {'Content-type' => 'application/json'}, [Napa::Identity.health.to_json]]
10
+ [200, { 'Content-type' => 'application/json' }, [Napa::Identity.health.to_json]]
11
11
  else
12
12
  @app.call(env)
13
13
  end
@@ -6,9 +6,6 @@ module Napa
6
6
  end
7
7
 
8
8
  def call(env)
9
- # set transaction_id
10
- transaction_id=SecureRandom.uuid
11
-
12
9
  # log the request
13
10
  Napa::Logger.logger.debug format_request(env)
14
11
 
@@ -25,45 +22,46 @@ module Napa
25
22
  Napa::LogTransaction.clear
26
23
  end
27
24
 
28
- private
29
- def format_request(env)
30
- request = Rack::Request.new(env)
31
- params = request.params
32
- begin
33
- params = JSON.parse(request.body.read) if env['CONTENT_TYPE'] == 'application/json'
34
- rescue
35
- # do nothing, params is already set
36
- end
25
+ private
37
26
 
38
- request_data = {
39
- method: env['REQUEST_METHOD'],
40
- path: env['PATH_INFO'],
41
- query: env['QUERY_STRING'],
42
- host: Napa::Identity.hostname,
43
- pid: Napa::Identity.pid,
44
- revision: Napa::Identity.revision,
45
- params: params
46
- }
47
- request_data[:user_id] = current_user.try(:id) if defined?(current_user)
48
- {request: request_data}
49
- end
27
+ def format_request(env)
28
+ request = Rack::Request.new(env)
29
+ params = request.params
30
+ begin
31
+ params = JSON.parse(request.body.read) if env['CONTENT_TYPE'] == 'application/json'
32
+ rescue
33
+ # do nothing, params is already set
34
+ end
50
35
 
51
- def format_response(status, headers, body)
52
- response_body = nil
53
- begin
54
- response_body = body.respond_to?(:body) ? body.body.map{|r| r} : nil
55
- rescue
56
- response_body = body.inspect
36
+ request_data = {
37
+ method: env['REQUEST_METHOD'],
38
+ path: env['PATH_INFO'],
39
+ query: env['QUERY_STRING'],
40
+ host: Napa::Identity.hostname,
41
+ pid: Napa::Identity.pid,
42
+ revision: Napa::Identity.revision,
43
+ params: params
44
+ }
45
+ request_data[:user_id] = current_user.try(:id) if defined?(current_user)
46
+ { request: request_data }
57
47
  end
58
-
59
- {response:
60
- {
61
- status: status,
62
- headers: headers,
63
- response: response_body
48
+
49
+ def format_response(status, headers, body)
50
+ response_body = nil
51
+ begin
52
+ response_body = body.respond_to?(:body) ? body.body.map { |r| r } : nil
53
+ rescue
54
+ response_body = body.inspect
55
+ end
56
+
57
+ { response:
58
+ {
59
+ status: status,
60
+ headers: headers,
61
+ response: response_body
62
+ }
64
63
  }
65
- }
66
- end
64
+ end
67
65
  end
68
66
  end
69
67
  end
data/lib/napa/version.rb CHANGED
@@ -1,41 +1,41 @@
1
1
  module Napa
2
- VERSION = "0.1.2"
2
+ VERSION = '0.1.3'
3
3
 
4
4
  class Version
5
5
  class << self
6
6
  def next_major
7
- self.next_level(:major)
7
+ next_level(:major)
8
8
  end
9
9
 
10
10
  def next_minor
11
- self.next_level(:minor)
11
+ next_level(:minor)
12
12
  end
13
13
 
14
14
  def next_patch
15
- self.next_level(:patch)
15
+ next_level(:patch)
16
16
  end
17
17
 
18
18
  def next_level(level)
19
- raise "Unidentified Level" unless [:major,:minor,:patch].include?(level)
19
+ fail 'Unidentified Level' unless [:major, :minor, :patch].include?(level)
20
20
 
21
- parts = Napa::VERSION.split('.').map{|p| p.to_i}
21
+ parts = Napa::VERSION.split('.').map { |p| p.to_i }
22
22
 
23
23
  if level == :major
24
- parts[0] += 1
24
+ parts[0] += 1
25
25
  significant_index = 1
26
26
  end
27
27
 
28
28
  if level == :minor
29
- parts[1] += 1
30
- significant_index = 2
29
+ parts[1] += 1
30
+ significant_index = 2
31
31
  end
32
32
 
33
33
  if level == :patch
34
- parts[2] += 1
34
+ parts[2] += 1
35
35
  significant_index = 3
36
36
  end
37
37
 
38
- parts.map.with_index{|p,i| parts[i] = 0 if i >= significant_index}
38
+ parts.map.with_index { |p, i| parts[i] = 0 if i >= significant_index }
39
39
 
40
40
  parts.join('.')
41
41
  end
data/lib/napa.rb CHANGED
@@ -6,19 +6,19 @@ require 'octokit'
6
6
  require 'grape'
7
7
 
8
8
  # require internal files
9
- require "napa/version"
10
- require "napa/logger/logger"
11
- require "napa/logger/log_transaction"
12
- require "napa/identity"
13
- require "napa/middleware/logger"
14
- require "napa/middleware/app_monitor"
15
- require "napa/activerecord"
16
- require "napa/grape_api"
17
- require "generators/scaffold"
9
+ require 'napa/version'
10
+ require 'napa/logger/logger'
11
+ require 'napa/logger/log_transaction'
12
+ require 'napa/identity'
13
+ require 'napa/middleware/logger'
14
+ require 'napa/middleware/app_monitor'
15
+ require 'napa/activerecord'
16
+ require 'napa/grape_api'
17
+ require 'generators/scaffold'
18
18
 
19
19
  # load rake tasks if Rake installed
20
20
  if defined?(Rake)
21
- load 'tasks/git.rake'
21
+ load 'tasks/git.rake'
22
22
  load 'tasks/deploy.rake'
23
23
  load 'tasks/routes.rake'
24
24
  load 'tasks/db.rake'
@@ -27,7 +27,7 @@ end
27
27
  module Napa
28
28
  class << self
29
29
  def env
30
- @_env ||= ActiveSupport::StringInquirer.new(ENV["RACK_ENV"] || "development")
30
+ @_env ||= ActiveSupport::StringInquirer.new(ENV['RACK_ENV'] || 'development')
31
31
  end
32
32
 
33
33
  def env=(environment)
data/lib/tasks/db.rake CHANGED
@@ -1,87 +1,89 @@
1
- task :environment do
2
- require 'erb'
3
- require './app'
1
+ unless defined?(Rails)
2
+ task :environment do
3
+ require 'erb'
4
+ require './app'
4
5
 
5
- raise "ActiveRecord Not Found" unless Module.const_defined?(:ActiveRecord)
6
- end
7
-
8
- namespace :db do
9
- desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
10
- task :migrate => :environment do
11
- ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
12
- Rake::Task["db:schema:dump"].invoke
6
+ raise "ActiveRecord Not Found" unless Module.const_defined?(:ActiveRecord)
13
7
  end
14
8
 
15
- desc "Create the database"
16
- task :create => :environment do
17
- db = YAML.load(ERB.new(File.read('./config/database.yml')).result)[Napa.env]
18
- adapter = db.merge({'database'=> 'mysql'})
19
- ActiveRecord::Base.establish_connection(adapter)
20
- ActiveRecord::Base.connection.create_database(db.fetch('database'))
21
- end
9
+ namespace :db do
10
+ desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
11
+ task :migrate => :environment do
12
+ ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
13
+ Rake::Task["db:schema:dump"].invoke unless Napa.env.production?
14
+ end
22
15
 
23
- desc "Delete the database"
24
- task :drop => :environment do
25
- db = YAML.load(ERB.new(File.read('./config/database.yml')).result)[Napa.env]
26
- adapter = db.merge({'database'=> 'mysql'})
27
- ActiveRecord::Base.establish_connection(adapter)
28
- ActiveRecord::Base.connection.drop_database(db.fetch('database'))
29
- end
16
+ desc "Create the database"
17
+ task :create => :environment do
18
+ db = YAML.load(ERB.new(File.read('./config/database.yml')).result)[Napa.env]
19
+ adapter = db.merge({'database'=> 'mysql'})
20
+ ActiveRecord::Base.establish_connection(adapter)
21
+ ActiveRecord::Base.connection.create_database(db.fetch('database'))
22
+ end
30
23
 
31
- desc "Create the test database"
32
- task :reset => :environment do
33
- Rake::Task["db:drop"].invoke
34
- Rake::Task["db:create"].invoke
35
- Rake::Task["db:schema:load"].invoke
36
- end
24
+ desc "Delete the database"
25
+ task :drop => :environment do
26
+ db = YAML.load(ERB.new(File.read('./config/database.yml')).result)[Napa.env]
27
+ adapter = db.merge({'database'=> 'mysql'})
28
+ ActiveRecord::Base.establish_connection(adapter)
29
+ ActiveRecord::Base.connection.drop_database(db.fetch('database'))
30
+ end
37
31
 
38
- namespace :generate do
39
- desc "Generate a migration with given name. Specify migration name with NAME=my_migration_name"
40
- task :migration => :environment do
41
- raise "Please specify desired migration name with NAME=my_migration_name" unless ENV['NAME']
42
-
43
- # Find migration name from env
44
- migration_name = ENV['NAME'].strip.chomp
45
-
46
- # Define migrations path (needed later)
47
- migrations_path = './db/migrate'
48
-
49
- # Find the highest existing migration version or set to 1
50
- if (existing_migrations = Dir[File.join(migrations_path, '*.rb')]).length > 0
51
- version = File.basename(existing_migrations.sort.reverse.first)[/^(\d+)_/,1].to_i + 1
52
- else
53
- version = 1
54
- end
55
-
56
- # Use the migration template to fill the body of the migration
57
- migration_content = Napa::ActiveRecord.migration_template(migration_name.camelize)
58
-
59
- # Generate migration filename
60
- migration_filename = "#{"%03d" % version}_#{migration_name}.rb"
61
-
62
- # Write the migration
63
- File.open(File.join(migrations_path, migration_filename), "w+") do |migration|
64
- migration.puts migration_content
65
- end
66
-
67
- # Done!
68
- puts "Successfully created migration #{migration_filename}"
32
+ desc "Create the test database"
33
+ task :reset => :environment do
34
+ Rake::Task["db:drop"].invoke
35
+ Rake::Task["db:create"].invoke
36
+ Rake::Task["db:schema:load"].invoke
69
37
  end
70
- end
71
-
72
- namespace :schema do
73
- desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
74
- task :dump => :environment do
75
- require 'active_record/schema_dumper'
76
- File.open(ENV['SCHEMA'] || "db/schema.rb", "w") do |file|
77
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
38
+
39
+ namespace :generate do
40
+ desc "Generate a migration with given name. Specify migration name with NAME=my_migration_name"
41
+ task :migration => :environment do
42
+ raise "Please specify desired migration name with NAME=my_migration_name" unless ENV['NAME']
43
+
44
+ # Find migration name from env
45
+ migration_name = ENV['NAME'].strip.chomp
46
+
47
+ # Define migrations path (needed later)
48
+ migrations_path = './db/migrate'
49
+
50
+ # Find the highest existing migration version or set to 1
51
+ if (existing_migrations = Dir[File.join(migrations_path, '*.rb')]).length > 0
52
+ version = File.basename(existing_migrations.sort.reverse.first)[/^(\d+)_/,1].to_i + 1
53
+ else
54
+ version = 1
55
+ end
56
+
57
+ # Use the migration template to fill the body of the migration
58
+ migration_content = Napa::ActiveRecord.migration_template(migration_name.camelize)
59
+
60
+ # Generate migration filename
61
+ migration_filename = "#{"%03d" % version}_#{migration_name}.rb"
62
+
63
+ # Write the migration
64
+ File.open(File.join(migrations_path, migration_filename), "w+") do |migration|
65
+ migration.puts migration_content
66
+ end
67
+
68
+ # Done!
69
+ puts "Successfully created migration #{migration_filename}"
78
70
  end
79
71
  end
80
-
81
- desc "Load a schema.rb file into the database"
82
- task :load => :environment do
83
- file = ENV['SCHEMA'] || "db/schema.rb"
84
- load(file)
72
+
73
+ namespace :schema do
74
+ desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
75
+ task :dump => :environment do
76
+ require 'active_record/schema_dumper'
77
+ File.open(ENV['SCHEMA'] || "db/schema.rb", "w") do |file|
78
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
79
+ end
80
+ end
81
+
82
+ desc "Load a schema.rb file into the database"
83
+ task :load => :environment do
84
+ file = ENV['SCHEMA'] || "db/schema.rb"
85
+ load(file)
86
+ end
85
87
  end
86
88
  end
87
- end
89
+ end
data/napa.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'logging'
21
21
  gem.add_dependency 'dotenv'
22
22
  gem.add_dependency 'octokit', '~> 1.25'
23
- gem.add_dependency 'virtus', '0.5.5'
23
+ gem.add_dependency 'virtus'
24
24
  gem.add_dependency 'grape'
25
25
  gem.add_dependency 'grape-swagger'
26
26
  gem.add_dependency 'unicorn'
@@ -28,4 +28,5 @@ Gem::Specification.new do |gem|
28
28
  gem.add_development_dependency "rspec"
29
29
  gem.add_development_dependency "pry"
30
30
  gem.add_development_dependency "git"
31
+ gem.add_development_dependency "rubocop"
31
32
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'napa/identity'
3
3
 
4
4
  describe Napa::Identity do
5
- context "#name" do
5
+ context '#name' do
6
6
  it "returns 'api-service' if no ENV['SERVICE_NAME'] is set" do
7
7
  ENV['SERVICE_NAME'] = nil
8
8
  Napa::Identity.name.should == 'api-service'
@@ -11,40 +11,40 @@ describe Napa::Identity do
11
11
  it "returns the ENV['SERVICE_NAME'] when specified" do
12
12
  ENV['SERVICE_NAME'] = nil
13
13
  ENV['SERVICE_NAME'] = 'my-service'
14
- Napa::Identity.name.should == 'my-service'
14
+ Napa::Identity.name.should eq('my-service')
15
15
  end
16
16
  end
17
17
 
18
- context "#hostname" do
19
- it "returns the value of the hostname system call and doesn't make a second system call" do
20
- Napa::Identity.should_receive(:`).with("hostname").and_return("system-hostname")
21
- Napa::Identity.hostname.should == 'system-hostname'
18
+ context '#hostname' do
19
+ it 'returns the value of the hostname system call and doesn\'t make a second system call' do
20
+ Napa::Identity.should_receive(:`).with('hostname').and_return('system-hostname')
21
+ Napa::Identity.hostname.should eq('system-hostname')
22
22
 
23
- Napa::Identity.should_not_receive(:`).with("hostname")
24
- Napa::Identity.hostname.should == 'system-hostname'
23
+ Napa::Identity.should_not_receive(:`).with('hostname')
24
+ Napa::Identity.hostname.should eq('system-hostname')
25
25
  end
26
26
  end
27
27
 
28
- context "#revision" do
29
- it "returns the value of the 'git rev-parse HEAD' system call and doesn't make a second system call" do
30
- Napa::Identity.should_receive(:`).with("git rev-parse HEAD").and_return("12345")
31
- Napa::Identity.revision.should == '12345'
28
+ context '#revision' do
29
+ it 'returns the value of the \'git rev-parse HEAD\' system call and doesn\'t make a second system call' do
30
+ Napa::Identity.should_receive(:`).with('git rev-parse HEAD').and_return('12345')
31
+ Napa::Identity.revision.should eq('12345')
32
32
 
33
- Napa::Identity.should_not_receive(:`).with("git rev-parse HEAD")
34
- Napa::Identity.revision.should == '12345'
33
+ Napa::Identity.should_not_receive(:`).with('git rev-parse HEAD')
34
+ Napa::Identity.revision.should eq('12345')
35
35
  end
36
36
  end
37
37
 
38
- context "#pid" do
39
- it "returns the process ID value" do
38
+ context '#pid' do
39
+ it 'returns the process ID value' do
40
40
  Process.stub(:pid).and_return(112233)
41
- Napa::Identity.pid.should == 112233
41
+ Napa::Identity.pid.should be(112233)
42
42
  end
43
43
  end
44
44
 
45
- context "#platform_revision" do
46
- it "returns the current version of the platform gem" do
45
+ context '#platform_revision' do
46
+ it 'returns the current version of the platform gem' do
47
47
  Napa::Identity.platform_revision.should == Napa::VERSION
48
48
  end
49
49
  end
50
- end
50
+ end
@@ -6,29 +6,29 @@ describe Napa::LogTransaction do
6
6
  Napa::LogTransaction.clear
7
7
  end
8
8
 
9
- context "#id" do
10
- it "returns the current transaction id if it has been set" do
9
+ context '#id' do
10
+ it 'returns the current transaction id if it has been set' do
11
11
  id = SecureRandom.hex(10)
12
12
  Thread.current[:napa_tid] = id
13
13
  Napa::LogTransaction.id.should == id
14
14
  end
15
15
 
16
- it "sets and returns a new id if the transaction id hasn't been set" do
16
+ it 'sets and returns a new id if the transaction id hasn\'t been set' do
17
17
  Napa::LogTransaction.id.should_not be_nil
18
18
  end
19
19
 
20
- it "allows the id to be overridden by a setter" do
20
+ it 'allows the id to be overridden by a setter' do
21
21
  Napa::LogTransaction.id.should_not be_nil
22
22
  Napa::LogTransaction.id = 'foo'
23
23
  Napa::LogTransaction.id.should == 'foo'
24
24
  end
25
25
  end
26
26
 
27
- context "#clear" do
28
- it "sets the id to nil" do
27
+ context '#clear' do
28
+ it 'sets the id to nil' do
29
29
  Napa::LogTransaction.id.should_not be_nil
30
30
  Napa::LogTransaction.clear
31
31
  Thread.current[:napa_tid].should be_nil
32
32
  end
33
33
  end
34
- end
34
+ end
data/spec/version_spec.rb CHANGED
@@ -2,39 +2,39 @@ require 'spec_helper'
2
2
  require 'napa/version'
3
3
 
4
4
  describe Napa::Version do
5
- context "#major_bump" do
6
- it "should set the major revision value, and the rest should be 0" do
7
- stub_const("Napa::VERSION", "1.2.3")
8
- Napa::Version.next_major.should == "2.0.0"
5
+ context '#major_bump' do
6
+ it 'should set the major revision value, and the rest should be 0' do
7
+ stub_const('Napa::VERSION', '1.2.3')
8
+ Napa::Version.next_major.should == '2.0.0'
9
9
  end
10
10
 
11
- it "should set the major revision value, and the rest should be 0" do
12
- stub_const("Napa::VERSION", "5.0.0")
13
- Napa::Version.next_major.should == "6.0.0"
11
+ it 'should set the major revision value, and the rest should be 0' do
12
+ stub_const('Napa::VERSION', '5.0.0')
13
+ Napa::Version.next_major.should == '6.0.0'
14
14
  end
15
15
  end
16
16
 
17
- context "#minor_bump" do
18
- it "should set the minor revision value, leaving the major value unchanged and the patch value to 0" do
19
- stub_const("Napa::VERSION", "1.2.3")
20
- Napa::Version.next_minor.should == "1.3.0"
17
+ context '#minor_bump' do
18
+ it 'should set the minor revision value, leaving the major value unchanged and the patch value to 0' do
19
+ stub_const('Napa::VERSION', '1.2.3')
20
+ Napa::Version.next_minor.should == '1.3.0'
21
21
  end
22
22
 
23
- it "should set the minor revision value, leaving the major value unchanged and the patch value to 0" do
24
- stub_const("Napa::VERSION", "0.5.0")
25
- Napa::Version.next_minor.should == "0.6.0"
23
+ it 'should set the minor revision value, leaving the major value unchanged and the patch value to 0' do
24
+ stub_const('Napa::VERSION', '0.5.0')
25
+ Napa::Version.next_minor.should == '0.6.0'
26
26
  end
27
27
  end
28
28
 
29
- context "patch_bump" do
30
- it "should set the patch revision value, leaving the major and minor values unchanged" do
31
- stub_const("Napa::VERSION", "1.2.3")
32
- Napa::Version.next_patch.should == "1.2.4"
29
+ context 'patch_bump' do
30
+ it 'should set the patch revision value, leaving the major and minor values unchanged' do
31
+ stub_const('Napa::VERSION', '1.2.3')
32
+ Napa::Version.next_patch.should == '1.2.4'
33
33
  end
34
34
 
35
- it "should set the patch revision value, leaving the major and minor values unchanged" do
36
- stub_const("Napa::VERSION", "5.5.5")
37
- Napa::Version.next_patch.should == "5.5.6"
35
+ it 'should set the patch revision value, leaving the major and minor values unchanged' do
36
+ stub_const('Napa::VERSION', '5.5.5')
37
+ Napa::Version.next_patch.should == '5.5.6'
38
38
  end
39
39
  end
40
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: napa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.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-10-31 00:00:00.000000000 Z
12
+ date: 2013-11-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -80,17 +80,17 @@ dependencies:
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - '='
83
+ - - ! '>='
84
84
  - !ruby/object:Gem::Version
85
- version: 0.5.5
85
+ version: '0'
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - '='
91
+ - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
- version: 0.5.5
93
+ version: '0'
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: grape
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +187,22 @@ dependencies:
187
187
  - - ! '>='
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: rubocop
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
190
206
  description: A simple framework for building APIs with Grape
191
207
  email:
192
208
  - darby@bellycard.com
@@ -196,6 +212,7 @@ extensions: []
196
212
  extra_rdoc_files: []
197
213
  files:
198
214
  - .gitignore
215
+ - .rubocop.yml
199
216
  - Gemfile
200
217
  - LICENSE
201
218
  - README.md
@@ -205,6 +222,7 @@ files:
205
222
  - lib/generators/templates/scaffold/.env
206
223
  - lib/generators/templates/scaffold/.env.test
207
224
  - lib/generators/templates/scaffold/.gitignore.tpl
225
+ - lib/generators/templates/scaffold/.rubocop.yml
208
226
  - lib/generators/templates/scaffold/Gemfile
209
227
  - lib/generators/templates/scaffold/README.md
210
228
  - lib/generators/templates/scaffold/Rakefile
@@ -252,7 +270,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
252
270
  version: '0'
253
271
  segments:
254
272
  - 0
255
- hash: -194936374716762064
273
+ hash: -3815573023004026351
256
274
  required_rubygems_version: !ruby/object:Gem::Requirement
257
275
  none: false
258
276
  requirements:
@@ -261,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
279
  version: '0'
262
280
  segments:
263
281
  - 0
264
- hash: -194936374716762064
282
+ hash: -3815573023004026351
265
283
  requirements: []
266
284
  rubyforge_project:
267
285
  rubygems_version: 1.8.25