slack_messaging 1.0.1 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 263c95f1178d714e3fea8e2531caa97e43532f9f
4
- data.tar.gz: 882b3026e39ad6217d32876c7ce8ddb6b25d8d46
3
+ metadata.gz: d78f53c59095f17ce3bd0f2a19de2d1cd933cecf
4
+ data.tar.gz: f4cb1ea1c452a4a8f39e96fb1ee46bf58cf24f07
5
5
  SHA512:
6
- metadata.gz: 8e903967552e5286684f052f79257daa7984fac87b989cc6d177278d1eafa4c7cefaaf8d31b042be85dce76eba51063f757ef5ca73f1677d5d1c4190e37e680f
7
- data.tar.gz: 0619d2d30f69863832ec222187fae8da237207ff76c398965eb016ed6d65cc66e088bc7a771735a8ab57059e6894ece6b5aa0f070f2bd287a444e58024e6b236
6
+ metadata.gz: 315fe8c28b86d74563ce09ea49662df5e0e2ca050b242398a59c221c964e7c48de2277315f0e12b4fcecd0e984eb2b4cf57c107e51532c14564f1ef8be156bbd
7
+ data.tar.gz: dcd20a21275cc88abb808c2581bb08f9f591b5e00f401dc6ddf1fc81f1b11131f8c883cc691494aabeefffaf632e7bc55492cd449ed668caaa2d1733e12c4aef
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,6 @@
1
+ #### v1.1.0
2
+ * Updating config.rb with more up to date information
3
+
1
4
  #### v1.0.1
2
5
  * Adding back in Changelog
3
6
 
data/README.md CHANGED
@@ -2,16 +2,25 @@
2
2
 
3
3
  This is a simple project designed to post messages to a given Slack channel as a bot.
4
4
 
5
- ### Usage
5
+ ## Installation
6
6
 
7
- First, run:
7
+ Add this line to your application's Gemfile:
8
8
 
9
+ ```ruby
10
+ gem 'slack_messaging'
9
11
  ```
10
- gem install bundler
11
- bundle install
12
- ```
13
12
 
14
- Then, the project should be ready to go! However, it won't necessarily know where to print to Slack. So, this project requires a config file called `~/.slack_messaging.yml`. The config file should look like this:
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install slack_messaging
20
+
21
+ ### Usage
22
+
23
+ This project requires a config file that should look like this:
15
24
 
16
25
  ```
17
26
  slack:
@@ -21,9 +30,13 @@ slack:
21
30
  icon_emoji: ":[SOME EMOJI]:"
