rack-takana 0.9.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 nc
1
+ Copyright (c) 2013 Mech.IO LTD
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,8 +1,8 @@
1
- = edge-rack
1
+ = rack-takana
2
2
 
3
- Description goes here.
3
+ Rack integration for Takana. http://usetakana.com
4
4
 
5
- == Contributing to edge-rack
5
+ == Contributing to rack-takana
6
6
 
7
7
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
8
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
@@ -14,6 +14,6 @@ Description goes here.
14
14
 
15
15
  == Copyright
16
16
 
17
- Copyright (c) 2012 nc. See LICENSE.txt for
17
+ Copyright (c) 2013 Mech.IO. See LICENSE.txt for
18
18
  further details.
19
19
 
@@ -1,10 +1,17 @@
1
1
  require 'rack'
2
2
  require 'pathname'
3
3
  require 'sequel'
4
+ require 'net/http'
4
5
 
5
6
  module Takana
7
+
6
8
  def self.sqlite_filepath
7
- Pathname.new(File.expand_path("~")).join("Library", "Application Support", "Edge", "takana.db").to_s
9
+ if ENV['TAKANA_ENV'] == "test"
10
+ File.expand_path("./test.db")
11
+ else
12
+ Pathname.new( File.expand_path("~") ).
13
+ join("Library", "Application Support", "Edge", "takana.db").to_s
14
+ end
8
15
  end
9
16
 
10
17
  def self.initialize_db
@@ -16,11 +23,20 @@ module Takana
16
23
  def self.db
17
24
  @db
18
25
  end
26
+
27
+ def self.migrate!
28
+ Sequel.extension :migration
29
+
30
+ Sequel::Migrator.run(Takana.db, File.expand_path("../sassy_bunny/app/db/migrations").to_s, use_transactions: true)
31
+ end
19
32
  end
20
33
 
21
34
  Takana.initialize_db
22
35
 
23
36
  if Takana.db
37
+
38
+ Takana.migrate! if ENV['TAKANA_ENV'] == "test"
39
+
24
40
  require 'rack-takana/models/project'
25
41
  require 'rack-takana/models/load_path'
26
42
  require 'rack-takana/models/compass_config'
@@ -14,6 +14,7 @@ module Takana
14
14
  @kind, @paths = detect_kind!
15
15
  @debug = false
16
16
  @host = "localhost"
17
+ @port = 48626
17
18
 
18
19
  if Takana.db
19
20
 
@@ -23,10 +24,17 @@ module Takana
23
24
 
24
25
  @project = Takana::Project[name: name] || Takana::Project.create(name: name, path: path, activated: false)
25
26
 
26
- @paths.each { |p| @project.add_load_path(path: p, source: 'takana-rack') }
27
+ @paths.each do |path|
28
+ unless @project.load_paths.find { |_| _.path == path.to_s }.present?
29
+ @project.add_load_path(path: path.to_s, source: 'rack-takana')
30
+ end
31
+
32
+ end
27
33
 
28
34
  if defined?(Compass) && defined?(Rails) && Rails.application.config.compass.present?
29
35
 
36
+ Rails.logger.debug "[Takana] detected compass. Attempting to load configuration"
37
+
30
38
  begin
31
39
  config = Rails.application.config.compass.serialize
32
40
 
@@ -37,13 +45,24 @@ module Takana
37
45
  attributes[k] = Rails.application.config.compass.send(k)
38
46
  end
39
47
 
40
- @project.compass_configs.delete
48
+ @project.compass_configs.each(&:delete)
41
49
  @project.add_compass_config(
42
- config: compass_config,
43
- attributes: attributes
50
+ config: config,
51
+ attributes: Marshal.dump(attributes)
44
52
  )
45
53
  end
54
+
55
+ # tell projects to reload
56
+ begin
57
+ url = URI.parse("http://#{@host}:#{@port}/projects/load")
58
+ req = Net::HTTP::Get.new(url.to_s)
59
+ res = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
60
+ rescue => e
61
+ Rails.logger.debug "[Takana] project reload request failed, perhaps takana isn't running #{e.inspect}"
62
+ end
63
+
46
64
  rescue => e
65
+ Rails.logger.debug "[Takana] failed to load compass configuration"
47
66
 
48
67
  end
49
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-takana
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.14.0
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-01-17 00:00:00.000000000 Z
12
+ date: 2013-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -75,6 +75,54 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 1.8.4
78
+ - !ruby/object:Gem::Dependency
79
+ name: combustion
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec-rails
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
78
126
  description: Connects your rack app to Takana (http://www.usetakana.com) so you can
79
127
  live edit stylesheets within a Rails app
80
128
  email: support@mech.io
@@ -107,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
155
  version: '0'
108
156
  segments:
109
157
  - 0
110
- hash: 2009484903996514444
158
+ hash: -205042569319427328
111
159
  required_rubygems_version: !ruby/object:Gem::Requirement
112
160
  none: false
113
161
  requirements: