atech 1.0.17 → 1.0.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ module ActiveRecord
2
+ class Base
3
+
4
+ ## Add a shortcut for adding a dependency for a model
5
+ def self.concerned_with(*concerns)
6
+ concerns.each do |concern|
7
+ require_dependency "#{name.underscore}/#{concern}"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -17,6 +17,11 @@ module ActiveRecord
17
17
  end
18
18
  end
19
19
 
20
+ def destroy(*args)
21
+ puts "\e[31mdestroyed\e[0m #{self.class.name} ##{self.id}"
22
+ super(*args)
23
+ end
24
+
20
25
  def self.seedable?
21
26
  actual_count = self.count.to_i
22
27
  return (actual_count == 0) unless Rails.env.development?
@@ -54,5 +54,10 @@ module Atech
54
54
  end
55
55
  end
56
56
 
57
+ ## Sets the page title to be passed value or returns the current value if it's empty
58
+ def page_title(text = nil)
59
+ text ? (@page_title = text) : @page_title
60
+ end
61
+
57
62
  end
58
63
  end
@@ -26,7 +26,7 @@ module Atech
26
26
  attr_accessor :networks
27
27
 
28
28
  def networks
29
- @networks ||= ['127.0.0.1/32', '109.224.145.104/29', '83.170.74.114/32', '10.0.1.0/24']
29
+ @networks ||= ['127.0.0.1/32', '109.224.145.104/29', '188.65.183.34/32', '10.0.1.0/24']
30
30
  end
31
31
 
32
32
  def approved_ip?(requested_ip)
@@ -0,0 +1,63 @@
1
+ module Atech
2
+ ## The aTech stats reporter return information about the application which
3
+ ## can be access by accessing the stats URL. This should be configured in your
4
+ ## application initializer.
5
+ ##
6
+ ## Atech::StatsReporter.application_name = 'my-application'
7
+ ## Atech::StatsReporter.application_key = 'your random key here'
8
+ ## Atech::StatsReporter.stats = Proc.new do
9
+ ## {
10
+ ## :last_activity => Event.last.created_at,
11
+ ## :projects => Project.count,
12
+ ## :repositories => Repositories::Repository.count,
13
+ ## :disk_usage => Repositories::Repository.sum(:disk_usage)
14
+ ## }
15
+ ## end
16
+ ##
17
+ class StatsReporter
18
+
19
+ class << self
20
+ attr_accessor :application_name
21
+ attr_accessor :application_key
22
+ attr_accessor :stats
23
+
24
+ def application_name
25
+ @application_name ||= "Application"
26
+ end
27
+
28
+ def stats
29
+ @stats ||= Proc.new do
30
+ Hash.new
31
+ end
32
+ end
33
+
34
+ def repo_stats
35
+ @repo_stats ||= {
36
+ :ref => `git log --pretty='%H' -n 1`.chomp,
37
+ :path => `git remote show -n origin | grep Fetch`.split(/\:\s*/, 2).last.strip
38
+ }
39
+ end
40
+ end
41
+
42
+ def call(env)
43
+ dup._call(env)
44
+ end
45
+
46
+ def _call(env)
47
+ req = Rack::Request.new(env)
48
+
49
+ if req.params['key'] != self.class.application_key
50
+ return [403, {}, ["Access Denied"]]
51
+ end
52
+
53
+ hash = {
54
+ :name => self.class.application_name,
55
+ :repo => self.class.repo_stats,
56
+ :props => self.class.stats.call
57
+ }
58
+
59
+ [200, {}, [ActiveSupport::JSON.encode(hash)]]
60
+ end
61
+
62
+ end
63
+ end
@@ -17,7 +17,7 @@ require 'active_support/string_inquirer'
17
17
  if defined?(ActionController::Request)
18
18
  class ActionController::Request
19
19
  def user_agent
20
- Atech::UserAgent.new(env['HTTP_USER_AGENT'])
20
+ env['HTTP_USER_AGENT'].is_a?(String) ? Atech::UserAgent.new(env['HTTP_USER_AGENT']) : nil
21
21
  end
22
22
  end
23
23
  end
@@ -30,6 +30,8 @@ module Atech
30
30
  when /(windows)|(win(\d{2}))/i then :windows
31
31
  when /linux/i then :linux
32
32
  when /macintosh/i then :mac
33
+ when /(iPhone)|(iPod)/ then :iphone
34
+ when /iPad/ then :ipad
33
35
  else :unknown
34
36
  end.to_s)
35
37
  end
@@ -48,6 +50,7 @@ module Atech
48
50
  @name_and_version ||= case self
49
51
  when /MSIE (\d+)/i then [:ie, $1.to_i]
50
52
  when /Firefox\/(\d+)/ then [:firefox, $1.to_i]
53
+ when /Version\/(\d+).*Mobile\/.+Safari/ then [:mobile_safari, $1.to_i]
51
54
  when /Chrome\/(\d+)/ then [:chrome, $1.to_i]
52
55
  when /Version\/(\d+).*Safari\//i then [:safari, $1.to_i]
53
56
  else [:unknown, 0]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atech
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 17
10
- version: 1.0.17
9
+ - 18
10
+ version: 1.0.18
11
11
  platform: ruby
12
12
  authors:
13
13
  - aTech Media
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-11 00:00:00 +01:00
18
+ date: 2011-02-25 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -29,13 +29,14 @@ extra_rdoc_files: []
29
29
 
30
30
  files:
31
31
  - lib/atech/base.rb
32
- - lib/atech/configuration.rb
32
+ - lib/atech/extensions/active_record.rb
33
33
  - lib/atech/extensions/controller_tests.rb
34
34
  - lib/atech/extensions/seeds.rb
35
35
  - lib/atech/extensions/string.rb
36
36
  - lib/atech/helpers.rb
37
37
  - lib/atech/network_restrictions.rb
38
38
  - lib/atech/record_identifier.rb
39
+ - lib/atech/stats_reporter.rb
39
40
  - lib/atech/user_agent.rb
40
41
  has_rdoc: true
41
42
  homepage: http://github.com/atech/atech
@@ -1,43 +0,0 @@
1
- ## This module allows you to create application specific configuration options.
2
- ## You can define a block to set your variables or you can simply set them
3
- ## on an instance of the object. The application should define this to begin
4
- ## with (`Codebase.settings = Atech::Configuration.new`) or something.
5
-
6
- module Atech
7
- class Configuration
8
-
9
- attr_reader :attributes
10
-
11
- def initialize(attributes = Hash.new)
12
- @attributes = attributes
13
- end
14
-
15
- def setup!(&block)
16
- block.call(self)
17
- end
18
-
19
- def method_missing(method_name, value = nil)
20
- method_name = method_name.to_s
21
- if method_name[-1,1] == '='
22
- method_name.gsub!(/\=\z/, '')
23
- attributes[method_name] = value
24
- else
25
- question = false
26
- if method_name =~ /\?\z/
27
- method_name.gsub!(/\?\z/, '')
28
- question = true
29
- end
30
-
31
- if attributes.keys.include?(method_name)
32
- if question
33
- !!attributes[method_name]
34
- else
35
- attributes[method_name]
36
- end
37
- else
38
- raise NoMethodError, "undefined configurtion attribute `#{method_name}' for #{self}"
39
- end
40
- end
41
- end
42
- end
43
- end