22
31
  ```
23
32
 
33
+ The default is for the file to be named `~/.slack_messaging.yml`, but a different path can be passed in like this:
34
+
35
+ $ slack-messaging --config="/PATH/TO/FILE/config.yml" slack
36
+
24
37
  To obtain the webhook url, go to [this link](https://api.slack.com/incoming-webhooks).
25
38
 
26
- Okay, now the project will _actually_ be ready to rock and roll.
39
+ Okay, now the project will be ready to rock and roll.
27
40
 
28
41
  To print a friendly message to Slack, run:
29
42
 
@@ -62,3 +75,18 @@ To contribute:
62
75
  3. Commit your changes (`git commit -am 'Add some feature'`)
63
76
  4. Push to the branch (`git push origin my-new-feature`)
64
77
  5. Create a new Pull Request
78
+
79
+ ### RubyGems
80
+ To make a new version and push to RubyGems:
81
+
82
+ 1. Update the CHANGELOG.markdown with the new version and changes made
83
+
84
+ 3. Run `git add -A && git commit -m "Updating Changelog for [version number]"`
85
+
86
+ 2. Update `lib/slack_messaging/version.rb` with the new version number
87
+
88
+ 4. Run `git add -A && git commit -m "Version Bump" && git push`
89
+
90
+ 5. Run `gem build slack_messaging.gemspec && gem push *.gem`
91
+
92
+ 6. Run `rm *.gem`
@@ -1,14 +1,8 @@
1
1
  require 'yaml'
2
+ require 'hashie'
2
3
 
3
4
  module SlackMessaging
4
5
 
5
- module PrivateAttrAccessor
6
- def private_attr_accessor(*names)
7
- private
8
- attr_accessor *names
9
- end
10
- end
11
-
12
6
  class DefaultPaths
13
7
  class << self
14
8
  def config
@@ -22,15 +16,10 @@ module SlackMessaging
22
16
  end
23
17
 
24
18
  class Config
25
-
26
- CONFIG_DEFAULTS = {}
27
-
28
19
  class << self
29
- extend PrivateAttrAccessor
30
- private_attr_accessor :config_data
31
20
 
32
21
  def config
33
- CONFIG_DEFAULTS.merge data
22
+ config_data.to_hash
34
23
  end
35
24
 
36
25
  def load(path)
@@ -38,54 +27,22 @@ module SlackMessaging
38
27
  config
39
28
  end
40
29
 
41
- def set_config_options(opts = {})
42
- data.merge! opts
43
- config
30
+ def config_data
31
+ @config_data ||= Hashie::Mash.new
44
32
  end
45
-
46
- def data
47
- self.config_data ||= {}
48
- end
49
- private :data
50
-
51
- def default_value(key)
52
- CONFIG_DEFAULTS[key.to_sym]
53
- end
54
- private :default_value
33
+ private :config_data
55
34
 
56
35
  def method_missing(method, args=false)
57
- return data[method] if data[method]
58
- return default_value(method) if default_value(method)
59
- nil
36
+ config_data.send(method, args)
60
37
  end
61
38
  private :method_missing
62
39
 
63
40
  def load_config(file)
64
41
  raise MissingConfig, "Missing configuration file: #{file}" unless File.exist?(file)
65
- self.config_data = symbolize_keys(YAML.load_file(file)) rescue {}
42
+ YAML.load_file(file).each{ |key,value| config_data.assign_property(key, value) }
66
43
  end
67
44
  private :load_config
68
45
 
69
- # We want all ouf our YAML loaded keys to be symbols
70
- # taken from http://devblog.avdi.org/2009/07/14/recursively-symbolize-keys/
71
- def symbolize_keys(hash)
72
- hash.inject({}){|result, (key, value)|
73
- new_key = case key
74
- when String then key.to_sym
75
- else key
76
- end
77
- new_value = case value
78
- when Hash then symbolize_keys(value)
79
- else value
80
- end
81
- result[new_key] = new_value
82
- result
83
- }
84
- end
85
- private :symbolize_keys
86
-
87
46
  end
88
-
89
- MissingConfig = Class.new(StandardError)
90
47
  end
91
48
  end
@@ -1,3 +1,3 @@
1
1
  module SlackMessaging
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -4,32 +4,13 @@ require 'slack_messaging'
4
4
  module SlackMessaging
5
5
  describe Config do
6
6
 
7
- context "#set_config_options" do
8
- it "should create a corresponding method that returns the value" do
9
- SlackMessaging::Config.set_config_options(test: "something")
10
- expect(SlackMessaging::Config.test).to eql("something")
11
- end
12
-
13
- it "setting a new key should return the entire config hash" do
14
- items = SlackMessaging::Config.config.count
15
- expect(SlackMessaging::Config.set_config_options(test1: "something_else").count).to eql(items + 1)
16
- expect(SlackMessaging::Config.set_config_options(test2: "something else").count).to eql(items + 2)
17
- end
18
- end
19
-
20
- context "#config_data" do
21
- it "should be a private method" do
22
- expect(SlackMessaging::Config).not_to respond_to(:config_data)
23
- end
24
- end
25
-
26
7
  context "config key methods" do
27
8
  it "should return nil when not set" do
28
9
  expect(SlackMessaging::Config.doesnt_exist).to eql(nil)
10
+ expect(SlackMessaging::Config.doesnt_exist?).to eql(false)
29
11
  end
30
-
31
12
  it "should return the config value when set" do
32
- SlackMessaging::Config.set_config_options(new_value: "testing")
13
+ SlackMessaging::Config.new_value = "testing"
33
14
  expect(SlackMessaging::Config.new_value).to eql("testing")
34
15
  end
35
16
  end
@@ -37,7 +18,7 @@ module SlackMessaging
37
18
  context "after loading a config file" do
38
19
  before do
39
20
  config_file = {"domain" => "example_domain",
40
- "slack" => {"slack_option"=>true,
21
+ "slack" => {"slack_option" => true,
41
22
  "username" => "Rspec Tester",
42
23
  "icon_url" => "http://fake.url",
43
24
  "channel" => "#test-channel",
@@ -55,7 +36,7 @@ module SlackMessaging
55
36
 
56
37
  it "overwriting values should work" do
57
38
  expect(SlackMessaging::Config.slack).to be_kind_of(Hash)
58
- SlackMessaging::Config.set_config_options(slack: "this is a string now")
39
+ SlackMessaging::Config.slack = "this is a string now"
59
40
  expect(SlackMessaging::Config.slack).to eql("this is a string now")
60
41
  end
61
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack_messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emma Sax